Skip to content

[Markdown] vendor html-text#18515

Merged
fisker merged 9 commits intoprettier:remark-11-markdownfrom
seiyab:remark-11-markdown-vendor-html-text
Dec 26, 2025
Merged

[Markdown] vendor html-text#18515
fisker merged 9 commits intoprettier:remark-11-markdownfrom
seiyab:remark-11-markdown-vendor-html-text

Conversation

@seiyab
Copy link
Copy Markdown
Collaborator

@seiyab seiyab commented Dec 22, 2025

Description

This PR tackles #18277 (comment) and #18498 (comment).

Status: Just a PoC. I'm not sure enough that it's worth vendoring the tokenizer. I'll also submit a PR to micromark.

Status:

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Dec 22, 2025

Open in StackBlitz

yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/@prettier/[email protected]
yarn add https://pkg.pr.new/[email protected]

commit: d1c5fe8

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 22, 2025

Deploy Preview for prettier ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d1c5fe8
🔍 Latest deploy log https://app.netlify.com/projects/prettier/deploys/694a6064b1424300081abf46
😎 Deploy Preview https://deploy-preview-18515--prettier.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@seiyab seiyab marked this pull request as ready for review December 23, 2025 03:56
@seiyab seiyab marked this pull request as draft December 23, 2025 03:56
@seiyab seiyab marked this pull request as ready for review December 23, 2025 04:02
@seiyab seiyab marked this pull request as draft December 23, 2025 04:56
@seiyab seiyab force-pushed the remark-11-markdown-vendor-html-text branch from 9af30ab to d1c5fe8 Compare December 23, 2025 09:26
node.type === "html" &&
previous.type === "html" &&
previous.position.end.line + 1 === node.position.start.line;
const isBlockHtmlWithoutBlankLineBetweenPrevParagraph =
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is equivalent to isInlineHtmlInterruptingParagraph. I updated the name to match current parser behavior. I moved it up because it's similar to isBlockHtmlWithoutBlankLineBetweenPrevHtml above.

@seiyab seiyab marked this pull request as ready for review December 23, 2025 10:45
const isBlockHtmlWithoutBlankLineBetweenPrevParagraph =
options.parser !== "mdx" &&
node.type === "html" &&
previous.type === "paragraph" &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should not care what previous sibling is?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I mean, always print html on own line if it was.

Copy link
Copy Markdown
Collaborator Author

@seiyab seiyab Dec 25, 2025

Choose a reason for hiding this comment

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

This part is about not printing double hardline (= preceding blank line) rather than owning line. Block HTML elements already always own their line. The idea not considering previous node type here sounds a reasonable choice, though its about having a blank line.

Should we get even inline HTMLs own their line if they did? It might be complex because they are in paragraphs and will also affects (and maybe be affected by) next nodes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

If we don't care previous sibling type: seiyab@7719e5a
We can cherry-pick if you prefer it.

@fisker fisker merged commit 927b467 into prettier:remark-11-markdown Dec 26, 2025
36 checks passed
@seiyab seiyab deleted the remark-11-markdown-vendor-html-text branch December 26, 2025 06:44
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