fix(preprocess): flatten nested callout heads to titled quotes #24
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daniel/obsidian-remarkable-round-trip!24
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/nested-callout-titles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #22
Problem
flattenCallouts(src/preprocess/preprocess.ts:323) rewrites a callout head into a bold title line:> [!tip] Title→> **Title**, and a head with no title gets the capitalised type, e.g.> [!tip]→> **Tip**. It matches withCALLOUT_HEAD_RE = /^>\s*\[!([a-zA-Z-]+)\][+-]?\s*(.*)$/(preprocess.ts:66), which only matches the outermost level. A callout nested in a callout or quote,> > [!tip] Inner(or>> [!tip]), therefore reaches the tablet as the literal text[!tip] Inner.flattenCalloutsalso ignores code fences, so a fenced line starting with> [!note](e.g. a markdown example) gets rewritten too.What to change
flattenCallouts, use a regex that keeps any quote prefix, e.g./^(\s*(?:>\s?)+)\[!([a-zA-Z-]+)\][+-]?\s*(.*)$/, and output${prefix}**${label}**with the same label rule as today: the title, else the capitalised type.flattenCalloutsthe wayremarksInPlacedoes (preprocess.ts:296) and leave fenced lines alone.CALLOUT_HEAD_REandremarksInPlaceunchanged. Remark callouts are always top-level, and their detection must not change.Constraints and decisions
sent.markdownand replayed, so old sends are unaffected and this needs no replay flag.contentHashis over the preprocessed text, so a note with a nested callout is re-sent once on the next sync. That is intended.> > **Inner**) inside quotes; the two can land in either order. Without !23, the nested title still shows as> **Inner**text inside the flat quote, which is already better than[!tip] Inner.Validation contract
maintoday): insrc/__tests__/preprocess.test.ts, next to "flattens callouts to titled blockquotes" (:196):preprocess("> [!note] Outer\n> text\n> > [!tip] Inner\n> > more").markdowncontains> > **Inner**and no[!tip].> > [!warning]with no title →> > **Warning**.> [!note] Xcomes out unchanged.npm ci && npm test→ green.npm run lint→ exit 0.🤖 Generated with Claude Code
claude referenced this pull request2026-10-20 18:48:17 +02:00
✅ Agent run completed
2m36s · 18 turns · $0.36 · pushed
agent/nested-callout-titles· session saved — new comments resume this runWhat changed
flattenCalloutsnow matches callout heads at any quote depth:> > [!tip] Inner/>> [!tip] Inner→> > **Inner**, and an untitled one gets the capitalised type (> > **Warning**). It also tracks ``` / ~~~ fences and leaves fenced lines alone.CALLOUT_HEAD_REandremarksInPlaceare unchanged; the new regex is a separateNESTED_CALLOUT_HEAD_RE."> ".repeat(depth)(with any leading indent kept) rather than emitting it verbatim, so top-level output stays byte-identical to before (>[!tip]and> [!tip]still give> **Tip**) and>> [!tip]gives> > **Tip**.npm run lintwas already failing onmainwith 3no-unsafe-*errors insrc/__tests__/migrate.test.ts(from !19). I fixed it with anas typeof fixturecast in its own commit.Verify
preprocess.test.tsfailed with the oldpreprocess.tsand pass now.npm test: 687/687 passing.npm run lint: exit 0.879263dyet.Follow-ups
None
claude referenced this pull request2026-10-20 18:57:06 +02:00
claude referenced this pull request2026-10-20 18:57:07 +02:00
claude referenced this pull request2026-10-20 19:03:23 +02:00
claude referenced this pull request2026-10-20 19:03:23 +02:00
claude referenced this pull request2026-10-20 19:07:23 +02:00