4

I want to fully disable indented code blocks for Kramdown as used in Jekyll. I am used to using the backtick method. And my primary reason for disabling indented code blocks is that I use a fair bit of html in a typical post.md, I have provided an example of that below:

<div class="notice--danger" markdown="1">
  <details>
    <summary>
      <svg class="icon"><use xlink:href="#icon-youtube-square"></use></svg>
    </summary>
    <div markdown="1">
      <figure>
        <iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID?playsinline=1" frameborder="0"></iframe>
      </figure>
    </div>
  </details>
</div>

The issue is that with indented code blocks enabled, this gets caught up as a code block. There is an existing workaround, which is to just not indent any of the above code, in which case this will render as expected. But I want to format the code properly for a number of reasons (best practice, and mainly, so I can collapse the code in an editor like atom, vim, etc.)

Is there a way to do this. I found two other posts, saying there might be a way to cut out the indentated code blocks feature of kramdown and side load it into my Jekyll. But those posts just state that it may be possible.

I would like to do this if possible. Also, here is the kramdown specific parts from my config.yml:

markdown                 : kramdown
kramdown:
  toc_levels             : 1..3
  input                  : GFM
  hard_wrap              : false
  auto_ids               : true
  entity_output          : as_char
  smart_quotes           : lsquo,rsquo,ldquo,rdquo
  enable_coderay         : false

Thank you.

ercfre
  • 183
  • 9

2 Answers2

3

You can disable kramdown parsing with a markdown tag attribute.

<div markdown="0">
   <p>No kramdown parsing here</p>
</div>

Must read : https://kramdown.gettalong.org/syntax.html#html-blocks

David Jacquel
  • 51,670
  • 6
  • 121
  • 147
0

From Kramdown's author:

Indented code blocks are part of the Markdown syntax, so the kramdown and GFM parsers are using them. If you don't want them, the easiest way would be to create a custom parser based on the kramdown (or GFM) parser and remove the indented code block parsing routine. Have a look at https://github.com/gettalong/kramdown/blob/master/lib/kramdown/parser/markdown.rb to see how to create such a custom parser.

Source: Ability to disable indented code blocks

marcanuy
  • 23,118
  • 9
  • 64
  • 113