Skip to content

fix(mdxish): ensure inline html tags with expressions stay inline#1528

Merged
kevinports merged 4 commits into
nextfrom
dimas/cx-3624-incorrect-icon-rendering-in-mdx-ish
Jun 30, 2026
Merged

fix(mdxish): ensure inline html tags with expressions stay inline#1528
kevinports merged 4 commits into
nextfrom
dimas/cx-3624-incorrect-icon-rendering-in-mdx-ish

Conversation

@eaglethrost

@eaglethrost eaglethrost commented Jun 30, 2026

Copy link
Copy Markdown
Contributor
🎫 Resolve CX-3624

🎯 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:

Screenshot 2026-06-30 at 2 04 11 pm

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:

<i ...></i>
<p><a href="https://x.com">3-D Secure</a></p>

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

  • Paste the reported snippet into an MDXish doc — icon and link render on the same line.
  • npx vitest run __tests__/lib/mdxish/mdxish.test.ts __tests__/lib/mdxish/mdxishAstProcessor.test.ts

More snippets to paste — inline tags should stay on one line, block tags should remain their own block:

<!-- self-closing icon + link → one line -->
<i class="fa fa-check" style={{ color: "red" }}/> <a href="https://x.com">link</a>
<!-- inline tag + trailing text → one line -->
<span style={{ color: "red" }}>Status</span>: all good
<!-- inside a list item → icon + link stay inline -->
- <i style={{ color: "red" }}></i> <a href="https://x.com">link</a>
<!-- block tag stays its own block, trailing text becomes a separate paragraph -->
<div style={{ color: "red" }}>box</div> trailing
<!-- standalone icon (nothing trailing) stays its own block -->
<i class="fa fa-check" style={{ color: "red" }}></i>

📸 Screenshot or Loom

Now content after icon stays inline:

Screenshot 2026-06-30 at 2 19 05 pm

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 13031319-c9e5-4462-a503-614a1eb5cb78

📥 Commits

Reviewing files that changed from the base of the PR and between 9010da4 and a7b1af7.

📒 Files selected for processing (1)
  • __tests__/lib/mdxish/mdxish.test.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)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/lib/mdxish/mdxish.test.ts

Walkthrough

The tokenizer adds a sawLineEnding flag and a new inline-candidate path after closing lowercase tags that are not flow HTML tags. The inline path only accepts whitespace, line endings, or end-of-input after the close tag. Tests update JSX trailing-content positions and add coverage for inline component attributes, lowercase HTML tag inline behavior, standalone inline-tag output, and block HTML tags followed by trailing text.


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3355f7c and 5511da8.

📒 Files selected for processing (3)
  • __tests__/lib/mdxish/mdxish.test.ts
  • __tests__/lib/mdxish/mdxishAstProcessor.test.ts
  • lib/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)

Comment thread lib/micromark/mdx-component/syntax.ts Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 30, 2026
@eaglethrost eaglethrost changed the title fix(mdxish): keep inline icon on the same line as trailing content (CX-3624) fix(mdxish): ensure inline html tags stay inline Jun 30, 2026
@eaglethrost eaglethrost changed the title fix(mdxish): ensure inline html tags stay inline fix(mdxish): ensure inline html tags with expressions stay inline Jun 30, 2026
@kevinports kevinports merged commit f32f4e9 into next Jun 30, 2026
8 checks passed
@kevinports kevinports deleted the dimas/cx-3624-incorrect-icon-rendering-in-mdx-ish branch June 30, 2026 16:38
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.

2 participants