feat(ink): render tables, lists, code and nested quotes inside quotes and callouts #23
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daniel/obsidian-remarkable-round-trip!23
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/quote-nested-blocks"
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?
Closes #22
Problem
A table (or list, code fence, heading, nested quote) inside a blockquote or callout shows up on the reMarkable as one wrapped italic paragraph of pipes and markers. Reproduced on
main@71d0788by runningparseBlockson:→ a single
{ type: "quote", lines: ["Note", "Intro text", "| Col A | Col B |", "| --- | --- |", "| 1 | 2 |", "- [ ] task one", "- item two", "", "code()", "", "> nested quote", "# Heading in quote"] }.drawQuote(src/convert/pdf.ts:780) joinslineswith spaces and wraps them in the italic font. As a result the table prints as pipes and---, the task box prints as the literal[ ]with no checkbox to tick, the fence turns into a lone backtick (inline-code stripping), and the callout title runs into the body text on the same line.Root cause:
parseBlocks(src/convert/mdblocks.ts:416-433) treats every>line as plain text and appends it to onequoteblock. Nothing inside a quote is parsed as blocks.What to change
1. Parser —
src/convert/mdblocks.tsParseOptions.nestedQuotes?: boolean, following the pattern ofhtmlandquotePictures.>lines, strip one quote level from each (/^\s*>\s?/), and parse the inner text recursively withparseBlocks(inner, options). Emit a quote block that holds its children, e.g.{ type: "quote"; lines: string[]; inline?; blocks?: Block[] }. You can pick the exact shape, but with the flag off, the block shape must stay byte-identical: existingtoEqualtests and old sends' replays depend on it.paragraphof the quote. ThequotePictureshoisting atmdblocks.ts:423-427is the legacy path only.withImageBlocks(below) finds it there.> \pagebreakchild is ignored, asdrawBlockalready ignores pagebreaks.2. Typesetter —
src/convert/pdf.tsTypesetterstate (e.g.ts.inset, default 0). Every draw routine's left x (ts.opts.margin + …) becomests.opts.margin + ts.inset + …, andcontentWidth()subtractsts.inset. Touch points:drawLines,drawHeading,drawParagraph,drawList(bullet, checkbox andcheckboxRectx),drawCode(band and text),drawGridRows/drawTable/computeColumnWidths(left/right, total width),drawHr,drawImageBlock,drawImage. Only the left edge and width change; vertical uses ofmargin(newPage,ensureRoom) do not. With inset 0, every existing layout must be unchanged to the point, because imported marks are anchored to that grid.drawQuote, when the block hasblocks, add 14 pt to the inset (the current quoteindent),drawBlockeach child, then restore the inset.margin + outerInset + 3, 1.5 pt grey, the same as today. Children can break pages, so keep a stack of open quote frames:newPagecloses each open frame's bar at the bottom margin and reopens it at the top of the new page. Nested quotes get their own bar at their own inset.quoteband (drawHighlightkind"quote"): draw it only behind text-like children (paragraph, heading, list). Code, tables and pictures keep their own accents, so the band must not overlap a code or table-header band. A nested quote draws its own band; the outer quote must not draw a second one.**Note**, the callout title) keep their style. Headings, lists, tables and code keep their own fonts.measureBlocks(pdf.ts:1222), like the other fields. That function documents why it must restore everything.3. Ink renderer —
src/ink/inkrender.tswithImageBlocks(:131) maps top-level blocks only. Make it recurse into a quote'sblocks, so pictures and remark ink inside quotes still turn intoinkimage/inkoverlay.drawImagealready respects the inset after step 2.4. Replay gating —
src/id/mapping.ts,src/inkedge.ts,src/sync/send.tsnestedQuotes?: truetoInkSnapshot(mapping.ts:~113, doc comment likequotePictures).snapshotBase()(inkedge.ts:162) and passnestedQuotes: trueinsend.ts:181.loadInk(inkedge.ts:233) passnestedQuotes: entry.ink.nestedQuotes === true.Why: the import regenerates a send's strokes exactly from the kept text. A notebook sent before this change must replay with the flat quote, or every mark in and after a quote is misplaced.
5. CHANGELOG-INK.md
Add an Unreleased bullet in the existing voice, e.g. "Tables, lists, task boxes, code and nested quotes inside quotes and callouts are typeset as such…".
Constraints and decisions
typo/INK_SHAPE_VERSION. It is a parse-level change, andinline/quotePicturesset the precedent for this.contentHashis over the preprocessed markdown, which this MR doesn't change.sourceprojection.tsaligns layout words to the note by order, with>and|treated as syntax, so erase/move/marks inside quoted tables keep working. A table's divider row is not drawn, as for top-level tables.inkpull.tableColumnUnderusesrole === "table"lines and their x positions. A quoted table produces normaltablelines, so it works there with no change.LineRoleas it is: children use their own roles.Out of scope (sibling MRs)
> > [!tip] X) that preprocessing does not flatten → MR onagent/nested-callout-titles.> - [ ]lines, and remark text written into a quoted table cell → MR onagent/quote-import-roundtrip.loadDrawingsdoesn't see> ```mermaid): follow-up, not here.Validation contract
maintoday): add tests tosrc/__tests__/mdblocks.test.ts.parseBlockson the sample above with{ html: true, quotePictures: true, nestedQuotes: true }must give a quote whoseblockscontain, in order: a boldparagraph"Note", aparagraph"Intro text", atablewithrows: [["Col A","Col B"],["1","2"]], alistwith a task item, acodeblock["code()"], a nestedquote, and aheading. The same input withoutnestedQuotesmust still give today's flatlines(assert it explicitly).src/__tests__/tables.test.tsorpdf.test.tsstyle): typesetting a quote holding a table placesrole: "table"lines whose x is ≥margin + 14. A quote holding- [ ] taskplaces a line with acheckboxrect. Every top-level block in an existing fixture keeps identical placed lines (inset 0).inkimagethroughwithImageBlocks(src/__tests__/imageblocks.test.tsorinkstrokes.test.ts).ink.nestedQuotesabsent,loadInkparses quotes flat (extend thequotePicturestests insrc/__tests__/inkstrokes.test.ts/remarkinplace.test.ts).npm ci && npm test→ all green.npm run buildandnpm run lint→ exit 0.🤖 Generated with Claude Code
✅ Agent run completed
3m21s · 23 turns · $3.65 · pushed
agent/quote-nested-blocks· session saved — new comments resume this run⚠️ Verification gate not satisfied: awaiting intent review. Outcome parked — not marked done.
claude referenced this pull request2026-10-20 18:48:17 +02:00
claude referenced this pull request2026-10-20 18:57:06 +02:00
claude referenced this pull request2026-10-20 18:57:07 +02:00
What changed
nestedQuotesoption parses the content of a quote recursively, so the quote carriesblocks. With the option off, the output is byte-identical to before. A callout title and picture lines become their own paragraphs, and> \pagebreakis ignored.ts.insetis applied to every draw routine; inset 0 leaves the layout point-identical, which a golden fixture guards.newPageclose the bar at the bottom margin and reopen it on the next page.measureBlocksrestores the new state.withImageBlocksnow recurses into quotes.InkSnapshot.nestedQuotesflag is set insnapshotBaseandsend.ts.loadInkpasses it on, so older sends replay with flat quotes.main, which brings in the sibling MRs #24 and #25. The only conflict was in CHANGELOG-INK, and both entries are kept. I added a test that a preprocessed> > [!tip] Innerbecomes a titled inner quote. Themigrate.test.tslint fix is the same one that landed on main.Verify
npm testpassed (713 tests), andnpm run lintandnpm run buildboth exit 0. The red-gate tests inmdblocks,quoteblocks,inkstrokes,remarkinplaceandsourceprojectionfail without the change. No CI pipeline has run on this branch yet. The only run listed is an older failed one onmain.Follow-ups
loadDrawingsdoes not see> ```mermaid, as noted in the MR.substituteVaultImagesandimageRefTargetsstill only scan top-level blocks. Images inside quotes reach the tablet throughwithImageBlocks, but those two helpers don't see them.✅ Agent run completed
2m29s · 16 turns · $0.61
Acceptance-intent assessment
#22 asks for tables, and other things nested inside comment blocks (quotes and callouts), to render properly on the reMarkable, and for other gaps in that area to be found and filled. This MR delivers the rendering half. Behind a new
nestedQuotesparse option, a quote's content is parsed as blocks of its own. The typesetter then draws each child with its own routine, set in by a left inset under a continuous bar. Older sends still replay flat. The other gaps found in this area went to sibling MRs !24 and !25, both already merged. The one remaining gap (Mermaid inside callouts) is tracked as an explicit follow-up.Criteria
Tables inside quotes/callouts render as tables. PASS.
parseBlockswithnestedQuotesreturns a childtablewithrows: [["Col A","Col B"],["1","2"]](mdblocks.test.ts).drawTableanddrawGridRowsnow draw fromleft(ts), withtotal = contentWidth(ts).quoteblocks.test.tschecks that a quoted table placesrole: "table"lines at x ≥ margin + 14.Other nested things render properly (lists, task boxes, code, headings, nested quotes, callout title). PASS.
checkboxrect.**Note**becomes its own bold paragraph and no longer runs into the body.newPage.> \pagebreakdraws nothing.Pictures and remark ink inside quotes still render. PASS.
withImageBlocksnow recurses intoquote.blocks. A test turns a picture inside a nested quote into aninkimage.No regression for existing notebooks and layouts. PASS.
linesexplicitly.InkSnapshot.nestedQuotesflag is set insnapshotBaseand insend.ts, andloadInkpasses it on.layout-inset0.jsonis a fair baseline. I copied the fixture and its test onto a worktree oforigin/main, and it passes there unchanged, so it records the pre-change layout and was not generated from the new code."Other gaps in that area": identified and filled. PASS. The issue thread lists them.
Splitting the work this way covers the question the issue asked; this MR covers the rendering scope.
Validation contract. PASS. I ran it locally.
npm cisucceeded, andnpm testpassed all 713 tests in 62 files.npm run lintexits 0 (run directly) andnpm run buildexits 0. CHANGELOG-INK has the Unreleased bullet.Verdict
Approved
claude referenced this pull request2026-10-21 00:28:50 +02:00
claude referenced this pull request2026-10-21 00:28:50 +02:00