From 3f2f63aac005a380076eeddf3923d19126183038 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 30 Sep 2026 16:57:54 +0200 Subject: [PATCH] 41 - review: a callout title reads its nodes as the plain reduction does, one goal reference renumbered --- README.md | 2 +- docs/decisions.md | 2 +- src/markdown/parse/markdown-to-adf.ts | 5 ++++- src/markdown/parse/plain-markdown-to-adf.test.ts | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d001777..31eda5b 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ read replaces mentions, attachments and macros with text. | ADF | Written | Read back | | --- | --- | --- | | `panel` | a GitHub alert, `> [!WARNING]`: info `NOTE`, note `IMPORTANT`, tip and success `TIP`, warning `WARNING`, error `CAUTION`, custom `NOTE` | `NOTE` info, `IMPORTANT` note, `TIP` tip, `WARNING` warning, `CAUTION` error, and Obsidian's: hint tip; success, check, done success; attention warning; danger, failure, fail, missing, bug, error error; any other word info — in any case; the rest of the marker's line is the first paragraph | -| `expand`, `nestedExpand` | Obsidian's folded callout, `> [!NOTE]- Title` | `-` or `+` after any word, the rest of the marker's line the title, a link as `text (target)`, an autolink as its text; an expand inside an expand is a `nestedExpand` | +| `expand`, `nestedExpand` | Obsidian's folded callout, `> [!NOTE]- Title` | `-` or `+` after any word, the rest of the marker's line the title, a link as `text (target)`, one whose text is its target as its text; an expand inside an expand is a `nestedExpand` | | `taskList` | `- [x] Done`, `- [ ] Todo` | a bullet list whose every item is so marked, `[X]` too | | `backgroundColor` | `==text==` | `==text==` on one line, the text touching both delimiters, bounded outside by whitespace, punctuation or a line edge, or touching a Han, Hangul, Hiragana, Katakana, Thai, Lao, Khmer or Myanmar character on either side, in the editor's default highlight `#f8e6a0` | | `table` | a pipe table: the first row its header, a cell's blocks on one line, a span kept under its header by empty cells | — | diff --git a/docs/decisions.md b/docs/decisions.md index f4f02f2..337453e 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -184,7 +184,7 @@ and HTML parsers are written in this repo. ## Standards ship as data 2026-08-30, the CommonMark suite 2026-09-05 and ADF's schemas 2026-09-13, the maintainer. Goals 1, -3 and 7. Valid while each table is fixed data a dependency would only wrap. +3 and 8. Valid while each table is fixed data a dependency would only wrap. A table a standard fixes is data rather than a dependency: HTML5's 2125 semicolon-terminated character references ship packed in their own module, so entity decoding is complete without one. diff --git a/src/markdown/parse/markdown-to-adf.ts b/src/markdown/parse/markdown-to-adf.ts index 84a2ac8..5a85072 100644 --- a/src/markdown/parse/markdown-to-adf.ts +++ b/src/markdown/parse/markdown-to-adf.ts @@ -8,6 +8,7 @@ import type { LinkDefinitions } from './inline-content.ts' import { carryName, readCarriedBlock } from '../opaque-carry.ts' import { commonMarkSpelling, type SpellingMemo } from '../emit/adf-to-markdown.ts' import { failure, faulted, positioned, success, type ConvertErrorPath, type ParseError, type Result, type SourcePosition } from '../../result.ts' +import { inlineLeaves } from '../emit/plain-inline.ts' import { languageSlot } from '../code-language.ts' import { largestNesting } from '../../nesting.ts' import { leadingMarker, readAlertMarker, readTaskMarker } from '../plain-conventions.ts' @@ -130,7 +131,9 @@ function quoteNode(blocks: readonly Block[], reading: Reading, path: ConvertErro const title = parseInlineContent(line, reading.definitions, path, 'paragraph', 'lossless') if (!title.ok) return title if (title.value.image !== undefined) return failure('unmappable-image', imageOnMarkerLine, path) - const text = titleText(title.value.nodes) + const leaves = inlineLeaves(title.value.nodes, 'paragraph', path, depth) + if (!leaves.ok) return leaves + const text = titleText(leaves.value) const type = reading.inExpand ? 'nestedExpand' : 'expand' return filledNode(text === '' ? { type } : { attrs: { title: text }, type }, readMarked(paragraphsOf(led.position, rest), false, body, { ...reading, inExpand: true }, path, depth)) } diff --git a/src/markdown/parse/plain-markdown-to-adf.test.ts b/src/markdown/parse/plain-markdown-to-adf.test.ts index 3c0e112..4fb4b94 100644 --- a/src/markdown/parse/plain-markdown-to-adf.test.ts +++ b/src/markdown/parse/plain-markdown-to-adf.test.ts @@ -123,6 +123,7 @@ test('reads a folded callout to an expand titled by the rest of its marker line, assert.deepEqual(read('> [!faq]- See [x](http://y)\n'), normal(node('expand', { title: 'See x (http://y)' }, paragraph()))) assert.deepEqual(read('> [!faq]- [a **b**](u "t")[c](u) and [d](v)\n'), normal(node('expand', { title: 'a bc (u) and d (v)' }, paragraph()))) assert.deepEqual(read('> [!faq]- or \n'), normal(node('expand', { title: 'http://y or a@b.c' }, paragraph()))) + assert.deepEqual(read('> [!faq]- [!adf:mention[@M]{id=5}](u) !adf:inlineCard{url="http://y"}\n'), normal(node('expand', { title: '@M (u) http://y' }, paragraph()))) assert.deepEqual(read('> [!NOTE]- Set ==x== here\n'), normal(node('expand', { title: 'Set ==x== here' }, paragraph()))) assert.deepEqual(read('> [!NOTE]-\n>\n> Line.\n'), [bare('expand', said('Line.'))]) })