It looks that Kramdown changes the delimiter of a code block from ```
to `
when I use to_kramdown
. The minimum code is below.
require 'kramdown'code = <<END```rbnum = 0while num < 2 do print("num = ", num)endprint("End")```ENDputs code #1doc = Kramdown::Document.new(code)puts doc.to_kramdown #2
This gives you:
```rbnum = 0while num < 2 do print("num = ", num)endprint("End")````rbnum = 0while num < 2 do print("num = ", num)endprint("End")`
How can I restore the code block with ```
?
I checked KD:Documnt
object and it has :codespan_delimiter=>"```"
. Is there any way to use it when I restore?
<KD:Document: options={:template=>"", :auto_ids=>true, :auto_id_stripping=>false, :auto_id_prefix=>"", :transliterated_header_ids=>false, :parse_block_html=>false, :parse_span_html=>true, :html_to_native=>false, :link_defs=>{}, :footnote_nr=>1, :entity_output=>:as_char, :toc_levels=>[1, 2, 3, 4, 5, 6], :line_width=>72, :latex_headers=>["section", "subsection", "subsubsection", "paragraph", "subparagraph", "subparagraph"], :smart_quotes=>["lsquo", "rsquo", "ldquo", "rdquo"], :typographic_symbols=>{}, :remove_block_html_tags=>true, :remove_span_html_tags=>false, :header_offset=>0, :syntax_highlighter=>:rouge, :syntax_highlighter_opts=>{}, :math_engine=>:mathjax, :math_engine_opts=>{}, :footnote_backlink=>"↩", :footnote_backlink_inline=>false, :footnote_prefix=>"", :remove_line_breaks_for_cjk=>false, :forbidden_inline_options=>[:template], :list_indent=>2} root=<kd:root options={:encoding=>#<Encoding:UTF-8>, :location=>1, :options=>{}, :abbrev_defs=>{}, :abbrev_attr=>{}, :footnote_count=>0} children=[<kd:p options={:location=>1} children=[<kd:codespan value="rb\nnum = 0\nwhile num < 2 do\n print(\"num = \", num)\nend\nprint(\"End\")\n" options={:codespan_delimiter=>"```", :location=>1}>]>]> warnings=[]>
I also tried Kramdown GFM Parser but it converts the code block differently as below.
num = 0 while num < 2 do print("num = ", num) end print("End"){: .language-rb}