Skip to content

fix(inline): nested strong inside emphasis correctly parses - #3

Open
SyahrulBhudiF wants to merge 3 commits into
TanStack:mainfrom
SyahrulBhudiF:fix/nested-strong-emphasis
Open

fix(inline): nested strong inside emphasis correctly parses#3
SyahrulBhudiF wants to merge 3 commits into
TanStack:mainfrom
SyahrulBhudiF:fix/nested-strong-emphasis

Conversation

@SyahrulBhudiF

@SyahrulBhudiF SyahrulBhudiF commented Jul 28, 2026

Copy link
Copy Markdown

Description

Fixes emphasis containing a bold word (e.g. *a **b** c*) rendering as separate <em> runs instead of nested <em><strong>.

Root cause

findDelimiter for single */_ matched the first occurrence greedily, including * characters that start a ** strong delimiter. The fix
skips delimiter positions that are part of a longer ** run with a matching close, so the single-delimiter scan passes over inner strong spans.

Changes

  • src/inline.ts — in findDelimiter, when scanning for a single */_ closer, skip positions where the character starts a **/__ pair
    that has a matching close
  • Consolidated duplicate isWhitespace/isDelimiterWhitespace helpers (same byte count)
  • Added test cases for *a **b** c*, *see **the docs** here*, _italic __bold__ tail_, *outer **inner***
  • Refreshed bundle size report

Bundle impact

Entry Δ gzip
Parser –4 B
HTML renderer +17 B
React adapter +25 B
Octane adapter +22 B
Pluggable +23 B

All well under 0.4% increase. CommonMark baseline preserved (no regressions).

Fixes #2

Summary by CodeRabbit

  • Bug Fixes

    • Improved inline delimiter handling for tilde cases, including single-character delimiters, to prevent premature termination.
    • Strengthened Markdown “strong inside emphasis” rendering to ensure correct nesting and escaping.
  • Tests

    • Added a Markdown rendering test covering nested emphasis structure across both HTML and React output.
    • Updated bundle-size budget thresholds to match current generated sizes.
  • Documentation

    • Regenerated bundle-size reports and refreshed generation timestamps/size metrics.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 09d9d15a-63f2-4977-8c72-65a97a8084be

📥 Commits

Reviewing files that changed from the base of the PR and between dc05240 and cb1e50d.

📒 Files selected for processing (5)
  • reports/sizes.json
  • reports/sizes.md
  • src/inline.ts
  • tests/bundle-size.test.ts
  • tests/markdown.test.tsx
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/bundle-size.test.ts
  • reports/sizes.json
  • reports/sizes.md
  • src/inline.ts
  • tests/markdown.test.tsx

📝 Walkthrough

Walkthrough

Inline delimiter scanning was updated for nested emphasis and strong spans, with regression coverage for HTML and React rendering. Bundle size budgets and generated size reports were refreshed with new metrics and timestamps.

Changes

Nested emphasis parsing

Layer / File(s) Summary
Inline delimiter handling
src/inline.ts
Single-character delimiter scans skip matching delimiter runs, tilde parsing uses delimiter-specific whitespace checks, and the obsolete whitespace helper is removed.
Nested emphasis regression coverage
tests/markdown.test.tsx
Adds assertions for nested <em><strong> output from HTML rendering and React static markup.
Bundle size baselines and reports
tests/bundle-size.test.ts, reports/sizes.json, reports/sizes.md
Raises selected gzip budgets and refreshes recorded bundle metrics and generation timestamps.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main parser fix.
Linked Issues check ✅ Passed The parser fix and regression tests address the nested emphasis/strong cases from issue #2 across renderers.
Out of Scope Changes check ✅ Passed The bundle size report refresh and test threshold updates are part of the stated PR objectives, so no unrelated changes stand out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

🤖 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 `@src/inline.ts`:
- Around line 364-370: Update the strong-close lookahead in the inline parsing
logic around the delimiter scan to use the existing delimiter-aware scanning and
eligibility rules instead of raw value.indexOf(delimiter + delimiter, ...).
Ensure escaped or malformed delimiter runs are not treated as matching closes,
and add a regression test covering the escaped-star example.

In `@tests/bundle-size.test.ts`:
- Around line 19-22: Update the React bundle-size assertion in the test to allow
the refreshed recorded size of 6,706 bytes by setting its toBeLessThan threshold
to at least 6,707; leave the other html, octane, and pluggable budgets
unchanged.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a3ac8af1-0d04-4db8-a090-260a8e245ae9

📥 Commits

Reviewing files that changed from the base of the PR and between b3ca355 and dc05240.

📒 Files selected for processing (5)
  • reports/sizes.json
  • reports/sizes.md
  • src/inline.ts
  • tests/bundle-size.test.ts
  • tests/markdown.test.tsx

Comment thread src/inline.ts
Comment thread tests/bundle-size.test.ts
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.

Emphasis containing a bold word splits into separate <em> runs instead of nesting <strong>

1 participant