fix(mdxish): ensure inline html tags with expressions stay inline#1528
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe tokenizer adds a Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/micromark/mdx-component/syntax.ts`:
- Line 5: The inline-candidate guard in syntax.ts only uses htmlBlockNames, so
raw-content tags like pre, script, style, and textarea can still fall back to
inline handling when they have JSX-style attrs. Update the afterClose check to
also include htmlRawNames alongside htmlBlockNames, and make sure the import at
the top of syntax.ts brings in htmlRawNames so these tags always stay in flow
mode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 54b85ea9-da2e-4bbe-bee0-9f553e67d408
📒 Files selected for processing (3)
__tests__/lib/mdxish/mdxish.test.ts__tests__/lib/mdxish/mdxishAstProcessor.test.tslib/micromark/mdx-component/syntax.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
readmeio/ai(manual)readmeio/gitto(manual)readmeio/markdown(manual)readmeio/readme(manual)
🎯 What does this PR do?
In MDXish, there is a reported bug where the text after an icon tag
<i>does not render in the same line as it, the icon is at the start of the line (if it's inside a line, it would be correctly inline)<i class="fa fa-check fa-lg" style={{ color: "#ff9f3a" }}></i> <a href="https://x.com">3-D Secure</a>MDX vs MDXish:
The issue is with the MDX tokenizer. Currently it treats a line-leading lowercase tag carrying a
{…}JSX attribute (e.g.style={{…}}) as a block, and captures the rest of the line as separate block siblings, so the icon becomes its own block:In reality, certain lowercase HTML tags such as icon are always inline, so the tokenizer should have been aware of that. The fix makes a single-line non-block lowercase tag with inline content trailing its end tag fall through to inline parsing (mirrors CommonMark html-flow type-7). We also distinct block-level HTML tags so it stays flow (excluded via
htmlBlockNames), so a<div>isn't invalidly nested in a<p>:🧪 QA tips
npx vitest run __tests__/lib/mdxish/mdxish.test.ts __tests__/lib/mdxish/mdxishAstProcessor.test.tsMore snippets to paste — inline tags should stay on one line, block tags should remain their own block:
📸 Screenshot or Loom
Now content after icon stays inline: