Repository navigation
fix: leave self-closing and inline custom tags unpadded - #708
Open
ahmedriad1 wants to merge 2 commits into
Open
ahmedriad1 wants to merge 2 commits into
ahmedriad1 wants to merge 2 commits into
Conversation
Contributor
|
@ahmedriad1 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes both
preprocessCustomTagsproblems reported in #706.<cite id="a" />. When no</cite>followed, the tag was handled as an unclosed streaming container. If it ended a line, every later blank line in the document became<!---->, which split loose lists into one list per item. If a</cite>came later, the self-closing tag paired with it, and everything in between got padded.He said: <verse>line one\nline two</verse> and left., got the blank-line sandwich. That ends the paragraph right after the opening tag, so the tag rendered empty and its body became a separate paragraph.Type of Change
Related Issues
Fixes #706
Changes Made
Self-closing tags: they never match as opening tags, in either pass. Both passes share one open-tag pattern,
openTagSource.Tags that follow text: they are left unchanged in both passes, as same-line tags already were. A tag keeps the fix(custom-tags): render Markdown inside custom tags with multiline content #484 container behavior only when it starts a block (
createStartsBlock). It starts a block when only these come before it on its line (BLOCK_PREFIX_RE):It also starts a block when only that same kind of run separates it from the closing tag of an earlier multi-line container that itself starts a block, as in
<note>\na</note><note>\n**b**\n</note>. That container gets padded, so a blank line follows its closing tag. Containers are decided in document order, so for adjacent containers the result does not depend on theallowedTagsorder, in the closed and the streaming pass alike.Blank lines in the body: a tag that follows text is not padded even when its body has a blank line. Padding it can never put the body inside the tag, because the paragraph ends right after the opening tag, so it only emptied the tag. Leaving it alone also means streaming frames match the final render.
Speed: line starts are found by binary search, and each prefix run is matched once. Container pairs are only collected when a tag that follows text comes right after a closing tag or a marker. Long single-line inputs and long chains of containers stay linear.
Changeset: added a
streamdownpatch changeset.Testing
20 new tests:
<!---->(preprocessCustomTags) #706 repros as render tests.allowedTags, and while streaming;allowedTagsorder for adjacent containers;Manual checks, comparing main and this branch:
mode="static"and in streaming mode, including every character prefix of the 65 answers that contain tags. These are LLM answers that use a self-closing citation tag and inline quote tags, plus search chunks and docs.allowedTagskey orders;literalTagContent;allowedTagsorder.Behavior changes beyond the issue
<div><note>\n**b**\n</note></div>, now keeps its body as raw HTML, as CommonMark does. Main padded it and parsed the body as markdown. On its own line, the tag still works as a container.Not changed
Text\n<note>\n…) is still padded, as on main./>on non-void elements, so a self-closing custom tag still wraps the text after it, up to the end of its paragraph.Checklist
pnpm changeset)