*** hikidoc.rb.orig Fri Aug 7 20:10:47 2009 --- hikidoc.rb Sat Aug 8 09:20:38 2009 *************** *** 58,63 **** --- 58,64 ---- @options = default_options.merge(options) @header_re = nil @level = options[:level] || 1 + @plugin_blocks = [] @plugin_syntax = options[:plugin_syntax] || method(:valid_plugin_syntax?) end *************** *** 96,102 **** def escape_plugin_blocks(text) s = StringScanner.new(text) buf = "" - @plugin_blocks = [] while chunk = s.scan_until(/\{\{/) tail = chunk[-2, 2] chunk[-2, 2] = "" --- 97,102 ---- *************** *** 329,337 **** INDENTED_PRE_RE = /\A[ \t]/ def compile_indented_pre(f) ! lines = f.span(INDENTED_PRE_RE)\ ! .map {|line| rstrip(line.sub(INDENTED_PRE_RE, "")) } ! text = restore_plugin_block(lines.join("\n")) @output.preformatted(@output.text(text)) end --- 329,361 ---- INDENTED_PRE_RE = /\A[ \t]/ def compile_indented_pre(f) ! text = '' ! brk = false ! rev = [] ! until brk ! line = f.gets ! break if line.nil? ! buf = restore_plugin_block(line).split(/[\r\n]+/) ! buf.each do |l| ! if brk ! rev.push l ! else ! if l.match(INDENTED_PRE_RE) ! text << rstrip(l.sub(INDENTED_PRE_RE, "")) + "\n" ! else ! brk = true ! rev.push l ! end ! end ! end ! end ! text.chomp! ! unless rev.empty? ! escape_plugin_blocks(rev.join("\n")) { |escaped| ! escaped.split(/\n/)\ ! .reverse_each { |l| f.ungets(l) } ! } ! end @output.preformatted(@output.text(text)) end *************** *** 340,347 **** def compile_block_pre(f) m = BLOCK_PRE_OPEN_RE.match(f.gets) or raise UnexpectedError, "must not happen" ! str = restore_plugin_block(f.break(BLOCK_PRE_CLOSE_RE).join.chomp) ! f.gets @output.block_preformatted(str, m[1]) end --- 364,395 ---- def compile_block_pre(f) m = BLOCK_PRE_OPEN_RE.match(f.gets) or raise UnexpectedError, "must not happen" ! str = '' ! brk = false ! until brk ! line = f.gets ! break if line.nil? ! buf = restore_plugin_block(line).split(/[\r\n]+/) ! rev = [] ! buf.each do |l| ! if brk ! rev.push l ! else ! if l.match(BLOCK_PRE_CLOSE_RE) ! brk = true ! else ! str << l + "\n" ! end ! end ! end ! unless rev.empty? ! escape_plugin_blocks(rev.join("\n")) { |escaped| ! escaped.split(/\n/)\ ! .reverse_each { |l| f.ungets(l) } ! } ! end ! end ! str.chomp! @output.block_preformatted(str, m[1]) end