Skip to content

Markdown rendering changes - stripping classes? #9054

Closed
@cipherboy

Description

@cipherboy
  • Gitea version (or commit ref): 1.10.0
  • Git version: 2.20.1
  • Pandoc version: 2.5-2 (dpkg)
  • KaTeX version: 0.11.0
  • Operating system: Ubuntu 19.10
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
  • Log gist:

Nothing relevant in logs.

Description

I've installed a custom markdown rendering based on pandoc as such:

[markup.markdown]
ENABLED         = true
FILE_EXTENSIONS = .md,.markdown
RENDER_COMMAND  = pandoc -f markdown -t html --katex

This lets me add a custom header and render LaTeX in Markdown with KaTeX:

    <link rel="stylesheet" href="https://git.cipherboy.com/internal-custom/static/katex/katex.min.css" integrity="sha384-BdGj8xC2eZkQaxoQ8nSLefg4AV4/AwB3Fj+8SUSo7pnKP6Eoy18liIKTPn9oBYNG" crossorigin="anonymous">

    <!-- The loading of KaTeX is deferred to speed up page rendering -->
    <script defer src="https://git.cipherboy.com/internal-custom/static/katex/katex.min.js" integrity="sha384-JiKN5O8x9Hhs/UE5cT5AAJqieYlOZbGT3CHws/y97o3ty4R7/O5poG9F3JoiOYw1" crossorigin="anonymous"></script>

    <!-- To automatically render math in text elements, include the auto-render extension: -->
    <script defer src="https://git.cipherboy.com/internal-custom/static/katex/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script>

Sometime recently (I remember it working early in 1.9.x series) this got broken. Looking at the source, it looks like classes on elements started getting stripped by gitea after pandoc got done rendering it.

For example, the browser gets sent source like:

...
<li><span>\{..., -16, -11, -6, -1, 4, 9, 14, ...\}</span></li>
<li><span>\{...,-7, -4, -1, 2, 5, 8, ...\}</span></li>
<li><span>\{-2, -1, 0, 1, 2, 3, 4, 5, 6\}</span></li>
<li><span>\{-1, 0, 1, 2, 3, 4, 5, 6, 7\}</span></li>
<li><span>\{-\sqrt{3}, \sqrt{3} \}</span></li>
...

However, running the pandoc command above on the server (on the same source file) gives:

...
<li><span class="math inline">\{..., -16, -11, -6, -1, 4, 9, 14, ...\}</span></li>
<li><span class="math inline">\{...,-7, -4, -1, 2, 5, 8, ...\}</span></li>
<li><span class="math inline">\{-2, -1, 0, 1, 2, 3, 4, 5, 6\}</span></li>
<li><span class="math inline">\{-1, 0, 1, 2, 3, 4, 5, 6, 7\}</span></li>
<li><span class="math inline">\{-\sqrt{3}, \sqrt{3} \}</span></li>
...

Which makes me think gitea changed something recently. This results in KaTeX not rendering anything, which means my Math+Markdown files are now broken.

Did something change? Perhaps more markdown sanitation was added recently?

Screenshots

Screenshot from 2019-11-17 08-44-23

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