From df7bc0b266bf1755a9311002a329e5d272265517 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 18 Oct 2026 12:08:29 +0200 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=203=20=F0=9F=9F=A1;=20rewrite=20the=20Line=20comment=20and=20t?= =?UTF-8?q?wo=20test=20names,=20and=20name=20the=20markdown=20in=20the=20c?= =?UTF-8?q?hangelog=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- src/markdown/parse/blocks.test.ts | 4 ++-- src/markdown/parse/blocks.ts | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4c36a..f6f242d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ - Every reader takes time linear in the markdown when it holds blank lines under list items nested deeply. Such a list is still refused as `unsupported-nesting-depth`, now after 40 ms where 20000 nested items and as many blank lines took 10.7 seconds. -- Every reader takes time linear in the markdown when it holds tab-indented lines under list items +- Every reader takes time linear in the markdown when tab-indented lines sit under list items nested deeply. Such a list is still refused as `unsupported-nesting-depth`, now after 107 ms where 20 lines of 40000 tabs under 80000 nested items took 1988 ms. - `losslessMarkdownToAdf` takes time linear in the markdown when an inline directive's `[content]` diff --git a/src/markdown/parse/blocks.test.ts b/src/markdown/parse/blocks.test.ts index c597bdb..a71132c 100644 --- a/src/markdown/parse/blocks.test.ts +++ b/src/markdown/parse/blocks.test.ts @@ -165,7 +165,7 @@ function outline(blocks: readonly Block[]): string { .join(' ') } -test('reads a marker a tab pushes to four columns past its container as text, not as a marker', () => { +test('reads a marker a tab indents four or more columns into its container as text', () => { const read = (markdown: string): string => outline(parseBlocks(markdown, flavourClaims.lossless).blocks) assert.equal(read('> a\n \t> b\n'), 'quote(paragraph(a|> b))') assert.equal(read('> > a\n>\t\t> b\n'), 'quote(quote(paragraph(a|> b)))') @@ -173,7 +173,7 @@ test('reads a marker a tab pushes to four columns past its container as text, no assert.equal(read('x\n\t# h\n'), 'paragraph(x|# h)') }) -test('gives what follows an item the columns of the tab a cut splits', () => { +test("keeps as spaces the columns a tab holds past an item's indentation", () => { const read = (markdown: string): string => outline(parseBlocks(markdown, flavourClaims.lossless).blocks) assert.equal(read('- ```\n\tx\n ```\n'), 'list(code(" x"))') assert.equal(read('- a\n \t- b\n'), 'list(paragraph(a) list(paragraph(b)))') diff --git a/src/markdown/parse/blocks.ts b/src/markdown/parse/blocks.ts index 3e7415f..d3854e1 100644 --- a/src/markdown/parse/blocks.ts +++ b/src/markdown/parse/blocks.ts @@ -62,10 +62,10 @@ type ContainerStart = { kind: 'blockquote'; rest: Line } | { fresh: boolean; ind type ParagraphLine = { position: SourcePosition; text: string } -// The line from an absolute column on: a tab a cut splits keeps the stop it is measured against, and its leftover columns -// stand as `spaces` before `text`, so a cut shares `text`. At most 3, and blank, so blankness reads `text` alone. A cut of -// `largestOpenerIndentation` leaves some only on a line indented as code, which no marker follows: a marker check reads -// `spaces` first, and a block takes the line through `lineText`. +// The line from an absolute column on, so a tab after a cut still measures its stop. When a cut splits a tab, its leftover +// columns, at most 3 and all blank, go in `spaces` rather than in a new `text`. Blankness reads `text` alone, and a block +// reads the line through `lineText`. After a `largestOpenerIndentation` cut, `spaces` is non-zero only on a line indented as +// code, so a marker check no code-indent guard precedes, as in `blockquoteRest`, refuses such a line. type Line = { column: number; spaces: number; text: string } type LeafOpener = { index: number; position: SourcePosition } @@ -621,7 +621,7 @@ function leadingColumns(line: Line, upTo = Infinity): number { return columns } -// CommonMark's tab stops: a tab the cut splits leaves the columns it holds past the cut as `spaces`. +// CommonMark's tab stops. function removeColumns(line: Line, columns: number): Line { const target = line.column + columns if (line.spaces >= columns) return { column: target, spaces: line.spaces - columns, text: line.text }