Skip to content

fix: make tag stripping attribute-aware - #68

Merged
rachfop merged 1 commit into
rachfop:mainfrom
deka0106:deka0106/fix-jsx-attr-stripping
Sep 1, 2026
Merged

rachfop merged 1 commit into
rachfop:mainfrom
deka0106:deka0106/fix-jsx-attr-stripping

Conversation

@deka0106

@deka0106 deka0106 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Both strip regexes in cleanMarkdownContent (HTML tags and PascalCase JSX components), and the three JSX-usage regexes in resolvePartialImports, scan tag attributes with [^>]*. But > can legally appear inside an attribute value, so the scan terminates early and the rest of the tag leaks into the generated markdown as prose:

Questions? <a href="#" onClick={() => openChat()}>Contact us</a> anytime.

Expected: Questions? Contact us anytime.
Actual: Questions? openChat()}>Contact us anytime.

title="a > b"-style quoted values trigger the same failure.

The PascalCase JSX strip is new in 0.5.0, so component tags leak on 0.5.0/0.5.1. The HTML-tag strip has carried the same [^>]* since at least 0.4.0, so the <a onClick={...}> example leaks there too.

Fix

A shared TAG_ATTRS regex fragment replaces [^>]* at all five sites: attribute values may be double-quoted, single-quoted, a JSX brace expression, or bare. Brace expressions match one nesting level; a deeper expression makes the whole tag fail to match and stay intact in the output — a visible leftover rather than silent corruption (covered by a test).

This deliberately does not change what gets stripped — only where a tag ends. The related question of content carried in props (#64) is left untouched here; I have a follow-up ready pending the direction discussion there.

Tests

New tests/test-jsx-attr-stripping.js (7 cases, 10 assertions), registered in test:unit: arrow functions in HTML and JSX attributes, > inside quoted values, multiline tags, the brace-nesting ceiling, code-fence preservation, and the resolvePartialImports path. Full suite passes.

The HTML/JSX strip regexes in cleanMarkdownContent (and the JSX-usage
regexes in resolvePartialImports) scanned attributes with [^>]*, which
terminates early on the '>' inside JSX expression attributes such as
onClick={() => ...} or quoted values like title="a > b", leaking the
rest of the tag into the output as prose. Replace the scan with a shared
attribute-aware pattern (quoted / brace-expression / bare values; braces
matched to one nesting level, failing safe to leaving the tag intact).
@deka0106
deka0106 marked this pull request as ready for review August 18, 2026 06:34
@rachfop
rachfop merged commit b703e7f into rachfop:main Sep 1, 2026
rachfop added a commit that referenced this pull request Sep 1, 2026
Several 0.5.x bugs (#63, #64/#68, #67, #69) shipped because no CI
ever ran against PRs. This runs the full unit + integration suites
on Node 18/20/22 for every pull request and push to main.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
rachfop added a commit that referenced this pull request Sep 1, 2026
…ndlier processMarkdownFile signature

Second pass over the full source (all 11 files read end to end):

- content.ts: the TabItem label emitter used a [^>]* scan, so a quoted
  label containing '>' (label="A > B") cut the tag short and leaked the
  remainder as prose — the same bug class #68 fixed for PascalCase tags.
  The matcher is now attribute-aware via TAG_ATTRS.
- content.ts: createMarkdownContent blockquotes every line of a
  multi-line description; previously only the first line got '>', leaving
  later lines as prose under the heading.
- processor.ts: processMarkdownFile now takes an optional options object
  as its final argument. The legacy positional tail still works
  (detected by shape), so existing callers and tests are unaffected;
  the internal caller uses the object form.

Adds tests/test-tabitem-attr-edge-cases.js (11 assertions), registered
in test:unit. Full unit + integration suites pass.
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