lib/kramdown/parser/kramdown/codeblock.rb in kramdown-0.13.8 vs lib/kramdown/parser/kramdown/codeblock.rb in kramdown-0.14.0

- old
+ new

@@ -42,16 +42,19 @@ end define_parser(:codeblock, CODEBLOCK_START) FENCED_CODEBLOCK_START = /^~{3,}/ - FENCED_CODEBLOCK_MATCH = /^(~{3,})\s*?\n(.*?)^\1~*\s*?\n/m + FENCED_CODEBLOCK_MATCH = /^(~{3,})\s*?(\w+)?\s*?\n(.*?)^\1~*\s*?\n/m # Parse the fenced codeblock at the current location. def parse_codeblock_fenced if @src.check(FENCED_CODEBLOCK_MATCH) @src.pos += @src.matched_size - @tree.children << new_block_el(:codeblock, @src[2]) + el = new_block_el(:codeblock, @src[3]) + lang = @src[2].to_s.strip + el.attr['class'] = "language-#{lang}" unless lang.empty? + @tree.children << el true else false end end