gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 274 forks source link

Code Blocks Eat Multiline YAML #767

Closed theory closed 2 years ago

theory commented 2 years ago

I have this something like this in a Jekyll post:

``` yaml
agent-inject-template-my_secret.json: |
{{ with secret "dev/testsecret" }}{{ .Data.data | toJSON }}{{ end }}
```

The second line does not display. The entirety of the resulting HTML is:

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="s">agent-inject-template-my_secret.json</span><span class="pi">:</span> <span class="pi">|</span>

</code></pre></div></div>

I have tried removing removing the pipe, changing it to !-, unindenting the second line, none of which work. I can get the line to appear if I put a backslash before each {, but then those backslashes render in the HTML, too.

Rendered by GitHub Pages' Jekyll support.

gettalong commented 2 years ago

When I run your input through the kramdown binary using kramdown -x parser-gfm -i GFM I get the following output:

<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">agent-inject-template-my_secret.json</span><span class="pi">:</span> <span class="pi">|</span>
<span class="err">{</span><span class="s">{ with secret "dev/testsecret" }}{{ .Data.data | toJSON }}{{ end }}</span>
</code></pre></div></div>

which seems right.

So my guess is this has something to do with Jekyll itself because the {{...}} parts look like Liquid tags, so please ask there.

theory commented 2 years ago

Oh Liquid tags, of course, I forget that Jekyll executes them in content files. Apologies for the noise, appreciate the pointer.

theory commented 2 years ago

For anyone running into this in the future, the solution is, sadly, to add raw/endear liquid tags to tell Jekyll to ignore your liquid tags:

``` yaml
agent-inject-template-my_secret.json: |
     {% raw %}{{ with secret "dev/testsecret" }}{{ .Data.data | toJSON }}{{ end }}{ %endraw %}
```