rich icon indicating copy to clipboard operation
rich copied to clipboard

[BUG] Text interpreted as html tag in markdown gets swallowed.

Open brianm78 opened this issue 2 years ago • 2 comments

  • [X] I've checked docs and closed issues for possible solutions.
  • [X] I can't find my issue in the FAQ.

Describe the bug

If markdown contains code with text that could be interpreted as html (eg. using "<" rather than entity escaping it), the text interpreted as a tag deleted. Eg

>>> md = Markdown("Do something if 0<foo or foo>10")
>>> console.print(md)
Do something if 010

Unless there's actual support for html, I think the html_inline rule should be disabled (or if this is used by something, add an option for markdown without html?). Changing the first line of markdown.Markdown.init to:

parser = MarkdownIt().enable("strikethrough").enable("table").disable("html_inline")

Seems to resolve the issue.

Platform

Click to expand

Running on linux, rich 13.9.4, wezterm terminal.

brianm78 avatar Nov 16 '24 10:11 brianm78

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar Nov 16 '24 11:11 github-actions[bot]

I reproduced this on current main. Markdown-it emits <foo or foo> as a single html_inline token, and Rich currently drops every such token except <kbd>, which explains the 010 output.

Would you approve this focused approach for an AI-assisted PR?

  • preserve the existing <kbd> styling path
  • keep HTML comments hidden
  • render the source text of every other html_inline token instead of discarding it
  • add regression tests for the reported expression, real inline tags, comments, and <kbd>

I also tested the one-line alternative from the report (disable("html_inline")), but it turns <kbd> into literal text and exposes HTML comments. I would keep block-level HTML out of this PR so README <details> blocks retain their current clean terminal rendering.

I have a local Opus-assisted implementation and tests ready, but I’ll wait for your direction before opening anything, per AI_POLICY.md.

davidpavlovschi avatar Jul 28 '26 20:07 davidpavlovschi