Visitar URL original
fix(editor): html parsing support for unquoted attributes by Alexander6060 · Pull Request #1591 · readmeio/markdown · GitHub
Skip to content

fix(editor): html parsing support for unquoted attributes - #1591

Merged
Alexander6060 merged 9 commits into
nextfrom
alex3/rm-16375-support-unquoted-attributes-in-native-html-tags
Nov 10, 2026
Merged

Alexander6060 merged 9 commits into
nextfrom
alex3/rm-16375-support-unquoted-attributes-in-native-html-tags

Conversation

@Alexander6060

@Alexander6060 Alexander6060 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor
🎫 Resolve RM-16375

🎯 What does this PR do?

  • Fixes RM-16375 by supporting unquoted attribute values on native HTML tags in MDXish, such as <a href=https://example.com>.
  • Root cause: micromark's html-text/html-flow end an unquoted value at /, so any URL value failed the tag, which then stayed text and was split by GFM autolinking.
  • Adds html-open-tag.ts, a small inline construct that recognises a single native HTML opening tag with an unquoted value (CommonMark open-tag grammar, but / allowed in values). It runs after the JSX construct and leaves the element body to the inline parser.
  • In the JSX scanner, the brace-attribute gate now only applies to a real />, so a / inside a value (<div data-url=https://…>) no longer blocks the existing block-tag claim. Otherwise the scanner is unchanged from next.
  • Raw tags (pre, script, textarea) stay with html-flow, <input.value=foo>-style prose stays text, and brace-bearing tags like <a title={…} href=…> are still claimed as one JSX element.
  • Adds tokenizer and MDXish/legacy RMDX parity tests, plus an unquoted-html-attributes regression fixture.

Known limitation: = is still invalid in unquoted values (per CommonMark), so <a href=https://example.com?a=b> is not claimed. Quote the value in that case.

🧪 QA tips

  • In an MDXish page, add <a href=https://example.com>Example</a> and confirm it renders as a link to https://example.com.
  • Confirm unquoted class values work on inline and block tags, such as <span class=example> and <div class=example>.
  • Confirm Pass <input.value=foo> to the CLI. stays as visible text.
  • Confirm a heading after <pre class=x> with a backticked </pre> in its body still renders as a heading.
  • Confirm quoted attributes and existing MDX component attributes continue to render normally.

📸 Screenshot

Before After
View
before-view
View
after-view
Edit
before-edit
Edit
after-edit

@coderabbitai

coderabbitai Bot commented Aug 12, 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: d2612737-d4f4-476f-885c-9cf3aa3439bb

📥 Commits

Reviewing files that changed from the base of the PR and between 09cf149 and 64b3ac0.

📒 Files selected for processing (3)
  • __tests__/lib/mdxish/utils/mdxish-component-tag-parser.test.ts
  • __tests__/lib/micromark/mdx-component.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)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/lib/micromark/mdx-component.test.ts
  • lib/micromark/mdx-component/syntax.ts

Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review.


Walkthrough

Lowercase MDX components now support qualifying unquoted HTML attribute values. The tokenizer tracks pending values, validates delimiters and incomplete assignments, handles self-closing tags, and applies flow-specific claim rules. Inline lowercase tags can complete after their opening tags. Tests cover MDXish, legacy RMDX, flow and inline tags, malformed assignments, nesting, formatting, and parsed output.

Merge Risk: ⚪ Minimal · up to 64b3a

This change adds support for valid unquoted HTML attribute values while preserving existing parsing behavior through focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

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.

__tests__/lib/mdxish/utils/mdxish-component-tag-parser.test.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Error while loading rule '@vitest/unbound-method': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.
Parser: /node_modules/@typescript-eslint/parser/dist/index.js
Occurred while linting /tests/lib/mdxish/utils/mdxish-component-tag-parser.test.ts
at throwError (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:40:11)
at getParserServices (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:29:9)
at create (/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unbound-method.js:138:55)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at create (/node_modules/@vitest/eslint-plugin/dist/index.cjs:6355:35)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at createRuleListeners (/node_modules/eslint/lib/linter/linter.js:895:21)
at /node_modules/eslint/lib/linter/linter.js:1066:110
at Array.forEach ()
at runRules (/node_modules/eslint/lib/linter/linter.js:1003:34)

__tests__/lib/micromark/mdx-component.test.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Error while loading rule '@vitest/unbound-method': You have used a rule which requires type information, but don't have parserOptions set to generate type information for this file. See https://tseslint.com/typed-linting for enabling linting with type information.
Parser: /node_modules/@typescript-eslint/parser/dist/index.js
Occurred while linting /tests/lib/micromark/mdx-component.test.ts
at throwError (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:40:11)
at getParserServices (/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:29:9)
at create (/node_modules/@typescript-eslint/eslint-plugin/dist/rules/unbound-method.js:138:55)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at create (/node_modules/@vitest/eslint-plugin/dist/index.cjs:6355:35)
at Object.create (/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:39:20)
at createRuleListeners (/node_modules/eslint/lib/linter/linter.js:895:21)
at /node_modules/eslint/lib/linter/linter.js:1066:110
at Array.forEach ()
at runRules (/node_modules/eslint/lib/linter/linter.js:1003:34)


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
Contributor

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 `@__tests__/lib/mdxish/utils/mdxish-component-tag-parser.test.ts`:
- Around line 456-471: Add direct parser-level assertions for unquoted
attributes that verify both flow and text AST output, rather than only the final
MDXish HAST; apply equivalent coverage to the RMDX engine. Extend the regression
cases for RM-16375 to cover malformed assignments, self-closing tags, whitespace
and line-ending variants, forbidden value delimiters, emphasis variants,
escapes, nesting, blank lines, and formatting differences, naming or labeling
the cases with RM-16375.

In `@lib/micromark/mdx-component/syntax.ts`:
- Around line 96-98: Update the comment near inUnquotedAttr to remove the claim
that CommonMark disallows `/` in unquoted HTML attribute values, while retaining
the accurate explanation about lowercase tags, JSX attribute expressions, and
URL handling.
🪄 Autofix

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: 4c025720-d46d-4c10-9ee9-7ca581ad1e95

📥 Commits

Reviewing files that changed from the base of the PR and between feed88f and 307c29e.

📒 Files selected for processing (2)
  • __tests__/lib/mdxish/utils/mdxish-component-tag-parser.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 Resolved

@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/utils/mdxish-component-tag-parser.test.ts`:
- Around line 458-476: The RM-16375 regression matrix is incomplete for emphasis
variants, escaped opening tags, nesting, blank lines, whitespace, and formatting
differences. In
__tests__/lib/mdxish/utils/mdxish-component-tag-parser.test.ts:458-476, extend
the shared describe.each coverage so every required edge case has explicit
expected output for both MDXish and legacy RMDX. In
__tests__/lib/micromark/mdx-component.test.ts:28-74, add matching assertions for
claim and MDAST behavior in both flow and text contexts, including all required
edge cases.
🪄 Autofix

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: e33c464e-0b5a-458d-95e3-7b891a65d091

📥 Commits

Reviewing files that changed from the base of the PR and between 307c29e and defe477.

📒 Files selected for processing (3)
  • __tests__/lib/mdxish/utils/mdxish-component-tag-parser.test.ts
  • __tests__/lib/micromark/mdx-component.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)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/micromark/mdx-component/syntax.ts

@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.

Approach & testing looks good! But found some regression cases because of the extended rule:

  1. These cases now swallow the <> parts: "Pass <key=value> to the CLI.", "Compare <a = b> and <c = d>."
  2. PascalCase components with =, ", ', or in an unquoted value drop out of the parser (e.g.<Image src=https://example.com/a.png?w=1 align=center />` would now split out the src as an autolink breaking the component
  3. In this example, the 2 lines no longer are wrapped in paragraphs:
<div id=a>

para one

para two

</div>
Screenshot 2026-08-17 at 2 32 29 pm

@Alexander6060

Copy link
Copy Markdown
Contributor Author

Approach & testing looks good! But found some regression cases because of the extended rule:

  1. These cases now swallow the <> parts: "Pass <key=value> to the CLI.", "Compare <a = b> and <c = d>."
  2. PascalCase components with =, ", ', or in an unquoted value drop out of the parser (e.g.<Image src=https://example.com/a.png?w=1 align=center />` would now split out the src as an autolink breaking the component
  3. In this example, the 2 lines no longer are wrapped in paragraphs:
<div id=a>

para one

para two

</div>
Screenshot 2026-08-17 at 2 32 29 pm

Good catch, implemented here

Here are some screenshots:
image
image

@greptile-apps

greptile-apps Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Reviews (5) · Last reviewed commit: "fix: address greptile" · Reviewed by Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 17, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 8, 2026 12:14

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 8, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps
greptile-apps Bot dismissed their stale review November 8, 2026 12:19

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 8, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 8, 2026 12:40

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

Comment thread lib/micromark/mdx-component/syntax.ts Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 8, 2026
@greptile-apps
greptile-apps Bot dismissed their stale review November 8, 2026 12:54

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@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.

Looks good!

@Alexander6060
Alexander6060 merged commit fa57d39 into next Nov 10, 2026
8 checks passed
@Alexander6060
Alexander6060 deleted the alex3/rm-16375-support-unquoted-attributes-in-native-html-tags branch November 10, 2026 00:59
rafegoldberg pushed a commit that referenced this pull request Nov 11, 2026
## Version 16.2.2
### 🛠 Fixes & Updates

* **compatibility:** convert each html comment separately in compiled html blocks ([#1686](#1686)) ([d220c1f](d220c1f))
* **editor:** html parsing support for unquoted attributes ([#1591](#1591)) ([fa57d39](fa57d39))

<!--SKIP CI-->
@rafegoldberg

Copy link
Copy Markdown
Collaborator

This PR was released!

🚀 Changes included in v16.2.2

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