Skip to content

Another case of fenced code block that should be handled #1601

@LLyaudet

Description

@LLyaudet

Hello,

I saw the issue #53.

But nothing can be added to it since 2015.

And I thought that the following issue on gi-docgen would be of interest as a new test case:

https://gitlab.gnome.org/GNOME/gi-docgen/-/work_items/219

Below is the important part.

It is not mine, but a very useful comment by balooii.

Thanks, best regards, Laurent Lyaudet

Comment by balooii:

This is what a regular code block returns:

import markdown

src = """\
Here comes a regular code block
```c
int x = 42;
```
"""
result = markdown.markdown(src, extensions=["fenced_code"])
print(result)
<p>Here comes a regular code block</p>
<pre><code class="language-c">int x = 42;
</code></pre>
<dl>

Now let's try your example: a code block within a definition list

import markdown

src = """\
`MY_CONSTANT`
:   Some description

    Here comes a code block within a definition
    ```c
    int x = 42;
    ```
"""

result = markdown.markdown(src, extensions=["def_list", "fenced_code"])
print(result)
<dl>
<dt><code>MY_CONSTANT</code></dt>
<dd>
<p>Some description</p>
<p>Here comes a code block within a definition
<code>c
int x = 42;</code></p>
</dd>
</dl>

Yeah, that looks not right. I would have expected this instead:

<dl>
<dt><code>MY_CONSTANT</code></dt>
<dd>
<p>Some description</p>
<p>Here comes a code block within a definition</p>
<pre><code class="language-c">int x = 42;
</code></pre>
</dd>
</dl>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions