Skip to content

Fixed code block rendering#126

Open
DesanSilva wants to merge 1 commit into
math2001:masterfrom
DesanSilva:fix-code-block-rendering
Open

Fixed code block rendering#126
DesanSilva wants to merge 1 commit into
math2001:masterfrom
DesanSilva:fix-code-block-rendering

Conversation

@DesanSilva
Copy link
Copy Markdown

Previously, code blocks in the Markdown preview were sometimes corrupted due to global string replacements.

Changes:

  • BeautifulSoup HTML parser is used to locate only the <code> elements inside <pre> blocks.

  • For each <pre><code> block, the package inspects its children:

    • If the <code> element contains only a single text node it rewrites or escapes the text as needed.
    • If the <code> element contains nested HTML (from Pygments), it leaves the content untouched to preserve syntax coloring
  • This approach ensures that any HTML generated by Pygments is not corrupted or escaped, so syntax highlighting remains intact

  • Add the Pygments CSS stylesheet to the current stylesheet to ensure color highlighting is preserved

Previous:

test1

Fixed:

test2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant