lib/kramdown/parser/kramdown/codeblock.rb in kramdown-1.2.0 vs lib/kramdown/parser/kramdown/codeblock.rb in kramdown-1.3.0

- old
+ new

@@ -19,14 +19,15 @@ CODEBLOCK_START = INDENT CODEBLOCK_MATCH = /(?:#{BLANK_LINE}?(?:#{INDENT}[ \t]*\S.*\n)+(?:(?!#{IAL_BLOCK_START}|#{EOB_MARKER}|^#{OPT_SPACE}#{LAZY_END_HTML_STOP}|^#{OPT_SPACE}#{LAZY_END_HTML_START})^[ \t]*\S.*\n)*)*/ # Parse the indented codeblock at the current location. def parse_codeblock + start_line_number = @src.current_line_number data = @src.scan(self.class::CODEBLOCK_MATCH) data.gsub!(/\n( {0,3}\S)/, ' \\1') data.gsub!(INDENT, '') - @tree.children << new_block_el(:codeblock, data) + @tree.children << new_block_el(:codeblock, data, nil, :location => start_line_number) true end define_parser(:codeblock, CODEBLOCK_START) @@ -34,11 +35,12 @@ FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?(\w+)?\s*?\n(.*?)^\1\2*\s*?\n/m # Parse the fenced codeblock at the current location. def parse_codeblock_fenced if @src.check(self.class::FENCED_CODEBLOCK_MATCH) + start_line_number = @src.current_line_number @src.pos += @src.matched_size - el = new_block_el(:codeblock, @src[4]) + el = new_block_el(:codeblock, @src[4], nil, :location => start_line_number) lang = @src[3].to_s.strip el.attr['class'] = "language-#{lang}" unless lang.empty? @tree.children << el true else