Skip to content

[patch] Draw HTML entities in Markdown as their characters, not a type name - #605

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/479-markdown-html-entities
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/479-markdown-html-entities

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #479

What changed

ImGui.Markdown/Rendering/InlineBuilder.cs:

  • New HtmlEntityInline case. It emits entity.Transcoded with the current emphasis role and link URL, so Tom & Jerry draws Tom & Jerry.
  • default: no longer calls inline.ToString(). Markdig inlines don't override ToString(), so that branch could only ever draw a CLR type name. It now drops the unknown leaf. Container inlines are still walked by the existing ContainerInline case above it.

Tests

Three new tests in tests/ImGui.Markdown.Tests/InlineBuilderTests.cs:

  • a named entity (&)
  • a numeric entity (©)
  • an entity inside bold (**a < b**), which keeps the bold role and draws no Markdig type name

All three fail with the InlineBuilder.cs change reverted. The full ImGui.Markdown.Tests project passes: 42/42.

🤖 Generated with Claude Code

https://claude.ai/code/session_0176ydtLncnCjKchHXEPCh7H


Generated by Claude Code

…e name

InlineBuilder had no case for Markdig's HtmlEntityInline, so "&", "©"
and every other entity fell into the default branch, which emitted
inline.ToString() and drew "Markdig.Syntax.Inlines.HtmlEntityInline". Entities
now emit their transcoded text with the current emphasis and link, and the
default branch drops an unknown leaf instead of drawing its type name.

Fixes #479

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0176ydtLncnCjKchHXEPCh7H
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

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.

Markdown renders HTML entities as the literal text "Markdig.Syntax.Inlines.HtmlEntityInline"

2 participants