fix(import): task ticks and remark text inside quotes and callouts #25

Merged
daniel merged 4 commits from agent/quote-import-roundtrip into main 2026-10-20 18:57:15 +02:00
Collaborator

Part of #22

Problem

!23 makes task boxes and tables inside quotes and callouts render as real checkboxes and grids on the tablet. The import side still assumes these constructs start at column 0, so pen input in them is lost or breaks the note. This MR closes those gaps. The changes here are source-text logic only and don't depend on !23's code, so they can land in either order.

  1. Ticks and strikes on a quoted task are dropped. TASK_LINE_RE = /^\s*[-*+]\s+\[( |x|X)\]/ (src/incoming/sourceprojection.ts:443) is checked against the source line at :307 (strike → cancel) and :384 (checkbox / checkbox-cancel). A tick on > - [ ] task, or > > - [ ] task, fails the test and is silently skipped. applyTaskStates (:451) uses the same column-0 regex to rewrite the marker.
  2. A remark written into a quoted table cell breaks the table. In insertRemarkText (src/incoming/remarkinsert.ts:184), TABLE_ROW = /^\s*\|.*\|\s*$/ doesn't match > | a | b |. The code falls into the > branch (:226), which inserts > remark text as a new line after the row. That ends the table, and the rest of the rows render as text.
  3. A remark written against a quoted list item becomes a lazy continuation of that item's paragraph, not a new item: the same > branch inserts > text after > - item. A top-level list item already gets a new item via the LIST_ITEM branch (:230).

What to change

  • sourceprojection.ts: allow an optional quote prefix in TASK_LINE_RE and in the applyTaskStates replace regex, e.g. /^((?:\s*>\s?)*\s*[-*+]\s+)\[( |x|X)\]/. The replacement must stay the same length so no offsets shift (see the applyTaskStates doc comment).
  • remarkinsert.ts insertRemarkText: when the anchor line starts with a quote prefix (/^(\s*(?:>\s?)+)/), strip the prefix and run the existing table-cell and list-item logic on the remainder. Re-add the prefix to every line written. Continuation lines of a quoted list item also carry the prefix, so the list-continuation scan (:234) must compare the stripped lines. If the stripped line is neither a table row nor a list item, keep today's behaviour: insert ${prefix}${line} after the anchor.
  • Add a CHANGELOG-INK.md Unreleased bullet.

Constraints and decisions

  • Top-level behaviour must stay unchanged: existing taskmarks, remarkinsert and sourceprojection tests stay green.
  • Leave blockEnd (sourceprojection.ts:764) alone. For a line inside a callout it returns the end of the callout, so a remark callout goes after the whole callout. That is the right place, because a callout cannot sit inside a callout line.
  • Out of scope: the rendering itself (!23) and nested callout titles (!24).

Validation contract

  • Red gates (fail on main today):
    • src/__tests__/taskmarks.test.ts: copy an existing "tick marks the task done" case, but with source > [!todo]\n> - [ ] buy milk (and a > > - [ ] x variant). A checkbox mark over the task's words → the output contains > - [x] buy milk. A checkbox-cancel → > - [-] buy milk. A strike over most of the quoted task line → cancelled.
    • src/__tests__/remarkinsert.test.ts: note > [!note]\n> | A | B |\n> | --- | --- |\n> | 1 | | with a remark anchored to the > | 1 | | row and column: 1 → the row becomes > | 1 | text |, and no line is inserted into the table. A remark against > - item → a new > - text item.
  • npm ci && npm test → green. npm run lint → exit 0.

🤖 Generated with Claude Code

Part of #22 ## Problem !23 makes task boxes and tables inside quotes and callouts render as real checkboxes and grids on the tablet. The import side still assumes these constructs start at column 0, so pen input in them is lost or breaks the note. This MR closes those gaps. The changes here are source-text logic only and don't depend on !23's code, so they can land in either order. 1. **Ticks and strikes on a quoted task are dropped.** `TASK_LINE_RE = /^\s*[-*+]\s+\[( |x|X)\]/` (`src/incoming/sourceprojection.ts:443`) is checked against the source line at `:307` (strike → cancel) and `:384` (checkbox / checkbox-cancel). A tick on `> - [ ] task`, or `> > - [ ] task`, fails the test and is silently skipped. `applyTaskStates` (`:451`) uses the same column-0 regex to rewrite the marker. 2. **A remark written into a quoted table cell breaks the table.** In `insertRemarkText` (`src/incoming/remarkinsert.ts:184`), `TABLE_ROW = /^\s*\|.*\|\s*$/` doesn't match `> | a | b |`. The code falls into the `>` branch (`:226`), which inserts `> remark text` as a new line after the row. That ends the table, and the rest of the rows render as text. 3. **A remark written against a quoted list item becomes a lazy continuation** of that item's paragraph, not a new item: the same `>` branch inserts `> text` after `> - item`. A top-level list item already gets a new item via the `LIST_ITEM` branch (`:230`). ## What to change - `sourceprojection.ts`: allow an optional quote prefix in `TASK_LINE_RE` and in the `applyTaskStates` replace regex, e.g. `/^((?:\s*>\s?)*\s*[-*+]\s+)\[( |x|X)\]/`. The replacement must stay the same length so no offsets shift (see the `applyTaskStates` doc comment). - `remarkinsert.ts` `insertRemarkText`: when the anchor line starts with a quote prefix (`/^(\s*(?:>\s?)+)/`), strip the prefix and run the existing table-cell and list-item logic on the remainder. Re-add the prefix to every line written. Continuation lines of a quoted list item also carry the prefix, so the list-continuation scan (`:234`) must compare the stripped lines. If the stripped line is neither a table row nor a list item, keep today's behaviour: insert `${prefix}${line}` after the anchor. - Add a CHANGELOG-INK.md *Unreleased* bullet. ## Constraints and decisions - Top-level behaviour must stay unchanged: existing `taskmarks`, `remarkinsert` and `sourceprojection` tests stay green. - Leave `blockEnd` (`sourceprojection.ts:764`) alone. For a line inside a callout it returns the end of the callout, so a remark callout goes after the whole callout. That is the right place, because a callout cannot sit inside a callout line. - Out of scope: the rendering itself (!23) and nested callout titles (!24). ## Validation contract - **Red gates (fail on `main` today):** - `src/__tests__/taskmarks.test.ts`: copy an existing "tick marks the task done" case, but with source `> [!todo]\n> - [ ] buy milk` (and a `> > - [ ] x` variant). A `checkbox` mark over the task's words → the output contains `> - [x] buy milk`. A `checkbox-cancel` → `> - [-] buy milk`. A strike over most of the quoted task line → cancelled. - `src/__tests__/remarkinsert.test.ts`: note `> [!note]\n> | A | B |\n> | --- | --- |\n> | 1 | |` with a remark anchored to the `> | 1 | |` row and `column: 1` → the row becomes `> | 1 | text |`, and no line is inserted into the table. A remark against `> - item` → a new `> - text` item. - `npm ci && npm test` → green. `npm run lint` → exit 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude self-assigned this 2026-10-20 18:48:37 +02:00
Author
Collaborator

🤖 Agent is working on this — turn 52

Last activity: assistant message — updated 16:54:46 UTC

Last message:

I merged the latest main into the MR branch, resolved the conflict and pushed the merge commit (bf99789). The MR should be mergeable again.

  • The conflict: only CHANGELOG-INK.md clashed. main had added a bullet about nested callouts (!24) at the same spot as this MR's bullet. Both belong, so I kept both.
  • Lint fix: main had already landed the same one-line lint fix to migrate.test.ts that this branch made, and it merged without a conflict.
  • Checks after the merge: npm test passes 694/694 and npm run lint exits 0, both run locally.

I posted a short update on the MR saying the same.

🤖 **Agent is working on this** — turn 52 _Last activity: assistant message — updated 16:54:46 UTC_ **Last message:** > I merged the latest `main` into the MR branch, resolved the conflict and pushed the merge commit (`bf99789`). The MR should be mergeable again. > > - **The conflict:** only `CHANGELOG-INK.md` clashed. `main` had added a bullet about nested callouts (!24) at the same spot as this MR's bullet. Both belong, so I kept both. > - **Lint fix:** `main` had already landed the same one-line lint fix to `migrate.test.ts` that this branch made, and it merged without a conflict. > - **Checks after the merge:** `npm test` passes 694/694 and `npm run lint` exits 0, both run locally. > > I posted a short update on the MR saying the same.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Task ticks, stripes and strikes on a quoted task line now rewrite its
marker, and a remark anchored to a quoted table row or list item goes into
the cell or becomes a new item, the quote prefix kept on every line.

Part of #22

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Collaborator

What changed

  • sourceprojection.ts: TASK_LINE_RE now allows a quote prefix (/^((?:\s*>\s?)*\s*[-*+]\s+)\[( |x|X)\]/), and applyTaskStates uses the same regex. Ticks, stripes and strikes on > - [ ] … and > > - [ ] … now become [x] or [-]. The rewrite keeps the line length, so no offsets shift.
  • remarkinsert.ts insertRemarkText: the quote prefix is taken off before the table-cell and list-item logic runs, and put back on every line written. The list-continuation scan compares the lines without the prefix. Any other quoted line works as before. A top-level line has an empty prefix, so its behaviour is unchanged.
  • Added a CHANGELOG-INK Unreleased bullet. Also fixed the 3 lint errors in src/__tests__/migrate.test.ts: they were already on main and made npm run lint fail, so I added a one-line type cast in a separate commit.

Verify

New red-gate tests failed before the change and pass now: 4 in taskmarks.test.ts (tick, stripe-cancel and strike in a callout, plus a nested quote) and 3 in remarkinsert.test.ts (callout table cell, quoted list item with a continuation line, numbered list in a nested quote). npm test passes 691/691 and npm run lint exits 0. No CI pipeline has run on this branch.

Follow-ups

None

## What changed - `sourceprojection.ts`: `TASK_LINE_RE` now allows a quote prefix (`/^((?:\s*>\s?)*\s*[-*+]\s+)\[( |x|X)\]/`), and `applyTaskStates` uses the same regex. Ticks, stripes and strikes on `> - [ ] …` and `> > - [ ] …` now become `[x]` or `[-]`. The rewrite keeps the line length, so no offsets shift. - `remarkinsert.ts` `insertRemarkText`: the quote prefix is taken off before the table-cell and list-item logic runs, and put back on every line written. The list-continuation scan compares the lines without the prefix. Any other quoted line works as before. A top-level line has an empty prefix, so its behaviour is unchanged. - Added a CHANGELOG-INK *Unreleased* bullet. Also fixed the 3 lint errors in `src/__tests__/migrate.test.ts`: they were already on `main` and made `npm run lint` fail, so I added a one-line type cast in a separate commit. ## Verify New red-gate tests failed before the change and pass now: 4 in `taskmarks.test.ts` (tick, stripe-cancel and strike in a callout, plus a nested quote) and 3 in `remarkinsert.test.ts` (callout table cell, quoted list item with a continuation line, numbered list in a nested quote). `npm test` passes 691/691 and `npm run lint` exits 0. No CI pipeline has run on this branch. ## Follow-ups None
Owner

@claude resolve mr conflicts

@claude resolve mr conflicts
Author
Collaborator

Since my last update: I merged main (which now includes !24) into this branch and resolved the one conflict, in CHANGELOG-INK.md, by keeping both Unreleased bullets. main also has the same lint fix for migrate.test.ts; it merged cleanly with no duplicate change. After the merge, npm test passes 694/694 and npm run lint exits 0. Pushed as bf99789.

Since my last update: I merged `main` (which now includes !24) into this branch and resolved the one conflict, in `CHANGELOG-INK.md`, by keeping both *Unreleased* bullets. `main` also has the same lint fix for `migrate.test.ts`; it merged cleanly with no duplicate change. After the merge, `npm test` passes 694/694 and `npm run lint` exits 0. Pushed as `bf99789`.
daniel merged commit db6c9a7667 into main 2026-10-20 18:57:15 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
daniel/obsidian-remarkable-round-trip!25
No description provided.