Skip to content

fix(mdxish): parse indented markdown inside plain html wrappers - #1545

Merged
kevinports merged 4 commits into
nextfrom
fix/parse-md-children
Jul 14, 2026
Merged

kevinports merged 4 commits into
nextfrom
fix/parse-md-children

Conversation

@kevinports

@kevinports kevinports commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

(See slack thread)

Markdown indented for readability right after a plain HTML opening tag (<div> … ## Heading) rendered as literal text. CommonMark HTML blocks only end at a blank line, so the content got swallowed. Same problem inside component bodies such as <Tabs>, where leftover indentation could also turn paragraphs into code blocks.

🎯 What does this PR do?

  • terminateHtmlFlowBlocks now also terminates 1–3 column shapes, but only after a lone opening tag followed by markdown. Column-0 behavior is unchanged, 4+ columns is still left alone (indented-code territory, fix(mdxish): tone down empty line addition preprocessing after html blocks #1344), and open <pre>/<table> payloads stay byte-exact.
  • Component bodies dedent fully (shallowest line = column 0) and re-run terminateHtmlFlowBlocks afterward, since dedenting invalidates the top-level pass's decisions.

Covered by unit tests, AST tests, and a new fixture rendered through both engines to ensure mdx/mdxish parity (headings, links, lists, quotes, tables in HTML wrappers).

Surfaced along the way, not fixed here: lists/blockquotes directly after a plain HTML opener don't parse in mdxish (pre-existing tokenizer limitation) — follow-up material.

🧪 QA tips

  • Run locally in the dev playground. Everything should render as real markdown inside its wrapper — no literal ##/> text, no stray code blocks.

  • Paste fixture sections into an mdxish page and the output should match.

  • [ ]

📸 Screenshot or Loom

@kevinports

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@kevinports
kevinports requested a review from eaglethrost July 13, 2026 22:03
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

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: b1e3a7b5-3bb7-4a7e-9238-6f717e1af90a

📥 Commits

Reviewing files that changed from the base of the PR and between 47ddee8 and 6ad2e89.

📒 Files selected for processing (1)
  • __tests__/lib/mdxish/markdown-inside-indented-html.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/markdown-inside-indented-html.test.ts

Walkthrough

The change refines HTML-flow block termination using indentation, standalone opening-tag, and raw-content depth rules. MDXish component parsing now fully deindents deeper bodies and applies the termination helper before Markdown parsing. New fixtures and tests cover Markdown inside nested HTML wrappers, indented content, lists, links, blockquotes, tables, inline formatting, raw-content elements, and equivalent rendering through MDX and MDXish.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
__tests__/lib/mdxish/markdown-inside-indented-html.test.ts (1)

91-102: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Nit: class vs className inconsistent with the rest of this file.

Every other element here uses className; this test uses plain class. Doesn't affect the assertions, just a style inconsistency.

🤖 Prompt for 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.

In `@__tests__/lib/mdxish/markdown-inside-indented-html.test.ts` around lines 91 -
102, Update the HTML anchor attributes in the test case around the deeply
indented wrapper to use className consistently with the other elements in the
file, while preserving the existing assertions and test behavior.
🤖 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.

Nitpick comments:
In `@__tests__/lib/mdxish/markdown-inside-indented-html.test.ts`:
- Around line 91-102: Update the HTML anchor attributes in the test case around
the deeply indented wrapper to use className consistently with the other
elements in the file, while preserving the existing assertions and test
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e5fb750-a164-4372-88b9-a801a8b334df

📥 Commits

Reviewing files that changed from the base of the PR and between 878ef89 and 95e2340.

📒 Files selected for processing (7)
  • __tests__/fixtures/markdown-in-html-tests.mdx
  • __tests__/lib/mdxish/markdown-inside-indented-html.test.ts
  • __tests__/lib/render-mdxish/markdown-in-html.test.tsx
  • __tests__/transformers/terminate-html-flow-blocks.test.ts
  • example/docs.ts
  • processor/transform/mdxish/components/mdx-blocks.ts
  • processor/transform/mdxish/terminate-html-flow-blocks.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)

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 13, 2026
eaglethrost
eaglethrost previously approved these changes Jul 14, 2026

@eaglethrost eaglethrost left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cleaned up the testing file, but did further testing & this looks good on solving the indentation issue on components! It definitely feels cleaner overall, but want to also note we're still limited by common mark's 4 indent -> code rule, so on normal docs they still get converted to code / not parsed.

E.g. this would still render different from MDX:

<div className="outer-wrapper" data-testid="nested-wrappers">
  <div className="inner-wrapper">
    ##### Markdown After A Nested Opening Tag
  </div>
</div>

But I think for these cases we need a bigger & different refactor from this! We can get this out first

@eaglethrost
eaglethrost dismissed stale reviews from coderabbitai[bot] and themself via a2a0861 July 14, 2026 03:25
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@__tests__/lib/mdxish/markdown-inside-indented-html.test.ts`:
- Around line 120-130: Extend the test case “does not treat deeply indented
content as code when nested under unindented HTML” to assert that the
account-balance text is preserved in the parsed AST or rendered HTML, in
addition to verifying no code element exists. Use the existing AST/query helpers
and the distinctive “Account balances” text.
🪄 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: d1788790-9f05-486f-9b7d-bf91a20b2d0b

📥 Commits

Reviewing files that changed from the base of the PR and between a2a0861 and 47ddee8.

📒 Files selected for processing (2)
  • __tests__/lib/mdxish/markdown-inside-indented-html.test.ts
  • processor/transform/mdxish/components/mdx-blocks.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)
  • processor/transform/mdxish/components/mdx-blocks.ts

@eaglethrost
eaglethrost self-requested a review July 14, 2026 08:42
@kevinports
kevinports merged commit 522275a into next Jul 14, 2026
8 checks passed
@kevinports
kevinports deleted the fix/parse-md-children branch July 14, 2026 15:49
rafegoldberg pushed a commit that referenced this pull request Jul 14, 2026
## Version 14.11.5
### 🛠 Fixes & Updates

* **mdxishTags:** capture components inside HTML blocks  ([#1547](#1547)) ([06d84d5](06d84d5))
* **mdxish:** parse indented markdown inside plain html wrappers ([#1545](#1545)) ([522275a](522275a)), closes [#1344](#1344)
* **mdxish:** stop escaping intraword underscores on serialization ([#1546](#1546)) ([571f839](571f839))

<!--SKIP CI-->
@rafegoldberg

Copy link
Copy Markdown
Collaborator

This PR was released!

🚀 Changes included in v14.11.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants