Possible bug with not parsing "<", "&", ">" correctly in code block nested inside of HTML elements

Hi - I’m working with Github Pages and Jekyll and I’ve run into an issue with the characters “<”, “>”, and “&” showing as HTML entities inside a code block when that code block is nested as follows:

<details>
  <div>
    ```
      code with > < & here
    ```
  </div>
</details>

This particular case uses <details>, but the shape seems to be what matters, as I ave also reproduced this issue with a <div> as the outermost container.

In my _config.yml I have the following settings on:

markdown: kramdown
kramdown:
  parse_block_html: true
  parse_span_html: true
  syntax_highlighter_opts:
    block:
      line_numbers: true

In my markdown file I have the following block:

<details>
<summary markdown="0">
<h4>Test Example Code Here</h4>
</summary>

<div markdown="0">
Check out my code block below:

```bash
# We are in a code block
export VARIABLE=xxx
echo "VARIABLE" > test.txt

Less than: >
Greater than: <
Ampersand: &
```
</div>
</details>

And in my index.html I am using:
{{ section.content | markdownify }}

This produces the following:
180854031-6636a778-fd12-486e-914d-47887b368c82

And to fix it, I have to replace the HTML entities before markdownify is used:

{{ section.content | replace: "&amp;", "&" | replace: "&lt;", "<" | replace: "&gt;", ">" | markdownify }}

Is this a bug? Is anyone aware of another way to do this?

Wouldn’t turning on markdown in the div work, and not require calling markdownify? I.e. (note 1 instead of 0):

<div markdown="1">
Check out my code block below:
...
</div>

Thanks for the reply! I have tried this, and it renders as the following:

I believe this is due to the kramdown parse_block_html setting being set to true.

With parse_block_html set to true, you wouldn’t need markdown=1 or markdownify, since the content of all blocks (DIVs, etc) will be treated as Markdown.

I tried reproducing the problem locally with a new Jekyll 3.9 site, but got the expected results:

Maybe you could post the generated HTML, which might have a clue to what is going wrong?

The HTML on the page generates as the following:

I think the issue might be that the semicolon is being put in a span, possibly as a side effect of it trying to do syntax highlighting in the code block?