Repository navigation
Label grammar: six edge cases from 0.47.0 (#70) - #78
Merged
Merged
Conversation
…ort) Each test asserts the correct behaviour and fails on 0.47.0 where the bug is real. No source changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… regressions - Block TK output: links resolve over each block's markdown and the block is rendered again, never over its HTML, where a label had already been through markdown (`*em*` -> `<em>`) and escaping. The HTML-source path (htmlCodeRanges, the `inert` parameter, previewInternalLinks' html flag) is gone. - A backtick in a live link's label no longer opens a code span that makes a later link inert: labels are blanked before code is found again, left to right, so a span opened before a link still wins (blygger#54). - labelText spaces every `]` followed by `]` or by the closing `]]`, so `a]]]b`, `a]]]]b` and `x]]]` round-trip through linkSource. - An autolinked URL holding a link gets its literal HTML-escaped in the href (`&` -> `&`). - withStubQuote keeps the directive line as written, label included. - directiveOwnLine takes `[^\S\n]` at both ends, DIRECTIVE_LINE's `\s` less the newline, so NBSP/FF/VT-led own-line directives in TK output are warned about (blygger#60). test/label-grammar-repros.test.ts becomes label-grammar-edge-cases.test.ts, with one added case for code-span precedence over a label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Six edge cases in 0.47.0's label grammar (
[[id | text]], #70). They were found while porting the renderer to another client, Blygger Desktop/Burrow, which pins studio output byte for byte. Each one was reproduced onmainwith a failing test before it was fixed. The tests are kept as regression coverage intest/label-grammar-edge-cases.test.ts.a <b> & xshowed asa <b> & x, and*em*showed as literal<em>em</em>. Block links were resolved from the block's already-rendered HTML. This only shows withimpyrtor generated block scopes, because model output already has links stripped (row 67).AnnotatedDocumentcarriesblockSources, andrenderGeneratedBlockre-renders a block only if it has links. Decoding entities from the HTML can't work, because markdown has already rendered the label's emphasis by then. The now-dead HTML path is removed: theinertparameter,previewInternalLinks'htmlflag, andhtmlCodeRanges.[[id]]on the same line literal, though no code renders.labelTextrewrote]]in one pass, soa]]]bbecamea] ]]band re-parsed truncated./\](?=\]|$)/g→"] ". The trailing]matters too, because callers append]]straight after the label.a]]]b,a]]]]bandx]]]all round-trip.&in its label left a raw&inhref(©decodes to ©).escapeHtml(encodeURI(literal))for the href, and the matching comparison updated.![[id | label]]to a bare![[id]], losing the label.findQuotereturns the original directive line, andwithStubQuotereuses it.directiveOwnLineused[ \t]whereDIRECTIVE_LINEuses\s. A form-feed or vertical-tab led own-line directive in TK output was quoted, but publish didn't give the #60 warning.[^\S\n]*at both ends, which is exactly\swithout the newline that ends a line. CRLF already agreed, and a control test pins it.Behaviour beyond the six:
labelTextcan return a label with a trailing space when the text ends in]. That's needed for the round trip.No wire, contract or migration changes.
Tests
npm run typecheck(both configs): clean.npm test: 1758 passed, 5 skipped.npm run test:ui: 97 passed.parity,picker,reading-pwa(stub passage quote) andgenerated-highlight, desktop and mobile: 97 passed, 1 skipped.ci-scope: the oracle, plus auth-security in both modes (48 + 5 caught). All pass.🤖 Generated with Claude Code