[Micromark] resolve unnecessary newline before inline html tag#18501
Conversation
commit: |
✅ Deploy Preview for prettier ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| text | ||
| <em>text</em> | ||
| text |
There was a problem hiding this comment.
Technically saying, it's better to be formatted as following:
text <em>text</em> textBut it's hard to be consistent with html-flow hack.
| ) { | ||
| const tagName = node.value.match(/^<\/?([a-z0-9-]+)/iu)?.[1].toLowerCase(); | ||
| const isInlineTag = | ||
| tagName && ![...htmlBlockNames, ...htmlRawNames].includes(tagName); |
There was a problem hiding this comment.
What will be broken if we don't check tagName?
There was a problem hiding this comment.
I guess HTML block tags (like tables) will get able to follow paragraph without a blank line. But I haven't experimented. I'll get it sure later.
There was a problem hiding this comment.
I think it's expected?
Otherwise, we add blank line to both
Foo
<div>
bar
</div>
and
Foo
<div>
bar
</div>
There was a problem hiding this comment.
I consider the following is expected:
Foo
<div>
bar
</div>There was a problem hiding this comment.
Make sense.
But this case
<table><tr><td>
<pre>
**Hello**,
_world_.
</pre>
</td></tr></table>
Should we consider inserting a new line after </pre> a bug?
I think it's fine to simply respect the existing line break?
There was a problem hiding this comment.
Should we consider inserting a new line after
</pre>a bug?
I think it's fine to simply respect the existing line break?
Ah I understand. </pre> problem is more serious so respecting the input makes sense.
There was a problem hiding this comment.
Or an intermediate idea: only check tagName for opening tag
There was a problem hiding this comment.
Let's keep it this way for now. We can improve if necessary.
|
Is this expected? Prettier pr-18501 --parser markdownInput: text
<em>text</em>
text
<em>text</em>
Output: text
<em>text</em>
text
<em>text</em>
|
|
Unintentional. I missed the case... |
|
I found the following case reports AST change. But I leave it because it's neither caused nor tackled by this PR but caused by html-flow hack. Prettier pr-18501 --parser markdownInput: text
<em>text</em>Output: text
<em>text</em>
|
Description
Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.