lib/kramdown/parser/kramdown/codeblock.rb in kramdown-1.9.0 vs lib/kramdown/parser/kramdown/codeblock.rb in kramdown-1.10.0

- old
+ new

@@ -30,19 +30,22 @@ end define_parser(:codeblock, CODEBLOCK_START) FENCED_CODEBLOCK_START = /^~{3,}/ - FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?(\w[\w-]*)?\s*?\n(.*?)^\1\2*\s*?\n/m + FENCED_CODEBLOCK_MATCH = /^((~){3,})\s*?((\S+?)(?:\?\S*)?)?\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], nil, :location => start_line_number) + el = new_block_el(:codeblock, @src[5], nil, :location => start_line_number) lang = @src[3].to_s.strip - el.attr['class'] = "language-#{lang}" unless lang.empty? + unless lang.empty? + el.options[:lang] = lang + el.attr['class'] = "language-#{@src[4]}" + end @tree.children << el true else false end