Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Markdown: Fenced code block after list is rendered inside the last list item #8067

@e22m4u

Description

@e22m4u

Gogs version

0.13.3

Git version

git version 2.39.5

Operating system

Debian 12

Database

SQLite 3

Describe the bug

When a Markdown fenced code block follows a list (bulleted or numbered), Gogs renders the code block inside the last list item (<li>), instead of closing the list and rendering the code block as a separate element.

This results the last item gets wrapped in <p> tags and includes the <pre> block, which differs from standard GitHub-flavored Markdown rendering.

To reproduce

Create a markdown file or comment with the following content:

- foo
- bar
- baz

```
some code
```

Current rendering in Gogs (HTML):

<ul>
<li>foo</li>
<li>bar</li>
<li>
  <p>baz</p>
  <pre><code class="hljs armasm"><span class="hljs-symbol">some</span> <span class="hljs-meta">code</span></code></pre>
</li>
</ul>

(The code block is nested inside the last <li>)

Image Image Image

Expected behavior

The list should be closed, and the code block should follow it.

Additional context

I'm not sure, but this may be the reason:

In internal/markup/markdown.go:

extensions |= blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    💊 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions