Skip to content

"Fix" markdown html printing#18467

Merged
fisker merged 8 commits intoprettier:remark-11-markdownfrom
fisker:html-print
Dec 12, 2025
Merged

"Fix" markdown html printing#18467
fisker merged 8 commits intoprettier:remark-11-markdownfrom
fisker:html-print

Conversation

@fisker
Copy link
Copy Markdown
Member

@fisker fisker commented Dec 10, 2025

Description

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 10, 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: 0ab7b45


export const disableHtmlFLowHack = () => {
enabled = false;
};
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@seiyab 😄

@fisker fisker marked this pull request as ready for review December 11, 2025 09:45
_world_. </pre>
_world_.

</pre>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, didn't notice that we added extra new line?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, the extra new line in <pre> is problematic.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hmm but the previous behavior removing a trailng newline can be also problematic... I'll see it later.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

b9763bc is good to me.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let' keep it this way for now.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@fisker
I find this case itself don't make sense enough now. I missed the resulting HTML #18467 (comment) is broken. It contains mismatching <p> and <pre>, say, ordering as <p>...<pre>...</p>...</pre>.
So I consider we don't need to care the number of spaces / newlines for this case. It is unclear whether it's <pre> or not.
I want to hear your opinion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Clearly, CommonMark doesn't treat it <pre> as HTML in this case, so I think we are safe to change whitespace inside it.

Let's pretend <pre> is not there.

<table><tr><td>
<pre>
**Hello**,

_world_.
</pre>
</td></tr></table>

<table><tr><td>
pre
**Hello**,

_world_.
pre
</td></tr></table>

I can see they format to the same result now (regardless of --prose-wrap).

@fisker
Copy link
Copy Markdown
Member Author

fisker commented Dec 11, 2025

@seiyab Are you fine with this approach?

@seiyab
Copy link
Copy Markdown
Collaborator

seiyab commented Dec 11, 2025

Looks good except #18467 (comment) as cursory review. I'll see deeper.

@fisker fisker merged commit a4626a4 into prettier:remark-11-markdown Dec 12, 2025
31 of 32 checks passed
@fisker fisker deleted the html-print branch December 12, 2025 10:56
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