Check that every small Markdown source and every CommonMark and GFM spec example parses, serializes and parses again to the same document, that a whole file that opens with a YAML or TOML front matter block stores that block, that a streamed parse that continues its previous result equals a fresh parse, and that each preview of a stream keeps the text it showed, takes back a guessed closer no more often than its source leaves markers open, hides at most three arrived characters and shows the text a strict parse of the same prefix shows, less only markers a later character can still pair, and that a partial parse or parseInline shows what a partial parseSlice of the same prefix shows, over the plugins of the Markdown test editor and the shipped kit's indent. Use before and after changing packages/platejs/src/markdown/lib or another file in its coverage record, when the markdown-round-trip step of pnpm check fails, or when fixing a Markdown or streaming bug a seed or a tester found.
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Handle $ARGUMENTS. check, or no argument, runs the gate bound. deep runs --inline=3 --part=round-trip and --blocks=3 and compares their failures with Findings. lower runs --lower after a fix removes a known finding. case <identity> runs --case=<identity> to print one case's full detail. update brings the verification in line with changed code, as Coverage record says.
The property. Two rules hold for every source up to the bound. A source that editor.api.markdown.parse accepts serializes, and the serialized Markdown parses to the same document. A streamed parse with parseSlice that continues a previous preview of the same source gives the result a fresh parseSlice of that prefix gives, at every chunking. docs/vision/plate.md says streaming continues the prior result with previous, and that the Markdown runtime owns reuse and invalidation so consumers keep no parse cache. Reuse that changed the result would break that promise.
Three more rules judge the preview of each prefix of a streamed source. The text a preview shows starts the text of the next longer preview and of the final document, so text a reader saw never changes. A preview hides at most three arrived characters of the final text. A preview shows the text that a strict parse of the same prefix shows, block by block. It may leave out only a marker that a later character can still pair, or one backslash that ends the prefix. Today's codec breaks the first two rules on the sources that Findings counts. The baseline holds each of those sources once per finding, so a repair lowers a source's count and no change may raise one.
A fourth rule judges a preview that shows half-typed bold, italic or strikethrough as it will read once it closes. Such a preview hides the opening markers on a guess. When the stream shows that the run never closes, the markers come back, so the preview takes text back once. The rule files that take-back apart from the first rule's and allows a source as many as its final text leaves runs of markers open. It keeps no baseline. Today's codec guesses 8 times at the gate, each within its source's ceiling, so the rule finds nothing.
The harm. A round trip that changes the document loses content each time a user saves and reopens Markdown, or each time an AI reply goes through the codec. A streamed preview that differs from a fresh parse shows the user a document that changes when the stream ends, or a final document that differs from the source. A preview that takes text back makes an AI reply flicker while it streams. One that hides arrived text looks stalled, and one that drops or adds a character shows text the document never holds. Each Markdown fix before this check, such as e1fb01295e, covered only the cases someone had already found.
packages/platejs/scripts/markdown-round-trip.ts runs the real codec of createTestEditor in packages/platejs/src/markdown/lib/__tests__/createTestEditor.tsx, with BaseIndentPlugin given the indent targets of apps/www/src/registry/components/editor/indent-static.tsx. That editor has the plugins the Markdown stress cases use, and its remark plugins are math, GFM, the two CJK-friendly plugins and emoji. A block that the parse indents keeps its indent as it does in the shipped kit. The script checks the TypeScript code itself, not a model of it.
--inline tokens from 22 tokens: a, a space, *, **, _, a backtick, ~~, [a](b), <br/>, <u>, </u>, a backslash, a newline, $, !, #, <, &, https://a.b, [^1], | and :+1:.https://a.b.\na and https://a.b)\na put a bare URL before a line break, and <https://a.b'> a, <https://a.b"> a and <https://a.b;> a end a URL in a character that GFM trims from a bare URL. The link plugin refuses the URL of <https://a.b]> a, so the parse keeps it as text. The parse also keeps <div>www.a.b </div> and <div>a@b.cd </div> as text. Each must parse again as text, though GFM finds an autolink literal in it. They run alone and join no sequence, because as block forms they would almost double the 902 round-trip sequences. Seven more fixed sources hold emphasis whose reading depends on the CJK plugins. 这是**重点。**然后, 日本語の**「強調」**です, 这是~~删除。~~文字, 这是*斜体。*文字 and 한국어 **강조.**다음 end bold, strike or italic in punctuation beside a CJK letter, which CommonMark alone keeps as text. 这是\*\*重点。\*\*然后 escapes its asterisks and a**"b"**c holds no CJK character, so both parse as text and must parse again as text. No inline token holds a CJK character, so these seven are fixed sources, and they run alone for the reason the URL sources do. Forty-three more fixed sources are whole files whose first line is --- or +++, or whose Markdown starts like one. 22 open with a YAML or TOML front matter block, such as ---\ntitle: Hello\ntags: [a, b]\n---\n\n# Body\n\nText.\n, an empty block, a block after a byte order mark and a YAML block that closes on .... 21 must stay CommonMark, such as a --- line over a heading, a list, a quote or a paragraph, as in ---\n\n# Introduction\n\nBody text.\n\n---\n\n# Next\n, a block with no closing line, a block that holds only a comment, a lone surrogate or TOML table brackets that do not pair, and a file whose first line is blank. Each source names the block its document parse must store in meta['markdown.frontmatter'], or none. Only a document parse reads a front matter block, so these sources join no streamed sequence, and they run alone for the reason the URL sources do. ---\n---\n is also CommonMark example 98, so the gate counts 42 of them. Two more forms leave a tag open that a count of tag names reads as closed, <callout> with </callout> in a code span and </callout> <callout>. They join only the streamed sequences. So do five forms whose half-typed syntax a preview shows before it closes: *a*, a code span, ~~a~~,  and a table of two columns. The spec examples cover their round trips.--blocks forms, each holding a, joined by one or two newlines. The round trip runs 902 sequences at the gate and the stream 1,595. 47 more sources stream alone, because as block forms they would more than double the sequences. On 41 of them, such as [a](b c) d, a**b** and **a\n\nb, a repair of half-typed syntax can hide text that has arrived, take text back or change a block before the one still arriving. Two hold a line of no-break spaces, which is not blank, so it ends no paragraph and closes no fence. Four hold what a repair must keep. **a \* b holds an escaped marker and **a `b*c` d a marker inside a code span. a  and **a  write the stand-in character U+E000 as a character reference. A repair may read an open paragraph again with that character after it. 28 more sources stream alone at every chunking, judged only by the two continuation rules, because each continued parse once differed from a fresh one. 21 hold an HTML block whose end the segment scan once read where the parse does not, such as <pre></script> or <!-->. One ends in a line of digits that the next chunk turns into a list marker. The rest hold a carriage return, a byte order mark, a half-typed tag after an unclosed one or diagnostics from two segments. The preview rules skip them, because their previews take back and hide text the way the sources Findings counts do.prefix part puts each of seven inline forms, **a**, *a*, a code span, ~~a~~, [a](b),  and a<br/>, in each of the 15 block forms that take an inline content, such as a bold run in a table cell. The stream part already runs 7 of those 105 sources, so the part runs 98. It streams each one character at a time, as the spec-stream part does, not at every chunking.commonmark-spec package with each → as a tab, and the 41 examples of GFM 0.29.0.gfm.13 that CommonMark lacks, kept in packages/platejs/scripts/markdown-round-trip-gfm.ts. Each example runs the round trip at every bound. The spec-stream part also streams each one as a\n\n<example>\n\na, one character at a time. It continues the preview of each prefix to the next character, as a preview and as a strict parse, and compares each with a fresh parse of that prefix. The preview rules of item 8 read the same fresh previews. A finding's detail starts with its example, such as CommonMark 0.31.2 example 218. A preview rule's detail counts the characters of the streamed source, so a prefix there is 3 characters longer than the same prefix of the example.refused and is not a failure. The script compares documents after nameDocumentListIds, because each parse gives every list a new id. A source that holds a line ending is also parsed with each one written as CRLF and then as CR, and each parse must give the document of the LF form. The documents these steps compare include their meta, so a front matter block must survive each of them. A front matter source also fails when its first parse stores another block than the one it names. A parse that drops part of the source drops it before any document exists, so the round trip also reads the code fences of the source and of the serialized Markdown with remark-parse and GFM alone. Each fence with a language or meta in the source must come back with both, unless the first parse reported a diagnostic. A fence with neither has nothing to lose. That parser also lacks the test editor's math and tag plugins, so it can read a callout's or a math block's body as such a fence.lossPolicy: 'allow', partial: true) and as a strict parse. Then it continues each reachable preview to its own prefix and every longer one, as a preview and as a strict parse, and compares each with the fresh result. A continuation reads its previous result through the runtime's checkpoint. Every stored state is a preview of a prefix of the same source, so the checkpoint's editor, formats, limits, policy and source test are the same for all of them, and each segment's nodes, diagnostics and last root follow from the segment ends. So the script records each checkpoint, merges previews whose segment ends match, and still covers every chunking without walking each chain. A failed preview merges with a checkpoint that has no segments, because neither reuses anything. When a preview has no recorded checkpoint, or a segment has no whole-number end, the script exits 2, because it can no longer read markdownCheckpoints in packages/platejs/src/markdown/lib/internal/markdownConversion.ts.spec-stream and prefix parts, the script reads the fresh preview of every prefix, from one character to the whole source, and runs five rules on them. A spec example files its take-backs, hidden runs and lossless findings under rules of their own, so the spec examples have their own baseline entries and the counts of the other sources stay as they were. Its guesses past the ceiling go to markdown-stream-guess, as every source's do. markdown-stream holds a continued preview equal to the fresh one, so a finding of these rules shows at every chunking that delivers its prefixes.
excused, 216 at the gate.*, _, ~ or backslash characters left out. That strict parse is the one the lossless rule reads, without the half-typed tag and under lossPolicy: 'allow'. The text that takes it back, the next preview's or the final document's, starts with that strict parse's text. So does the strict parse of the whole source without each link or footnote definition that starts after the earlier preview's prefix, because a definition that arrives later changes the blocks before it. Every other take-back stays a markdown-stream-prefix finding. A source's ceiling is the number of runs of one marker, *, _ or ~, that the strict parse of the whole source shows as plain text, outside code, formulas and objects. A source with more guesses than its ceiling gets one markdown-stream-guess finding per guess, and a source within its ceiling gets none.trimIncompleteMarkdownTag, as the preview does before it parses, and parses the rest without partial under lossPolicy: 'allow', the preview's own policy. It skips a prefix whose preview or strict parse is refused. It reads both results as blocks, each block that holds text or is one object, in document order, and compares their text. A block of the preview must equal the strict parse's block with nothing added or changed, and it may leave out only two kinds of character. One is a *, _ or ~ that the strict parse shows as text outside code and that the source wrote unescaped. To tell, the script parses the prefix again with every escaped marker and every character reference to a marker spelled as another character, and the marker must still show at the same place. The other is one unescaped backslash that ends both the prefix and the last block. The preview may hold one block fewer than the strict parse, the last, when every character of that block may be left out. A preview with more blocks fails, and so does one that shows more stand-in characters, U+E000, than the strict parse.parse and parseInline. The script also parses each prefix with a partial parse and compares its blocks with the partial parseSlice of that prefix by block type, mark value and text. When parse stores a front matter block, parseSlice reads the prefix with that block blanked, because parseSlice reads no front matter. Where parseSlice shows one paragraph, a partial parseInline must show that paragraph's text and mark values, past leading whitespace.markdown-fence-info: a source whose code fence language or meta the serialized Markdown leaves out, though the parse reports nothing.markdown-front-matter: a front matter source whose document parse stores another block than the one the check names for it.markdown-line-endings: a source whose CRLF or CR line endings parse to another document than its LF line endings.markdown-round-trip: a source whose parse, serialized and parsed again, gives another document.markdown-serialize: a parsed document that does not serialize, or whose Markdown does not parse.markdown-stream: a preview that continues an earlier preview and differs from a fresh preview.markdown-stream-final: a strict parse that continues a preview and differs from a fresh strict parse.markdown-throws: a parse or serialize that throws.markdown-stream-parse: a partial parse or parseInline that shows other blocks, text or mark values than the partial parseSlice of the same prefix. It records the first such prefix of each source.markdown-stream-guess: a guess, on a source with more guesses than its ceiling.markdown-stream-hidden: a run of previews that each hide more than three arrived characters.markdown-stream-lossless: a preview that shows other text than the strict parse of the same prefix, beyond a marker or a trailing backslash it may leave out.markdown-stream-prefix: a preview that takes back text the preview before it showed, other than a guess, or that the parse refuses.markdown-spec-stream-hidden: a markdown-stream-hidden finding on a streamed spec example.markdown-spec-stream-lossless: a markdown-stream-lossless finding on a streamed spec example.markdown-spec-stream-prefix: a markdown-stream-prefix finding on a streamed spec example.packages/platejs/scripts/markdown-round-trip-baseline.json through tooling/scripts/finding-baseline.mjs. Every finding is filed under packages/platejs/src/markdown/lib. An identity is the source alone, and the detail names the chunking, because which chain first reaches a state changes whenever the codec's segments do. Under the six hidden, lossless and prefix rules the baseline holds a source once per finding, and the detail names the prefix and the texts. So the baseline counts each source's take-backs, and a take-back that moves to another prefix keeps its entry. The guess and markdown-stream-parse rules have no baseline entry, so any finding of either fails the gate.Run every command from the repository root.
pnpm check:markdown-round-trip checks the gate bound: two inline tokens and two blocks. It compares 11,609 cases: 9,148 round trips, 679 of them spec examples that parse and 42 front matter sources, 1,670 streamed sources, 693 streamed spec examples and 98 prefix sources. On a loaded machine, it took 11 to 43 s and 141 to 170 CPU-s. It prints one JSON summary line, then each finding the baseline does not list. pnpm check markdown-round-trip runs the same step through the check runner, and Local CI runs it on next after each landing.pnpm check markdown-round-trip --light is the run a session makes before a diff panel, and it runs the whole step. The gate is its own light run, because its 90th-percentile time is under a minute. It took 74 s through the check runner at a load average near 125.guesses counts every guess, within its source's ceiling or not. closedTakeBacks counts the markdown-stream-prefix take-backs, without the refused previews, of the closed sources, those with a ceiling of 0. It is 1,968 at the gate, down from 2,446 before the preview styled open runs, and a change to how it styles them must not raise it. differingPreviews counts the previews whose blocks hold other text than the strict parse of their own prefix, as the lossless rule reads both. It is 1,168 at the gate, each a preview that leaves out markers or a trailing backslash the strict parse shows. unmarkingPreviews counts the previews that show a character without a mark that the preview one character shorter showed it with. It reads a mark set to undefined, null or false as no mark. It is 60 at the gate, down from 178, such as **a* b*, whose bold a turns italic when the b arrives. To compare two previews, the script reads each character of the earlier one at its first place in the later one after the character before it, and skips a character the later one dropped. closedCopiesRun counts the fresh previews of the stream, spec-stream and prefix parts for which the partial parse read a closed copy of its open tail. closedCopiesKept counts those whose text differs from the same preview parsed again with each copy's tree emptied. An empty copy makes the preview show the received parse. They are 5,226 and 1,966 at the gate. The script sees and empties the copies through a remark plugin it adds to the test editor. The other four counts and excused read the stream and prefix parts alone, so the spec examples' preview rules left every count as it was.--inline and --blocks raise one part of the bound, and --part=round-trip, --part=stream, --part=spec-stream or --part=prefix runs one part. --inline=3 --part=round-trip compares 166,999 cases in 439 CPU-s on a loaded machine, and --blocks=3 compares 136,237 cases in 4,350 CPU-s on a loaded machine. Its stream half, --blocks=3 --part=stream, holds 89,338 of them. A bound other than the gate's, --part or --case skips the baseline and exits 1 on any failure.--case='<identity or part of one>' prints the full diff and stack of each failure whose identity contains it, such as --case='"<br/><br/>"'.bun test ./packages/platejs/scripts/markdown-round-trip-previews.spec.ts runs the cases that say which take-back is a guess. The markdown-round-trip step of pnpm check runs it after the gate, because no test suite collects a spec under packages/platejs/scripts/.--jobs=<n> sets the number of worker processes. It defaults to CHECK_CORES, the cores the check runner reserves for the step, and otherwise to the machine's cores up to 16. Findings do not depend on it.completesDefinition in packages/platejs/scripts/markdown-round-trip-previews.ts then excuses nothing, so either it broke or the codec no longer needs it. At the gate the run also fails when it compares other than 11,609 cases, the GATE_CASES constant, so a change that makes parse refuse more sources cannot shrink the gate while the baseline still matches. Update the constant only with the reason the count moved.pnpm check:markdown-round-trip --lower. The baseline never grows past the base commit's copy. --init seeds only a rule the baseline lacks and never the guess rule. --lower and --init write nothing when the case count misses GATE_CASES or a source passes its guess ceiling.A finding prints its rule, identity and the first line of its detail:
markdown-round-trip "<br/><br/>"
serialized "<br />\n<br />\n"; the parse again differs at .children.0.children.0.text: "\n\n\n", not "\n\n"
markdown-stream "1. a\na\n\n1. a"
chunked at 1,9,10, the continued result differs at .slice.content.1.listId: "b", not "a"The first is a known finding, two breaks in a row that come back as three line endings. The second is what the gate prints when findMarkdownSegmentBoundaries stops keeping a list open, as What a pass proves says. The preview of the first 9 characters ends in 1, which is not a list marker yet. So the segment scanner commits a boundary after the lazy line, and the continuation splits one list in two. Run --case on the identity for the full documents.
The preview rules name the prefix and the texts:
markdown-stream-prefix "**a**"
the preview of the first 4 characters shows "*a" after "**a"
markdown-stream-hidden "<callout>\n\n`</callout>`"
the previews of the first 16 to 21 characters hide up to 9 arrived characters of "</callout>"; at 16 the preview shows "`"
markdown-stream-lossless "**a `b*c` d"
the preview of the first 9 characters shows "**a bc" in block 1, not "**a b*c", as the strict parse of "**a `b*c`" shows
markdown-stream-guess "**a\n\nb"
the strict parse of the whole source shows "**a\nb" after "a\nb", one of 2 guesses against a ceiling of 1The first two are known findings. In the first, the preview shows the opening stars as text and takes one back when the first closing star arrives. The third is what the gate prints when a partial parse drops a star inside a code span. The fourth is what it prints when previews hide the stars of **a twice and the stream shows them again twice, though the final text leaves one run open. The run prints both guesses. A source that the baseline lists prints only its identity when it gains a finding, as markdown-stream-prefix packages/platejs/src/markdown/lib: "\"a**b**\"", because the baseline holds fewer entries for that source than the run found. Run --case on the source to print each of its findings, and compare them with the same run on the base commit.
Tell a real bug from a modeling error before you change code:
--lower.docs/vision/plate.md together. Never weaken a rule or add a baseline entry to get green.The gate finds 2,628: 59 markdown-round-trip, 1 markdown-throws, 1,982 markdown-stream-prefix, 72 markdown-stream-hidden, 478 markdown-spec-stream-prefix and 36 markdown-spec-stream-hidden. The first two numbered 157 at fix(markdown): round-trip every CommonMark and GFM spec example. Measured on 7bc3175013, the lockfile's move from mdast-util-to-markdown 2.1.2 to 2.2.3 cleared 79 round-trip entries, 42 headings and 37 callouts whose text starts or ends with a break. The CJK plugins' writer cleared 6 more, a break before a bare URL in a paragraph, a quote, a list item or a footnote definition. Read by their examples, the round-trip entries that remain fall into these classes. No log proves that each class has a single cause:
<div>:+1:</div> comes back with the emoji glyph and escaped tags.https://a.b:+1: comes back as text that holds the emoji glyph in place of the shortcode.# https://a.b<br/> serializes the break as 
, which the parse again reads into the URL, and so does a callout that holds https://a.b<br/>.<callout>\n<br/>https://a.b\n</callout> serializes the break as a space.<u>. The serializer closes it around the text after it, as in [<u> ] and a table cell that holds <u> .The other entry has one cause:
> [^1]:+1: throws Markdown node mapping "blockquote" expected block content. during serialize. 1 markdown-throws entry.The preview entries measure today's partial parse. It shows an open bold, italic or strikethrough run styled, as a closed copy of its open tail reads. It holds back a trailing marker it cannot read yet. Other half-typed syntax shows as text until it closes. markdown-stream-lossless and markdown-stream-guess have none, and the summary's guesses is 8.
markdown-stream-prefix entries on 1,233 sources. Each entry is grouped by the first character of the earlier text that the later text does not keep, or by the character after it when that one is a line ending. The largest classes are the backticks of a fence (242), the dollars of a math block (230), the number of an ordered item before its dot (230), a code span's backtick (229), a table's rows before its delimiter row (214), a link's [a](b (140), <br/ (121), an image's , a task item's box (118) and the dashes of a thematic break (109). Most of the others take back the text of a callout tag in the two unbalanced tag forms. The same grouping counts 398 emphasis markers and 122 strikethrough markers at test(platejs): tell a streamed preview's guessed closer from a take-back, and 34 and 9 now. Each of those 43 is an open run in or after a link or footnote definition, after a table or an unbalanced callout tag, or inside raw HTML, where the preview shows the received parse. 9 entries are previews that the parse refuses, each a prefix that reads as a heading around an image, such as \n-.markdown-spec-stream-prefix entries on 302 examples, grouped as the take-backs above are. The largest classes are backticks (92), [ (81), * (38), the & of a character reference (37), < (34) and an object character (26). 62 are *, _ or ~. CommonMark example 427, **foo **bar****, takes back twice: the preview of 12 characters shows **foo **b after foo **, and the preview of 15 shows foo bar after **foo **bar. 13 entries are refused previews. 36 markdown-spec-stream-hidden entries on 32 examples. They include markers that a preview styles or reads as a thematic break and the stream then shows as text, such as the four stars of example 392, **(**foo), HTML that the preview cuts as a half-typed tag, and a link definition whose title is still arriving. markdown-spec-stream-lossless has none.markdown-stream-hidden entries. Each is a tag that the final document shows as text. The preview cuts it as a half-typed tag until its > arrives, so up to 9 characters of </callout> stay hidden, and 12 characters of the code span in Use `a <u>b</u> [c](d) now` .Both deep runs below ran before fix(markdown): keep a comment only as its own HTML block and read back lone breaks, which cleared 12 round-trip entries at the gate: 5 task items that start with a break, 5 sources with two breaks in a row, <br/><u> and <u><br/>. --inline=3 --part=round-trip fails 2,496 round trips and 24 throws, and every throw is a footnote definition in a quote. --blocks=3 fails the gate's 71 round trips and 1 throw. No source there fails markdown-stream, markdown-stream-final or markdown-stream-lossless. The run finds 211,991 markdown-stream-prefix and 4,177 markdown-stream-hidden entries and excuses 16,224 take-backs. Neither run finds a markdown-line-endings case. The deep runs read no baseline.
Bugs planted on this tree showed where the gate holds:
markdown-round-trip and 74 markdown-throws findings, 199 of them new. - a<br/> drops its break, and a heading with an autolink throws heading expected inline content.!state.openList test in markdownSegments.ts gives 4 markdown-stream and 4 markdown-stream-final findings, such as 1. a\n\n1. a chunked at 1,7,8 and 1. a\na\n\n1. a chunked at 1,9,10, two lists where one belongs.markdownConversion.ts and the bare URL check in markdownIntrinsics.ts, gives 405 markdown-line-endings findings, such as - [ ] \n_, whose CRLF form keeps a leading line ending. It also fails the five bare URL sources that the script held then. https://a.b.\na serializes to https://a.b.\\\na, which parses again without the link. <https://a.b'> a serializes to https://a.b' a, which parses again with the ' cut from the URL.remarkSeparateEscapes from the parse in markdownConversion.ts gives 7 markdown-round-trip findings: the ], www. and email sources and four div sources, such as <div>https://a.b </div>. <https://a.b]> a serializes to https\://a.b] a, which parses again with a link to https://a.b, because mdast-util-gfm-autolink-literal finds the URL in the decoded text.MARKDOWN_DEFINITION.test(source) fallback in markdownConversion.ts gives stream findings on [a]\n\n[a]: b chunked at 1,11 and [^1]: a\n\n[^1]: a chunked at 1,13, a reference that a later definition does not resolve.markdownConversion.ts gives a stream finding on <div>a</div>\n\n<div>a</div> chunked at 1,18, two text runs that normalization would join.markdownConversion.ts gives 40 markdown-stream and 40 markdown-stream-final findings, such as </callout> <callout>\n\n--- chunked at 1,24, a body that falls out of its tag.fix(markdown): round-trip every CommonMark and GFM spec example, gives 22 new markdown-round-trip findings and 1 markdown-stream finding, all spec examples. CommonMark example 335 splits its code span into three at its line endings, example 404 closes its emphasis before the link it holds, and example 218 streams [foo] as text, though the quote below it defines foo.meta in the code block's Markdown decode in packages/platejs/src/features/code-block/lib/BaseCodeBlockPlugin.ts gives 2 markdown-fence-info findings and no markdown-round-trip finding, because both parses drop the meta alike. They are CommonMark examples 143 and 146, such as ~~~~ ruby startline=3 $%@#$, which serializes to a fence of ruby alone. Writing no meta in that plugin's Markdown encode gives the same 2 and 2 more markdown-round-trip findings. Both runs used the script of fix(platejs): keep a code fence's meta through Markdown import and export.markdownConversion.ts gives 22 markdown-front-matter findings, one for each front matter source that names a block. ---\n title: Hello\n---\nBody\n stores no block, where the check names a YAML block of title: Hello.markdown-stream findings. A segment scan that commits each boundary its line state allows, without the parse's check, gives 14. In each, a continued preview splits or joins a block that a fresh preview of the same prefix reads whole.markdown-round-trip findings. \n+++\n\nx=1\n\n+++ serializes to +++\n\nx=1\n\n+++\n, which parses again as a TOML block, and so does \n+++\n\ntitle = "Hello"\n\n+++\n.Each run used the gate bound and restored the product files byte for byte. The two front matter runs used the script of feat(markdown): keep a Markdown file's YAML or TOML front matter. Each earlier run also ran before the lockfile moved to mdast-util-to-markdown 2.2.3, so its round-trip counts are those of the 2.1.2 writer. The 7bc3175013 run used the script of fix(markdown): round-trip every CommonMark and GFM spec example, the unclosed tag run the script of fix(markdown): keep a streamed tag open until its real closer, and the remarkSeparateEscapes run the script of fix(markdown): read an escaped URL as text. The openList and 0cfbdc701a runs used the script of fix(markdown): read CR line endings as LF and keep a bare URL a link, and the others ran at the first sync, test(platejs): check Markdown round trips and streamed parses on every small document.
Mutations planted in runParsedNodes of markdownConversion.ts, on the partial parse only, an earlier repair and two changes to the check's own files showed where the three preview rules hold:
markdown-stream-lossless findings. On **a \* b the preview of the first 6 characters shows **a where the strict parse shows **a *.**a `b*c` d.shows 1 stand-in characters (U+E000), not 0.<callout>\n alone gives 1. The default strict parse refuses that prefix, so the rule reads it only because it parses under the preview's own loss policy.a\\**b**. Hiding one unescaped backslash that ends the prefix gives none.a**, one character after the preview of a* showed the first, gives one more markdown-stream-prefix finding on a**b**, a source the baseline lists, and no lossless finding.markdown-stream-lossless findings. On - [ ] a\n**a** its preview of the first 10 characters shows a where the strict parse shows a\n**, so it hides a line ending with the stars.completesDefinition never matches excuses nothing, finds 2,683 markdown-stream-prefix entries and exits 2. The gate on a baseline without the three rules' entries prints all 2,467 take-backs and 72 hidden runs with their details.Each of these runs used the gate bound, in a scratch worktree at fix(platejs): keep a continued Markdown preview equal to a fresh one with the script that added the three rules, and restored the product files byte for byte.
Two classifiers planted in packages/platejs/scripts/markdown-round-trip-previews.ts, and the codec of a repair that never landed, showed where the guess rule holds:
markdown-round-trip-previews.spec.ts. They are a star the next preview invents in the middle, a star more than the strict parse of the prefix shows, another marker than the one the prefix holds, and a styled preview that the next one shows raw though the final parse styles it.markdown-stream-prefix findings. [^1]: n\n\n**a [^1] b** shows n\n**a and the footnote's object after n\na [^1 at 17 characters. [a]: u\n\n*b **[a]** c* shows *b **a after b [a at 16. **[\*x](u)** shows *x after [*x](u at 10. The fourth is planted: after a preview of **hello world that shows hello world, the final text is *.Each of these runs used a scratch worktree at test(platejs): check what each streamed Markdown preview shows with the script that added the guess rule.
Two mutations planted in packages/platejs/scripts/markdown-round-trip-previews.ts at feat(markdown): show the open bold, italic or strikethrough of a streamed preview styled showed where its changes to the preview rules hold:
markdown-round-trip-previews.spec.ts. On a_b, a blank line and [r]: u, a planted preview of 11 characters shows ab after a_b\n[r]:, and only the excuse's new condition files it.false as a mark fails "reads a mark set to false as no mark".A take-back planted in parseMarkdownSliceWithRuntime of markdownConversion.ts showed where the spec examples' preview rules hold. The plant makes the preview of a\n\naaa\n\nbb, the first 10 characters of CommonMark example 219's stream, read the source without its last two characters. The gate then finds 1 more markdown-spec-stream-prefix entry, the preview of 10 characters showing a\naaa after a\naaa\nb, and 1 markdown-spec-stream-lossless entry, and it fails. The gate of feat(markdown): show the open bold, italic or strikethrough of a streamed preview styled, which ran no preview rule on the spec examples, passes the same plant. Both runs used the gate bound in scratch worktrees.
packages/platejs/src/markdown/lib/internal/markdownOpenTail.spec.ts tests the closed copy itself. Each check that keeps or refuses a copy fails one of its tests under a planted mutation. The gate ran on none of those mutants.
Synced at fix(markdown): commit a streamed segment only where its own parse ends. The verification describes these files as they stand there:
| File | What the check exercises |
|---|---|
packages/platejs/src/markdown/lib/MarkdownPlugin.ts | parse, parseSlice and serialize |
packages/platejs/src/markdown/lib/internal/markdownConversion.ts | the full parse, the partial parseSlice, the tag it cuts first and the closed copy of its open tail, the line-ending pass, checkpoints and segment reuse |
packages/platejs/src/markdown/lib/internal/markdownSegments.ts | the boundaries a streamed parse proposes, and whether a segment's own parse holds one open |
packages/platejs/src/markdown/lib/internal/markdownTags.ts | trimIncompleteMarkdownTag, which the lossless rule runs on each prefix as the preview does |
packages/platejs/src/markdown/lib/internal/markdownOpenTail.ts | the closers a partial parse plans for an open bold, italic or strikethrough run, the trailing markers it holds back, and the checks that keep or refuse the closed copy |
packages/platejs/src/markdown/lib/internal/ | the mappings, tags, lines, intrinsics and front matter both directions use |
packages/platejs/src/markdown/lib/deserializer/ | Markdown to nodes |
packages/platejs/src/markdown/lib/serializer/ | nodes to Markdown |
packages/platejs/src/markdown/lib/__tests__/createTestEditor.tsx | the plugins under test |
packages/platejs/src/features/indent/ | the indent plugin the check adds |
apps/www/src/registry/components/editor/indent-static.tsx | the kit's indent targets the check copies |
packages/platejs/scripts/markdown-round-trip-gfm.ts | the GFM examples |
packages/platejs/scripts/markdown-round-trip-previews.ts | the editor under test, the text a result shows, the take-backs, the guess rule and the remark plugin that counts closed copies |
packages/platejs/src/markdown/lib/__tests__/nameListIds.ts | comparing documents up to list ids |
packages/plitejs/scripts/check-harness.ts | the flags, workers and gate the formal checks share |
To see whether the verification needs another look, find the sync commit with git log --oneline -1 --grep "commit a streamed segment only where its own parse ends", then run git log --oneline <that commit>..HEAD -- with the table's paths and packages/platejs/scripts/markdown-round-trip.ts. For each commit it lists, read the diff and confirm eight things. A continuation still reads its previous result only through the checkpoint's segments and the startsWith test on its source, and each segment's facts still follow from its ends alone, so merging previews by segment ends stays sound. New Markdown syntax the codec supports has an inline token or a block form. A new plugin in the test editor that changes what a source parses to is in the gate. The check's indent targets still match the kit's. A preview still cuts its half-typed tag with trimIncompleteMarkdownTag and the runtime's tags before it parses. Past that it only holds back trailing markers and shows a closed copy of its open tail. Both differ from the received text only in markers, so the lossless rule's strict parse reads what the preview read. The partial parse still runs the editor's remark plugins on each closed copy, so the script's probe plugin sees every copy. A partial parse that reads an open paragraph again with a stand-in character uses U+E000, the script's STAND_IN. A change to which files the front matter reader takes for a block adds a front matter source on each side of that change. Move the sync commit in this file forward, naming its subject, only after that check and a run of pnpm check:markdown-round-trip.
a, and the sources that stream alone. The spec-stream and prefix parts continue each source one character at a time, so other chunkings of inline syntax go unchecked.parse or parseInline in an editor unlike the test editor, such as one with ElementIdPlugin or a custom paragraph decoder. markdown-stream-parse compares the three entry points only in the test editor, and markdownOpenTail.spec.ts tests the closed copy in those editors.markdown-stream still compares whole documents, continued against fresh.lossPolicy: 'allow'. The lossless rule skips that prefix, and the prefix rule still reads the preview.2*3 costs what a guess that a blank line ends costs.unmarkingPreviews, and no rule limits them.RawHtmlPlugin, so the gate never runs a parse that marks raw HTML. With that plugin, a continued parse reuses no segment.packages/platejs/src/markdown/lib/cjkEmphasis.spec.ts asserts their marks and exported bytes.<callout>\r a loses its indented text. That bug is in the markdown subject's Open work. A round trip of these forms joins the gate once that bug is fixed.parseSlice reads no front matter block, so the front matter sources join no streamed sequence.remark-frontmatter in a streamed parse. With it, or any remark plugin that adds block syntax other than a math block, a GFM table and a GFM footnote definition, a continued parse reads the whole source. The test editor adds no such plugin, so the gate never runs that whole read, and markdownContinuation.spec.ts covers it.refused and gets no round trip./pstack:maintain-formal-verification-skill brings this verification back in line after changes that did not recheck it.
udecode/plate
46bed0c
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.