class Aozora2Html::TagParser
注記記法parser
青空記法の入れ子に対応(?)
Public Class Methods
new(input, endchar, chuuki, image, gaiji_dir:)
click to toggle source
# File lib/aozora2html/tag_parser.rb, line 10 def initialize(input, endchar, chuuki, image, gaiji_dir:) # rubocop:disable Lint/MissingSuper unless input.is_a?(Jstream) raise ArgumentError, 'tag_parser must supply Jstream as input' end @stream = input @gaiji_dir = gaiji_dir @buffer = TextBuffer.new @ruby_buf = RubyBuffer.new @chuuki_table = chuuki @images = image # globalな環境を記録するアイテムは共有する必要あり @endchar = endchar # 改行を越えるべきか否か… @section = :tail # 末尾処理と記法内はインデントをしないので等価 @raw = +'' # 外字変換前の生テキストを残したいことがあるらしい end
Public Instance Methods
general_output()
click to toggle source
出力は返しで!
# File lib/aozora2html/tag_parser.rb, line 40 def general_output @ruby_buf.dump_into(@buffer) ans = +'' @buffer.each do |s| if s.is_a?(Aozora2Html::Tag::UnEmbedGaiji) && !s.escaped? # 消してあった※を復活させて ans.concat(GAIJI_MARK) end ans.concat(s.to_s) end [ans, @raw] end
process()
click to toggle source
# File lib/aozora2html/tag_parser.rb, line 53 def process catch(:terminate) do parse end general_output end
read_char()
click to toggle source
method override!
# File lib/aozora2html/tag_parser.rb, line 27 def read_char c = @stream.read_char @raw.concat(c) c end
read_to_nest(endchar)
click to toggle source
Calls superclass method
Aozora2Html#read_to_nest
# File lib/aozora2html/tag_parser.rb, line 33 def read_to_nest(endchar) ans = super(endchar) @raw.concat(ans[1]) ans end