Skip to content

Issues with fenced code blocks in list items #175

@Tachi107

Description

@Tachi107

Hi (again)!

This is a similar issue to #174 (maybe), but as it is more complex I decided to open it as a separate one. Feel free to merge them back :)

The first issue is that if a fenced code block inside a list item contains a black line, the whole code block seems to get ignored. As an example,

- This is an item followed by some RDF
  ```turtle
  @base <http://example.org/> .
  @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
  @prefix foaf: <http://xmlns.com/foaf/0.1/> .
  @prefix rel: <http://www.perceive.net/schemas/relationship/> .
  
  <#green-goblin>
      rel:enemyOf <#spiderman> ;
      a foaf:Person ;    # in the context of the Marvel universe
      foaf:name "Green Goblin" .
  
  <#spiderman>
      rel:enemyOf <#green-goblin> ;
      a foaf:Person ;
      foaf:name "Spiderman", "Человек-паук"@ru .
  ```

gets rendered as:

<ul>
<li><p>This is an item followed by some RDF
```turtle
@base <a href="http://example.org/">http:&#47;&#47;example.org&#47;</a> .
@prefix rdf: <a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#">http:&#47;&#47;www.w3.org&#47;1999&#47;02&#47;22-rdf-syntax-ns#</a> .
@prefix rdfs: <a href="http://www.w3.org/2000/01/rdf-schema#">http:&#47;&#47;www.w3.org&#47;2000&#47;01&#47;rdf-schema#</a> .
@prefix foaf: <a href="http://xmlns.com/foaf/0.1/">http:&#47;&#47;xmlns.com&#47;foaf&#47;0.1&#47;</a> .
@prefix rel: <a href="http://www.perceive.net/schemas/relationship/">http:&#47;&#47;www.perceive.net&#47;schemas&#47;relationship&#47;</a> .</p>
<p>&#60;#green-goblin&#62;
  rel:enemyOf &#60;#spiderman&#62; ;
  a foaf:Person ;    # in the context of the Marvel universe
  foaf:name &#8220;Green Goblin&#8221; .</p>
<p>&#60;#spiderman&#62;
  rel:enemyOf &#60;#green-goblin&#62; ;
  a foaf:Person ;
  foaf:name &#8220;Spiderman&#8221;, &#8220;Человек-паук&#8221;@ru .
```</p></li>
</ul>

Which is... interesting.

The second issue appears when the code block has no blank lines. It gets rendered, but somehow interpreted as an indented code block(?), leading to the info string being part of the code itself. As an example,

- This is an item followed by some RDF
  ```turtle
  <#green-goblin>
      rel:enemyOf <#spiderman> ;
      a foaf:Person ;    # in the context of the Marvel universe
      foaf:name "Green Goblin" .
  ```

gets rendered as:

<ul>
<li>This is an item followed by some RDF
<code>turtle
&#60;#green-goblin&#62;
  rel:enemyOf &#60;#spiderman&#62; ;
  a foaf:Person ;    # in the context of the Marvel universe
  foaf:name "Green Goblin" .
</code></li>
</ul>

Both of these issues go away if a blank line is put in between the list item and the the code block. Nonetheless, md2html (from md4c), renders the two cases correctly (note how the p element is missing; with the blank line, instead, it's present):

<ul>
<li>This is an item followed by some RDF<pre><code class="language-turtle">&lt;#green-goblin&gt;
    rel:enemyOf &lt;#spiderman&gt; ;
    a foaf:Person ;    # in the context of the Marvel universe
    foaf:name &quot;Green Goblin&quot; .
</code></pre>
</li>
</ul>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions