Skip to content

Class stripping removes language-* from code blocks, losing the code language #34

Closed

Description

@trsdn

Problem

LoopHtmlConverter.Convert strips every class attribute from the rendered HTML:

// Remove CSS classes that Markdig adds
html = System.Text.RegularExpressions.Regex.Replace(html, @"\s*class=""[^""]*""", "");

Markdig renders a fenced block with its language as <code class="language-cs">. The regex deletes that, so the language is gone from the output HTML.

Repro

Input Markdown:

```cs
var x = 1;
```

Output HTML:

<pre><code>var x = 1;
</code></pre>

Round-tripping back through HtmlToMarkdownConverter therefore yields an unlabelled fence — the cs hint is lost permanently.

Impact

  • Code language is dropped on every Markdown → Rich Text conversion, so Loop cannot syntax-highlight and the information cannot be recovered.
  • The regex is broader than its stated intent ("classes that Markdig adds") — it also strips classes from any raw HTML the user deliberately wrote in their Markdown.

Suggested fix

Preserve language-* classes and strip only what Loop actually chokes on. Either:

Found while verifying #16.

Activity

  1. added a commit that references this issue on Aug 28, 2026
    f8af640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions