Public: anyone can read this; the crew can change it.

Merge scanJsxTag and scanHtmlAttributes into one tag-attribute scanner #17088

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scanJsxTag and scanHtmlAttributes now share one attribute scanner. tsc is clean, the highlight tests pass (87, snapshots unchanged) and scripts/gate.ts passes. I did not run scripts/design-lint.ts or the wider suite; the forge's check runs the full suite on the push.

Notes

opened this

scanJsxTag and scanHtmlAttributes now share one attribute scanner. tsc is clean, the highlight tests pass (87, snapshots unchanged) and scripts/gate.ts passes. I did not run scripts/design-lint.ts or the wider suite; the forge's check runs the full suite on the push.

What moved

  • New scanner: scanTagAttributes(line, from, out, jsx) lives in a new src/web/highlight/tagattrs.ts.
  • Shared parts: whitespace, > and />, =, and quoted strings are handled once.
  • What jsx switches:
    • A { stops the scan so the code scanner can take the expression.
    • Strings honour backslash escapes.
    • Attribute names are an identifier with - and :.
    • Any other character is emitted as punctuation.
    • In HTML mode a name is any run up to a space, = or >.
  • Callers: scanJsxTag in generic.ts still scans the tag name, then calls the shared scanner. scanHtml in html.ts calls it directly. scanHtmlAttributes is deleted.

What I chose not to do

  • I didn't change tokenisation. The two modes are still different, as before, so a merge that changed tokens would be a behaviour change.
  • I added no tests, because no behaviour changed. The existing highlight tests and snapshots cover both paths, and the commit says No test:.

How to try it Open /docs on the preview and look at a code block containing HTML or JSX. It highlights exactly as before.

I didn't run bun scripts/similar.ts, so the pull doesn't list what I reused; the new function is the two merged.

The commit carries the Direction, No door, No test, No look and Try lines the gate asked for.

🤖 Generated with Claude Code

Closes #16802

commented

scanJsxTag and scanHtmlAttributes now share one attribute scanner. tsc is clean, the highlight tests pass (87, snapshots unchanged) and scripts/gate.ts passes. I did not run scripts/design-lint.ts or the wider suite; the forge's check runs the full suite on the push.

What moved

  • New scanner: scanTagAttributes(line, from, out, jsx) lives in a new src/web/highlight/tagattrs.ts.
  • Shared parts: whitespace, > and />, =, and quoted strings are handled once.
  • What jsx switches:
    • A { stops the scan so the code scanner can take the expression.
    • Strings honour backslash escapes.
    • Attribute names are an identifier with - and :.
    • Any other character is emitted as punctuation.
    • In HTML mode a name is any run up to a space, = or >.
  • Callers: scanJsxTag in generic.ts still scans the tag name, then calls the shared scanner. scanHtml in html.ts calls it directly. scanHtmlAttributes is deleted.

What I chose not to do

  • I didn't change tokenisation. The two modes are still different, as before, so a merge that changed tokens would be a behaviour change.
  • I added no tests, because no behaviour changed. The existing highlight tests and snapshots cover both paths, and the commit says No test:.

How to try it Open /docs on the preview and look at a code block containing HTML or JSX. It highlights exactly as before.

I didn't run bun scripts/similar.ts, so the pull doesn't list what I reused; the new function is the two merged.

The commit carries the Direction, No door, No test, No look and Try lines the gate asked for.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs