oficina / mapa Public

The importer's looks: icons, covers and column widths (columns and icons spec, phase 4)

A Notion page's icon and cover become its icon and banner, prepared
before its write under notion_images' icon: and cover: places: emoji
checked against the list, uploaded and custom icons capped at 128 KB and
512 pixels, covers from Notion's file store and its gallery only.
ImportCreate writes the look; ImportUpdate writes renamed, styled,
edited; unchanged compares the look. The report counts icons and
banners by reason, and uneven column widths. Gates I20, I21, I24, I25;
four mutations. Luna on the report's words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev bd3ee462621b4cdfe4139b966ed7b80393ba047d parent bad9c27
36 files changed, +1,003 −43
  • AGENTS.md +6 −0
  • copy-review/import-looks/result.json +53 −0
  • copy-review/import-looks/strings.json +74 −0
  • docs/superpowers/specs/2026-11-17-notion-import.md +9 −4
  • docs/superpowers/specs/2026-11-22-mapa-columns-icons.md +9 −0
  • go.mod +1 −1
  • go.sum +2 −0
  • internal/mapa/import_convert.go +12 −4
  • internal/mapa/import_images.go +7 −0
  • internal/mapa/import_images_store.go +4 −0
  • internal/mapa/import_looks.go +217 −0
  • internal/mapa/import_looks_test.go +242 −0
  • internal/mapa/import_report.go +30 −7
  • internal/mapa/import_safety_test.go +6 −2
  • internal/mapa/import_set.go +3 −0
  • internal/mapa/import_store.go +35 −2
  • internal/mapa/import_write.go +35 −3
  • internal/mapa/markup/testdata/corpus/import.json +2 −0
  • internal/mapa/markup/testdata/editor.json +3 −1
  • internal/mapa/markup/testdata/golden.json +2 −0
  • internal/mapa/notionmd/blocks.go +20 −0
  • internal/mapa/notionmd/fixtures_blocks_test.go +15 −1
  • internal/mapa/notionmd/mapper.go +0 −6
  • internal/mapa/notionmd/render.go +1 −2
  • internal/mapa/notionmd/testdata/fixtures/columns-even.json +53 −0
  • internal/mapa/notionmd/testdata/fixtures/columns-widths.json +54 −0
  • internal/mapa/notionmd/testdata/fixtures/page-icon-cover.json +8 −2
  • internal/mapa/notionmd/testdata/golden/columns-even.json +5 −0
  • internal/mapa/notionmd/testdata/golden/columns-even.md +13 −0
  • internal/mapa/notionmd/testdata/golden/columns-widths.json +8 −0
  • internal/mapa/notionmd/testdata/golden/columns-widths.md +13 −0
  • internal/mapa/notionmd/testdata/golden/page-icon-cover.json +1 −5
  • internal/mapa/notionmd/tree.go +17 −3
  • internal/mapa/templates/import.html +4 −0
  • scripts/mutate/import_looks.go +38 −0
  • scripts/mutate/main.go +1 −0

CI failed — run details

CI log
=== editor ===
cd editor && npm ci --no-audit --no-fund --loglevel=error

added 16 packages in 309ms
cd editor && node build-bundles.mjs
wrote internal/mapa/static/editor.bad1b29c273b6a86.js (364471 bytes, 114.4KB gzipped; L12 budget 120KB)
cd editor && node --test
✔ a badge is named for what it does, starting with its visible word (1.066079ms)
✔ first words stop at five words or forty characters (0.173553ms)
✔ the field keeps one trimmed line, without brackets (0.288245ms)
✔ the field holds at most MaxAlt bytes, cut at a character (0.461316ms)
✔ a block becomes column 1 of two, and undo gives it back (13.480076ms)
✔ a selection over blocks moves them all into column 1 (3.110134ms)
✔ no layout is made inside a layout (0.658463ms)
✔ Add a column, Remove this column and Undo columns (5.385918ms)
✔ Undo columns puts the blocks in reading order (0.709788ms)
✔ Backspace in an empty column takes the column away (1.129928ms)
✔ ⌥⌘→ and ⌥⌘← move between columns (0.546705ms)
✔ typing a fence line in a column never closes it (D16) (8.072076ms)
✔ a selection holding a layout makes no nested layout (H1) (4.581315ms)
✔ a fence typed after a break in a column stays in the column (H2) (4.388617ms)
✔ code holding a fence line and ::: stays code in its column (H2) (4.12555ms)
✔ Backspace after a layout and Delete before one join nothing (M4) (1.613055ms)
✔ deleting across columns keeps every column (M3) (2.68262ms)
✔ a layout pasted into a column arrives as its blocks (M1) (3.947889ms)
✔ copying inside one column puts no fence on the clipboard (M2) (0.362093ms)
✔ typing goes on in the column after a structural reparse (round 2) (7.238197ms)
✔ a structural reparse in a column leaves code as it was (round 2) (3.341944ms)
✔ days and weeks move across months and years (1.568101ms)
✔ a month keeps the day, or takes the month's last (0.219007ms)
✔ the grid is six weeks from Monday, as the month calendar draws it (0.399331ms)
✔ the grid starts the week where the locale does (0.398911ms)
✔ the keys move a day, a week, a month and a year (0.211763ms)
✔ the picked day is the chip [[ makes for a date (13.93451ms)
✔ Insert → Today's date still puts today in at once (1.79387ms)
✔ / offers Date, the picker, and Today's date beside it (0.361231ms)
✔ after a ! the chip goes in after a space, never as an embed (5.493518ms)
✔ where the Markdown would read the chip differently, it is refused (2.881439ms)
✔ over a selection the chip goes after it and the words stay (2.308516ms)
✔ today is the day in the viewer's zone (17.175046ms)
✔ every offered locale has cases (0.780089ms)
✔ dates.mjs writes every date Go writes, byte for byte (3.121486ms)
✔ a chip, the month and the week, in three locales (0.418827ms)
✔ dates.json is what ICU gives, byte for byte (472.859438ms)
✔ L1: mounting then serialising gives cleanBody(body), byte for byte (88.062578ms)
ℹ 903 bodies
✔ L1: mounting a stored body adds nothing, and saving it writes nothing new (83.321508ms)
✔ L2: one edited block changes only that block's bytes; undo gives the body back (141.042288ms)
ℹ 890 single-block edits
✔ L2: inserting or deleting a block changes bytes only at the new seams, by Join (163.316548ms)
ℹ 898 inserts, 837 deletes
✔ L3: seeded edits keep the document and its Markdown saying the same thing (5147.761149ms)
ℹ 21672 edits over 903 bodies
✔ L3: Link to a page makes exactly one chip, and changes nothing else (1309.231369ms)
ℹ 4717 links over 903 bodies; refused: {"A page link can’t hold another link or a line break. Select plain words.":945,"A page link can’t show [ or ]]. Select words without them.":404,"Select some words to link them to a page.":174,"Linked here, the Markdown around these words would read differently: a ! before them makes an embed, and a stray ` or * pairs up. Select other words.":18}
✔ L3: a picked date is one more date chip, or refused where a letter would be too (1348.303144ms)
ℹ over 903 bodies: {"inserted":5350,"spaced":23,"refused":45,"unstable":9}
✔ linear: trailing spaces (35.180293ms)
✔ linear: trailing whitespace (42.864719ms)
✔ linear: unclosed web links (21.338004ms)
✔ linear: web links with no address (24.880711ms)
✔ linear: unclosed wiki links (28.331117ms)
✔ linear: unclosed embeds (22.32176ms)
✔ linear: closes only (6.963498ms)
✔ the selected words become the chip's shown text (13.785141ms)
✔ words that are the title make a plain [[Title]] (5.072027ms)
✔ spaces at the selection's edges stay outside the chip (1.334388ms)
✔ a date makes a date link, in a heading, an item and a quote (7.656575ms)
✔ bold words lose their bold: a chip carries no marks in Mapa's Markdown (1.533738ms)
✔ only the linked block's bytes change, and undo gives the body back (3.247649ms)
✔ a selection across blocks, over a chip or a break, or of brackets is refused (1.678616ms)
✔ a target the words cannot be linked to as typed is refused (0.314433ms)
✔ ⌘L: over a selection it opens Page link; with none it types [[; in code it does nothing (2.582905ms)
✔ web-linked words are refused: the address would be lost (review M4) (1.447408ms)
✔ words whose Markdown would read otherwise are refused (review M3) (2.947392ms)
✔ ⌘A then ⌘L says why, instead of doing nothing (review low 1) (0.383021ms)
✔ linkCheck says why it refuses (review low 2) (1.59458ms)
✔ golden file has bodies (0.929025ms)
✔ markup.mjs parses every body into Go's blocks, byte offsets and all (29.948821ms)
✔ markup.mjs strips and spans every block as Go does (46.040765ms)
✔ the schema's toDOM draws every body as Go renders it (64.721146ms)
✔ emphasis draws the four pinned outputs (17.819751ms)
✔ a body ends in the editor's empty paragraph (0.290169ms)
✔ the editor labels date chips as Go does, in every locale L4 holds (9.045663ms)
✔ a POST that never answers is aborted after the timeout (22.325097ms)
✔ a keepalive POST carries no signal, and an answer clears the timer (1.856477ms)
✔ autosave sends only what differs, and the tab owns the draft it wrote (11.69354ms)
✔ an offered draft never commits by itself; Save commits it (1.64253ms)
✔ reload, then close: sessionStorage says the draft is this tab's own (0.671137ms)
✔ closing carries text not yet sent, and the cap leaves it out (56.964484ms)
✔ clean rebase: applied, the caret survives, the base moves by the rebase POST (4.198575ms)
✔ the block under the caret is the teammate's too, and undo brings back yours (3.01131ms)
✔ typing mid-flight: the merge is not applied and the base does not move (1.224012ms)
✔ a merge the editor cannot represent stops after three tries (4.550698ms)
✔ a conflict is shown, locks the editor's own commits, and Resolve settles it (1.388348ms)
✔ leaving: a conflict stays with the choice; a failed flush offers Leave anyway; a stored draft leaves (1.667676ms)
✔ a stale tab shows the newer draft, offered, and never overwrites it (1.077341ms)
✔ the first scratch commit: empty creates nothing, then one page, then drafts on it (0.890363ms)
✔ noBase and gone lead to the existing choices (0.836172ms)
✔ a commit that merged is applied when nothing was typed since (1.149384ms)
✔ back from the cache: nothing unsaved reloads, unsaved text autosaves at once (7.671362ms)
✔ an own draft committed meanwhile goes on as a new draft (1.453569ms)
✔ a reload keeps a stored draft; unsent text still commits (0.597549ms)
✔ a page deleted mid-edit: what is typed is still stored as the draft, and nothing commits (H1) (1.230324ms)
✔ an offered draft committed in another tab: typing goes on as a new draft (H1) (2.417528ms)
✔ a commit reply without a revision is not a commit; an emptied day starts afresh (H2) (1.004695ms)
✔ Resolve stores what was typed first, and takes no typing until its answer is applied (M1) (3.680243ms)
✔ closing with a choice open, or commits held, still writes the text, never commits (M2) (1.349687ms)
✔ closing inside the settling window sends the loaded version with settling=1 (M3) (0.391807ms)
✔ a clean merge not applied because of typing still ends the choice on show (M4) (1.131691ms)
✔ settling finds the draft committed with a teammate's text: a close still writes (M-A) (0.579826ms)
✔ settling finds another tab's newer draft: the tab shows it before any typing (0.799204ms)
✔ a page deleted before the first autosave: the text is offered as a scratch page, and a close makes one (M-B) (0.691995ms)
✔ an autosave that never answered but landed: its 409 keeps the typing since (L3) (0.696533ms)
✔ marks: em outside strong, bold reopened around italics, edges outside (5.022195ms)
✔ marks close before code, links and atoms, and reopen after (0.358977ms)
✔ untouched blocks and atoms re-emit their source; edited atoms are written from attributes (5.967348ms)
✔ empty blocks are written as nothing (3.552115ms)
✔ an unclosed fence that is no longer last gets its closing fence (2.605938ms)
✔ the structure check puts Join's seam where a kept one would merge two blocks (2.775422ms)
✔ prepareSave adopts the parse when no seam or rewrite can save the document (6.493936ms)
✔ reparse: typed emphasis becomes a mark, "- " after a break becomes an item (3.346442ms)
✔ a trailing hard break stays on screen and is written as nothing (0.936809ms)
✔ the reparse waits while an IME is composing (1.140106ms)
✔ copied blocks paste with their bytes and seams; a cut and paste gives the body back (4.613917ms)
✔ a forged x-mapa slice is refused, and text from outside is read as Markdown (0.663061ms)
✔ rebuild changes origins only, outside undo history (2.986655ms)
✔ applyBody takes a teammate's block, keeps the caret, and ends untouched (1.562741ms)
✔ a block whose context changed is written again: a task toggled, a bullet, a quote (2.0575ms)
✔ a duplicate ^id typed above its holder never takes the id from it (1.161006ms)
✔ a copy-dragged block is reparsed, and says what its Markdown says (1.21169ms)
✔ a history command that throws is refused, never thrown (5.628889ms)
✔ an image re-emits its source, and an edited alt changes only its span (0.956385ms)
✔ a paste whose image copy is refused says why and pastes nothing (15.224715ms)
✔ a line of image openers reads in linear time (115.451488ms)
✔ a line of shared link address reads in linear time (9.019675ms)
✔ a line of shared web address reads in linear time (41.603417ms)
✔ one rename at a time, from either field (2.034306ms)
✔ an empty or unchanged title sends nothing (0.244564ms)
✔ a refusal keeps what was typed, and the title (0.263028ms)
✔ the pending state holds for the busy rule (11.455157ms)
✔ a failed POST says so and keeps the title (1.379591ms)
✔ Update links posts the confirm page's POST (0.271334ms)
✔ clean is CleanTitle's whitespace rule (0.358646ms)
✔ the saver's base follows a rename made over it, and only that (0.329783ms)
✔ closing sends the rename as one keepalive POST (2.716473ms)
✔ the port answers every shared case as typeddate.go does (6.416383ms)
✔ numbers follow the locale: 12/11 is November in en-IE, December in en-US (0.287053ms)
✔ M6: several files land in the order they were chosen (39.778921ms)
✔ M5: one Backspace before the box keeps the image where the box is (12.631219ms)
✔ M5: undoing text typed just before the box keeps the upload (13.042854ms)
✔ L12: a failed upload an undo takes away does not stall the next (13.84852ms)
✔ M4: Replace… keeps the old image until the new one is in, and its alt (14.703768ms)
✔ M3 and N1: text wins, except over a picture copied from a page (1.277642ms)
✔ N2: a JPEG over 10 MB is scaled before its size is checked (5.331076ms)
✔ a drag whose anchor the document no longer reaches selects to its end (6.729122ms)
ℹ tests 143
ℹ suites 0
ℹ pass 143
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 8459.079988
=== vet ===
go vet ./...
go vet -tags browser ./internal/mapatest/
=== fmt ===
=== code ===
go tool rastrillo budget code
The base has no .rastrillo/code.txt: skipping the check that records only go down.
budget code: within the limits.
=== test ===
CGO_ENABLED=0 go test ./...
?   	amadan.net/oficina/mapa/cmd/mapa	[no test files]
ok  	amadan.net/oficina/mapa/internal/mapa	4.019s
ok  	amadan.net/oficina/mapa/internal/mapa/emoji	0.009s
?   	amadan.net/oficina/mapa/internal/mapa/icons	[no test files]
ok  	amadan.net/oficina/mapa/internal/mapa/imagefile	0.155s
ok  	amadan.net/oficina/mapa/internal/mapa/locale	0.008s
ok  	amadan.net/oficina/mapa/internal/mapa/markup	0.147s
ok  	amadan.net/oficina/mapa/internal/mapa/notionmd	0.313s
ok  	amadan.net/oficina/mapa/internal/mapa/seal	0.004s
ok  	amadan.net/oficina/mapa/internal/mapatest	13.646s
?   	amadan.net/oficina/mapa/scripts/mutate	[no test files]
?   	amadan.net/oficina/mapa/scripts/preview	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
=== credits-check ===
python3 scripts/credits.py --check
the Colophon's JavaScript inventory is stale; run make credits
make: *** [Makefile:171: credits-check] Error 1

amadan: step credits-check failed: exit status 2

amadan: job failed at step credits-check — its output is above, not at the tail of this log
diff --git a/AGENTS.md b/AGENTS.md
index 8d248cd..bff8e81 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -173,6 +173,12 @@ Makefile, estilo's files served straight from the module).
`import_pins.go` (the import pins its roots once, marked in the
sealed coordinate). Pins hold up to 20 (`pins.go` still reads a
list sealed at 12).
+ - The importer's looks (the same spec, §6.1, §6.4, phase 4):
+ `import_looks.go` (a page's icon and cover prepared before its
+ write, under notion_images' pseudo-blocks `icon:` and `cover:`;
+ covers fetched only from Notion's file store and its cover gallery,
+ the one external path the notion module pins), and `ImportUpdate`'s
+ styled revision between the renamed and the edited.
- `internal/mapatest/` — the gates of spec §11, from the outside.
`browser_test.go` is behind the `browser` tag.
- `scripts/preview/`, `scripts/mutate/` — `make preview`, `make mutate`.
diff --git a/copy-review/import-looks/result.json b/copy-review/import-looks/result.json
new file mode 100644
index 0000000..6f443b9
--- /dev/null
+++ b/copy-review/import-looks/result.json
@@ -0,0 +1,53 @@
+{
+ "action": "approve",
+ "guidance": null,
+ "note": "Reviewed 2026-11-22 by Luna (gpt-5.6-luna through Codex). Luna's edits are applied: the report says Banners, Mapa's word, for what Notion calls covers.",
+ "not_applied": [],
+ "strings": [
+ {
+ "id": "report.icons",
+ "text": "Icons imported",
+ "was": null
+ },
+ {
+ "id": "report.icons.not",
+ "text": "Icons not imported",
+ "was": null
+ },
+ {
+ "id": "report.covers",
+ "text": "Banners imported",
+ "was": "Covers imported"
+ },
+ {
+ "id": "report.covers.not",
+ "text": "Banners not imported",
+ "was": "Covers not imported"
+ },
+ {
+ "id": "look.emoji",
+ "text": "not in Mapa's emoji list",
+ "was": "an emoji Mapa doesn't have"
+ },
+ {
+ "id": "look.iconset",
+ "text": "from Notion's icon set or another website",
+ "was": null
+ },
+ {
+ "id": "look.elsewhere",
+ "text": "from another website",
+ "was": null
+ },
+ {
+ "id": "look.iconlarge",
+ "text": "too large for an icon (over 128 KB or 512 pixels on a side)",
+ "was": "too large for an icon (over 128 KB or 512 pixels)"
+ },
+ {
+ "id": "loss.widths",
+ "text": "Column widths",
+ "was": null
+ }
+ ]
+}
\ No newline at end of file
diff --git a/copy-review/import-looks/strings.json b/copy-review/import-looks/strings.json
new file mode 100644
index 0000000..2d30666
--- /dev/null
+++ b/copy-review/import-looks/strings.json
@@ -0,0 +1,74 @@
+[
+ {
+ "id": "report.icons",
+ "section": "Import report",
+ "label": "report.icons",
+ "text": "Icons imported",
+ "context": "A row label in the import report's detail list: how many Notion page icons became Mapa page icons. A number follows.",
+ "notes": ""
+ },
+ {
+ "id": "report.icons.not",
+ "section": "Import report",
+ "label": "report.icons.not",
+ "text": "Icons not imported",
+ "context": "Row label: page icons not brought across, by reason ('reason: count; reason: count'), or 0.",
+ "notes": ""
+ },
+ {
+ "id": "report.covers",
+ "section": "Import report",
+ "label": "report.covers",
+ "text": "Covers imported",
+ "context": "Row label: how many Notion page covers became Mapa page banners. A number follows.",
+ "notes": ""
+ },
+ {
+ "id": "report.covers.not",
+ "section": "Import report",
+ "label": "report.covers.not",
+ "text": "Covers not imported",
+ "context": "Row label: page covers not brought across, by reason, or 0.",
+ "notes": ""
+ },
+ {
+ "id": "look.emoji",
+ "section": "Import report",
+ "label": "look.emoji",
+ "text": "an emoji Mapa doesn't have",
+ "context": "A reason in the Notion import's report, after 'Icons not imported:' or 'Covers not imported:', followed by ': <count>'. Several reasons are joined with '; '. The page's Notion icon is an emoji outside Mapa's emoji list.",
+ "notes": ""
+ },
+ {
+ "id": "look.iconset",
+ "section": "Import report",
+ "label": "look.iconset",
+ "text": "from Notion's icon set or another website",
+ "context": "A reason in the Notion import's report, after 'Icons not imported:' or 'Covers not imported:', followed by ': <count>'. Several reasons are joined with '; '. The icon is one of Notion's own built-in icons (SVG, which Mapa refuses) or a picture at another web address, which the import never fetches.",
+ "notes": ""
+ },
+ {
+ "id": "look.elsewhere",
+ "section": "Import report",
+ "label": "look.elsewhere",
+ "text": "from another website",
+ "context": "A reason in the Notion import's report, after 'Icons not imported:' or 'Covers not imported:', followed by ': <count>'. Several reasons are joined with '; '. A cover that is a picture at another web address (Unsplash and the like), which the import never fetches. Notion's own cover gallery is fetched.",
+ "notes": ""
+ },
+ {
+ "id": "look.iconlarge",
+ "section": "Import report",
+ "label": "look.iconlarge",
+ "text": "too large for an icon (over 128 KB or 512 pixels)",
+ "context": "A reason in the Notion import's report, after 'Icons not imported:' or 'Covers not imported:', followed by ': <count>'. Several reasons are joined with '; '. The uploaded icon or custom emoji is over the icon limits. In Mapa the person can upload a smaller one, which Mapa's picker scales.",
+ "notes": ""
+ },
+ {
+ "id": "loss.widths",
+ "section": "Import report",
+ "label": "loss.widths",
+ "text": "Column widths",
+ "context": "A row in the import report's list of things Notion had that Mapa does not keep, followed by a count: Notion columns of different widths become Mapa columns of equal width.",
+ "notes": ""
+ }
+]
\ No newline at end of file
diff --git a/docs/superpowers/specs/2026-11-17-notion-import.md b/docs/superpowers/specs/2026-11-17-notion-import.md
index 14dfb83..3b46d14 100644
--- a/docs/superpowers/specs/2026-11-17-notion-import.md
+++ b/docs/superpowers/specs/2026-11-17-notion-import.md
@@ -249,7 +249,7 @@ The run's report is for importers only. It unseals titles to show them.
- Its body is the mapped blocks (§10), with the parent line first (§9.4).
- Its title is the Notion title, made to fit (§9.2).
- Its sealed record carries the Notion times (§14).
-- The page's icon and cover are not imported. They are counted.
+- The page's icon and cover are imported as its look (columns and icons spec §6.1). An icon or cover Mapa cannot hold is counted. *(Amended by the columns and icons spec, `2026-11-22-mapa-columns-icons.md`, §6.6.)*
- Notion returns at most 25 mentions inside a title on the page object. A title at that limit is read in full from the page property endpoint (`GET /v1/pages/{id}/properties/title`), which M4's path pin allows.
### 9.2 Titles
@@ -316,7 +316,10 @@ Mapa has no tree. Notion's tree becomes links, both ways:
| `code` | a fence: ```` ``` ```` plus the language (lowercased, spaces to `-`; `plain text` gives none). If the code holds a line starting ```` ``` ```` after any leading spaces (the closing test trims them all: `blocks.go`, and `markup.mjs`'s port), the fence is `~~~`. If it holds both, the block is written as a placeholder with the code in it (counted). The caption, if any, follows as an `*italic*` paragraph | — |
| `divider` | `---` | — |
| `table`, `table_row` | pipe-table text, one paragraph: a header row, a `\| --- \|` row when Notion marks a header, then one line per row. Mapa shows it as lines of text (level-up D10); a future vault export (base decision 15, not built) would render it as a table. A cell's line breaks become spaces; a `\|` inside a cell becomes `/` | layout, column and row header styling. A table that needs sorting or typed columns belongs in Fichas |
-| `column_list`, `column` | each column's blocks in order, left to right | side-by-side layout (counted) |
+| `column_list`, `column`, two to four columns | a column layout (columns and icons spec §1): `:::: columns`, each column as `::: column` … `:::` holding its blocks in order, then `::::` | the widths, when they differ (counted) |
+| `column_list` with one column | its blocks, in place | — |
+| `column_list` with five or more columns | each column's blocks in order, left to right | side-by-side layout (counted) |
+| `column_list` inside a column, at any depth | its columns' blocks in order, inside the outer column | the inner layout (counted) |
| `tab` (a tabbed container) | each tab in order: its label as a `**bold**` paragraph, then its blocks | the tabs (counted) |
| `synced_block`, original | its children, in place | that it is synced (counted) |
| `synced_block`, copy | the original's children, in place. **Unverified:** Notion's reference says a copy's children "will be mirrored", and does not say what reading a copy's children returns. The mapper reads the copy's children, and if that is empty or 404s, reads the original's (`synced_from.block_id`). If the original is not shared, a placeholder. §19 step 3 checks against a recording | that it is synced; each copy is its own text from now on (counted) |
@@ -396,6 +399,8 @@ Each placeholder's Notion id is recorded, sealed, on the ledger row, so phase 2
### 11.4 Literal text Mapa would read as markup (D16)
+*Amended by the columns and icons spec §6.6: a fence line (`markup.FenceLike`: `:::` after any spaces) is checked on every line, the first and every hard-break continuation, and written with U+200B before its first `:`.*
+
Mapa has **no escapes** (level-up D11). The editor accepts that because a person typing `*word*` sees what it becomes. An import has nobody watching, and Notion text that discusses Markdown or code is ordinary. Left alone, a Notion line beginning ```` ``` ```` would open a fence that runs to the end of the page (`markup/blocks.go`: an unclosed fence has no end), and two stray backticks would pair up and swallow a link between them (`markup/spans.go`, `codeSpan`).
**"Meant" is computed first.** Before writing a block, the mapper decides what it means: the block's kind and level, its task box if it is a to-do, its lines, and its inline parts (literal text, marks, links, mentions, code spans). The check (D9) compares `markup.Parse`, `markup.Spans` and the task box (`render.go`'s `taskBox`) of the written block with that, part for part. Literal text must parse as literal text.
@@ -524,7 +529,7 @@ The import writes pages only through two methods in package `mapa`, each **one `
## 15. Sealing
-**New purposes:** `notion.token`, `notion.workspace` (its name and id), `notion.coordinate` (a row's Notion id, its Mapa page id, the revision the import last wrote, the ids it mentioned that were not imported, its placeholders' ids), `notion.staged` (a surveyed tree), `notion.image` (an image block's id, its file's key (§25 note 17) and Mapa image). Print keys are derived apart, as base build note 21 does: `oficina/mapa:print:notion.page` and `…:notion.image`.
+**New purposes:** `notion.token`, `notion.workspace` (its name and id), `notion.coordinate` (a row's Notion id, its Mapa page id, the revision the import last wrote, the ids it mentioned that were not imported, its placeholders' ids, and, for a root of the import, its sealed `pin` mark: columns and icons spec §6.3), `notion.staged` (a surveyed tree), `notion.image` (an image block's id, its file's key (§25 note 17) and Mapa image). Print keys are derived apart, as base build note 21 does: `oficina/mapa:print:notion.page` and `…:notion.image`.
**New tables and their plaintext,** to be added to base §4's list and to `plaintext_test.go` with the build:
@@ -533,7 +538,7 @@ The import writes pages only through two methods in package `mapa`, each **one `
| `notion_connections` (one row) | `id`, `created_by` (member id), `created_at`, `verified_at` | token, workspace name | that a Notion connection exists, who made it, when it was last checked |
| `notion_runs` | `id`, `actor`, `state`, `lease` (random, redrawn on start, resume and Stop), `started_at`, `heartbeat_at`, `progress_at`, `finished_at`, the counters, `error_code` | — | when imports ran, who ran them, how many pages each created, kept, failed. The lease is random and says nothing |
| `notion_pages` (the map) | `id`, `notion_print` (unique), `state`, `error_code`, `surveyed_run`, `seen_run` | the coordinate record (Notion id, last Notion title, Mapa page id, last written revision, unresolved mention ids, placeholder ids); the staged tree | how many Notion pages exist and their states |
-| `notion_images` | `id`, `place_print` (unique: an HMAC of the Notion block id and the **Notion** page id together, which the map pins to one Mapa page; §25.7), `block_print` (an HMAC of the block id alone, not unique, to find a block that moved or is shown on several pages), `state` (`imported`, `refused`; a transient failure keeps no row, so the next run tries again) | the image record (block id, the file's key (§25 note 17), Mapa page id, public id, refusal reason) | how many images were imported, refused and failed, and, through equal `block_print`s, how many Notion images appear on more than one page. The images spec's own `images` table holds the rest (§12) |
+| `notion_images` | `id`, `place_print` (unique: an HMAC of the Notion block id and the **Notion** page id together, which the map pins to one Mapa page; §25.7; and one row each for a page's icon and cover, whose place print is of the pseudo-block `icon:` or `cover:` and the Notion page id: columns and icons spec §6.1), `block_print` (an HMAC of the block id alone, not unique, to find a block that moved or is shown on several pages), `state` (`imported`, `refused`; a transient failure keeps no row, so the next run tries again) | the image record (block id, the file's key (§25 note 17), Mapa page id, public id, refusal reason) | how many images were imported, refused and failed, and, through equal `block_print`s, how many Notion images appear on more than one page. The images spec's own `images` table holds the rest (§12) |
- **What the file still shows, said plainly.** The coordinate is sealed, so no column joins a ledger row to a Mapa page. **But the plaintext event log does.** A run's `created` events, by the run's actor, inside the run's window in `notion_runs`, mark which team pages it made, and sequential `pages.id` and `notion_pages.id` in survey order line them up row for row. So the file shows **which team pages came from a Notion import, and roughly their order in Notion**. It does not show their titles, bodies or Notion ids. This goes in the leak list. `notion_pages` carries no `updated_at`, which would be a second join.
- **Prints are HMACs under the instance key**, equality only, as every print in Mapa (base §4).
diff --git a/docs/superpowers/specs/2026-11-22-mapa-columns-icons.md b/docs/superpowers/specs/2026-11-22-mapa-columns-icons.md
index a264e52..9a392ca 100644
--- a/docs/superpowers/specs/2026-11-22-mapa-columns-icons.md
+++ b/docs/superpowers/specs/2026-11-22-mapa-columns-icons.md
@@ -792,3 +792,12 @@ Fable found every round-1 finding answered in substance, and five mediums and si
- **P6, gates.** IN1 and IN2 (`inside_test.go`); IN3 (the private In: line, and `/p/{id}/inside` a 404 for a private or missing page), IN4, IN6 and IN7 (a cycle, 51 children, indents stopping at four levels, the 200-row cap with its link) in `mapatest/inside_test.go`, with IN8's server half (a page shown twice: three distinct list ids, each named by an `aria-controls`, one lit row); IN5 (no move and no shift on mounting, with the cookie set) and IN8 (→ and ←, a page shown twice toggled by script, focus on the arrow pressed, axe) in `inside_browser_test.go`; I23 (`import_pins_test.go`: the report, a full sidebar, an earlier run's roots with one already pinned, a failed parent's child, Resume by another member) and I17's crash list gaining `pin:marked` and `write:pinned`, each resumed run pinning every root once; gate 8 drives `POST /view/open`; two mutations (a private In: line counts; a root offered every run), both caught. Luna's wording applied (`copy-review/inside`).
- **P7, Fable on the build, round 1 (`0b7cf66`), CHANGES REQUIRED with no High.** Answered: list ids that a script toggle could repeat (M1), the wrong row swapped for a page shown twice (M2), `aria-current` doubled or lost after a toggle (M3), → and ← (M4), the gates above (M5), a failed parent's children taken for roots (M6), a root already pinned reported as having no slot (M7); lows 8, 10 to 17. Not done: low 9, the report's "your" for an importer who is not the run's actor: the marks do not record whose sidebar took the pins, and Resume by another member is rare.
+### Phase 4: the importer's icons, covers and widths (`feat/import-looks`, and the notion module's `feat/looks`)
+
+- **F1, the module.** `Icon.URL` (file, external, custom_emoji), `Page.Cover {Type, URL}` in place of `HasCover`, and `Block.WidthRatio`, each read from Notion's documented shapes (`notiontest.AddLooks`, `TestPageLooksDecode`); no real recording was made, as §6.5's two unverified points (a custom emoji's host, `width_ratio` on a column read) await §19's first real run. Q5: the file transport pins `www.notion.so` to `/images/page-cover/` only; M5 refuses every other path on that host, and two mutations (the pair removed, the host pinned alone) are caught.
+- **F2, the staged tree.** `notionmd.Page` holds the look under new keys (`pageIcon`, `pageCover`), so a tree staged before this decodes with none, and that page's look comes on its next run. The mapper writes nothing of the look and no longer counts it; it counts `column_widths` when a layout's columns' ratios differ (a column with none is an even share).
+- **F3, the look before the write.** `import_looks.go` prepares the icon and the cover after the page's images and before its transaction, under §12's rules: the page object read again for a fresh URL, the lease checked before each add, a refusal the page's count and never its failure. An emoji goes through `EmojiIcon`'s check. An icon is fetched with a 128 KiB cap, and one over 512 pixels a side is discarded at once and remembered as refused. A cover is fetched when it is Notion-hosted or the pin allows its address. The look's added images and places join the page's images, so a kept or failed page discards them and a written page keeps their `notion_images` rows in its own transaction.
+- **F4, the writes.** `ImportCreate` writes the record with its icon and banner (centred, `Y: 50`), and its commit attaches them. `ImportUpdate` writes renamed, styled, edited, each only when needed, in one transaction (`update:styled` is a new crash point); the styled revision carries drafts as a rename's does. "Unchanged" compares the look too. A page this run prepared no look for (a fix-up after a Resume) keeps its own.
+- **F5, the report.** "Icons imported", "Icons not imported" by reason, "Banners imported" and "Banners not imported" (Luna: Mapa's word for what Notion calls a cover), and "Column widths" among the losses; the old "Page icons" and "Page covers" losses are gone (an old run's report shows them by key). Luna's wording applied (`copy-review/import-looks`).
+- **F6, gates.** I20 and I25 (`TestI20IconsAreImported`: emoji, custom emoji and uploaded icons imported; Notion's set, an emoji Mapa lacks, an icon too wide, a download that fails and a custom emoji on an unpinned host counted, the page written each time); I21 (`TestI21CoversAreImportedFromThePinOnly`); I22 is COL11 plus the width goldens; I24 (`TestI24ALookChangedInNotionIsStyled`, `TestI24RenamedStyledEditedInOrder`, and I17's re-run crash case now renaming, restyling and editing at every crash point). Four mutations, all caught. The import spec's §9.1, §10, §11.4 and §15 say what this spec changed.
+
diff --git a/go.mod b/go.mod
index 7c11c8c..2d0fa33 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ toolchain go1.26.11
require (
amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2
- amadan.net/oficina/notion.git v0.0.0-20261122111155-169302d88bbe
+ amadan.net/oficina/notion.git v0.0.0-20261122193726-d36f6e0f6101
amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc
github.com/chromedp/cdproto v0.158.6
github.com/chromedp/chromedp v0.21.0
diff --git a/go.sum b/go.sum
index 1ba473a..a6f1ef7 100644
--- a/go.sum
+++ b/go.sum
@@ -2,6 +2,8 @@ amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2 h1:E2+IhBdGcjhX
amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8=
amadan.net/oficina/notion.git v0.0.0-20261122111155-169302d88bbe h1:rTQZz9FJ7tQ7p5adMGNzjFLg6hpplF2NQewgtaQs3ac=
amadan.net/oficina/notion.git v0.0.0-20261122111155-169302d88bbe/go.mod h1:2WuyjBTLHwurTGri00zfPxSKc9b3pomdT6wSs/UIvA4=
+amadan.net/oficina/notion.git v0.0.0-20261122193726-d36f6e0f6101 h1:EdCkiWKC2PrZuiFEIeSrT4YH3E2Js4d1PKI37kG1qZ8=
+amadan.net/oficina/notion.git v0.0.0-20261122193726-d36f6e0f6101/go.mod h1:2WuyjBTLHwurTGri00zfPxSKc9b3pomdT6wSs/UIvA4=
amadan.net/rastrillo/fiesta v1.3.0 h1:7SsHw4aeWPLStR3RHFEEtX4CwqKu+Ig3PgNX8FvD8WM=
amadan.net/rastrillo/fiesta v1.3.0/go.mod h1:LpO391W1dIRUxOIKklHm+bGyWXtlFyBRRPQCysb9LjY=
amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc h1:QakboVkj9nqA6ZaKXeDVXWLPobQSVvd80ic521aA8/U=
diff --git a/internal/mapa/import_convert.go b/internal/mapa/import_convert.go
index c97c56b..50f3ab8 100644
--- a/internal/mapa/import_convert.go
+++ b/internal/mapa/import_convert.go
@@ -12,10 +12,17 @@ import (
// stagedPage is a surveyed page in notionmd's tree.
func stagedPage(page notion.Page, blocks []notion.Block, parent string,
seq int) notionmd.Page {
- return notionmd.Page{ID: page.ID, Title: convertRuns(page.Title),
+ staged := notionmd.Page{ID: page.ID, Title: convertRuns(page.Title),
Parent: parent, Created: page.CreatedTime,
- Edited: page.LastEditedTime, HasIcon: page.Icon != nil,
- HasCover: page.HasCover, Seq: seq, Blocks: convertBlocks(blocks)}
+ Edited: page.LastEditedTime, Seq: seq, Blocks: convertBlocks(blocks)}
+ if icon := page.Icon; icon != nil {
+ staged.Icon = &notionmd.Look{Type: icon.Type, Emoji: icon.Emoji,
+ URL: icon.URL}
+ }
+ if cover := page.Cover; cover != nil {
+ staged.Cover = &notionmd.Look{Type: cover.Type, URL: cover.URL}
+ }
+ return staged
}
func convertBlocks(blocks []notion.Block) []notionmd.Block {
@@ -35,7 +42,8 @@ func convertBlock(block notion.Block) notionmd.Block {
Unsupported: block.UnsupportedType, Text: convertRuns(block.RichText),
Caption: convertRuns(block.Caption), Checked: block.Checked,
Toggleable: block.Toggleable, Language: block.Language,
- Title: block.Title, URL: block.URL, Expression: block.Expression,
+ WidthRatio: block.WidthRatio,
+ Title: block.Title, URL: block.URL, Expression: block.Expression,
Color: block.Color, Cells: convertCells(block.Cells),
SyncedFrom: block.SyncedFrom,
OriginalUnshared: block.OriginalUnshared,
diff --git a/internal/mapa/import_images.go b/internal/mapa/import_images.go
index 9ca36fe..e4d52d0 100644
--- a/internal/mapa/import_images.go
+++ b/internal/mapa/import_images.go
@@ -42,6 +42,9 @@ type ImageStore interface {
type AddedImage interface {
PublicID() string
Markdown(alt string) string
+ // Side is the image's longer side in pixels: an imported icon over
+ // MaxIconSide is refused (columns and icons spec §6.1).
+ Side() int
}
// errNoImageStore is the images spec's ErrNoImageStore, whose sentence
@@ -53,6 +56,10 @@ type imageCounts struct {
Imported int `json:"imported,omitempty"`
Links int `json:"links,omitempty"`
Failed map[string]int `json:"failed,omitempty"`
+ // Icon and Cover are the page's look (columns and icons spec
+ // §6.1): lookImported, or why not; "" when Notion has none.
+ Icon string `json:"icon,omitempty"`
+ Cover string `json:"cover,omitempty"`
}
// pageImages is one page's prepared images: the line for each hosted
diff --git a/internal/mapa/import_images_store.go b/internal/mapa/import_images_store.go
index 85c49a1..f3e98f6 100644
--- a/internal/mapa/import_images_store.go
+++ b/internal/mapa/import_images_store.go
@@ -24,6 +24,10 @@ type addedImage struct{ image Image }
func (added addedImage) PublicID() string { return added.image.PublicID }
+func (added addedImage) Side() int {
+ return max(added.image.Width, added.image.Height)
+}
+
func (added addedImage) Markdown(alt string) string {
return added.image.Markdown(alt)
}
diff --git a/internal/mapa/import_looks.go b/internal/mapa/import_looks.go
new file mode 100644
index 0000000..a54d47c
--- /dev/null
+++ b/internal/mapa/import_looks.go
@@ -0,0 +1,217 @@
+package mapa
+
+import (
+ "context"
+
+ "amadan.net/oficina/mapa/internal/mapa/notionmd"
+ "amadan.net/oficina/notion.git/notion"
+)
+
+// A Notion page's look (columns and icons spec §6.1): its icon and its
+// cover, prepared with its images, before the page's transaction, under
+// the same rules (import spec §12): a fresh URL from the page object,
+// the lease checked just before each add, a failure the page's own
+// count and never its failure. notion_images keeps where each went,
+// under the pseudo-blocks icon: and cover: on the page, so the file's
+// key decides whether it changed, as for an image block.
+
+// The look's pseudo-blocks in notion_images.
+const (
+ iconPlace = "icon:"
+ coverPlace = "cover:"
+)
+
+// The look's outcomes, in words for the report. lookImported counts;
+// the rest are why not.
+const (
+ lookImported = "imported"
+ lookEmoji = "not in Mapa's emoji list"
+ lookIconSet = "from Notion's icon set or another website"
+ lookElsewhere = "from another website"
+ lookIconLarge = "too large for an icon (over 128 KB or 512 pixels " +
+ "on a side)"
+)
+
+// pageLook is a page's prepared icon and banner, the images it added,
+// and where each went.
+type pageLook struct {
+ icon *Icon
+ banner *Banner
+ added []AddedImage
+ placed []placedImage
+}
+
+// prepareLook prepares a page's icon and cover, counting each.
+func (job *importJob) prepareLook(ctx context.Context, entry *importEntry,
+ counts *imageCounts) (*pageLook, error) {
+ look := &pageLook{}
+ if err := job.prepareIcon(ctx, entry, look, counts); err != nil {
+ return nil, err
+ }
+ return look, job.prepareCover(ctx, entry, look, counts)
+}
+
+func (job *importJob) prepareIcon(ctx context.Context, entry *importEntry,
+ look *pageLook, counts *imageCounts) error {
+ icon := entry.staged.Icon
+ switch {
+ case icon == nil:
+ return nil
+ case icon.Type == notion.IconEmoji:
+ made, err := EmojiIcon(icon.Emoji)
+ if err != nil {
+ counts.Icon = lookEmoji
+ return nil
+ }
+ look.icon, counts.Icon = made, lookImported
+ return nil
+ case icon.Type != notion.IconCustomEmoji && icon.Type != notion.FileHosted:
+ // Notion's own icon set is SVG, which Mapa refuses, and any
+ // other address is never fetched (import D13).
+ counts.Icon = lookIconSet
+ return nil
+ }
+ public, reason, err := job.lookImage(ctx, entry, iconPlace, icon, look)
+ if err != nil || reason != "" {
+ counts.Icon = reason
+ return err
+ }
+ look.icon, counts.Icon = &Icon{Image: public}, lookImported
+ return nil
+}
+
+func (job *importJob) prepareCover(ctx context.Context, entry *importEntry,
+ look *pageLook, counts *imageCounts) error {
+ cover := entry.staged.Cover
+ if cover == nil {
+ return nil
+ }
+ // An external cover is fetched only from Notion's own gallery, the
+ // one address the file transport pins for it (Q5).
+ if cover.Type != notion.FileHosted && !job.files.Allowed(cover.URL) {
+ counts.Cover = lookElsewhere
+ return nil
+ }
+ public, reason, err := job.lookImage(ctx, entry, coverPlace, cover,
+ look)
+ if err != nil || reason != "" {
+ counts.Cover = reason
+ return err
+ }
+ // The API gives no position: centred.
+ look.banner, counts.Cover = &Banner{Image: public, Y: 50},
+ lookImported
+ return nil
+}
+
+// lookImage is an icon's or a cover's image: its last place reused when
+// Notion still shows the same file and the page still holds the image,
+// a permanent refusal remembered, or a fresh download.
+func (job *importJob) lookImage(ctx context.Context, entry *importEntry,
+ pseudo string, given *notionmd.Look, look *pageLook) (string, string,
+ error) {
+ placed := placedImage{page: entry.staged.ID, block: pseudo,
+ key: notion.FileKey(given.URL)}
+ prior, found, err := job.priorPlace(ctx, entry.staged.ID, pseudo)
+ if err != nil {
+ return "", "", err
+ }
+ if found && sameFile(prior.Key, placed.key) {
+ if prior.Reason != "" {
+ placed.reason, placed.permanent = prior.Reason, true
+ look.placed = append(look.placed, placed)
+ return "", prior.Reason, nil
+ }
+ if entry.place.PageID != 0 &&
+ job.images.Held(ctx, prior.PublicID, entry.place.PageID) {
+ placed.publicID = prior.PublicID
+ look.placed = append(look.placed, placed)
+ return prior.PublicID, "", nil
+ }
+ }
+ added, key, why, err := job.addLook(ctx, entry, pseudo)
+ if err != nil {
+ return "", "", err
+ }
+ if key != "" {
+ placed.key = key
+ }
+ if why.text != "" {
+ placed.reason, placed.permanent = why.text, why.permanent
+ look.placed = append(look.placed, placed)
+ return "", why.text, nil
+ }
+ placed.publicID = added.PublicID()
+ look.added = append(look.added, added)
+ look.placed = append(look.placed, placed)
+ return placed.publicID, "", nil
+}
+
+// addLook downloads an icon or a cover and adds it, and answers the key
+// of the file it downloaded. An icon over 512 pixels a side is taken
+// away again at once: Mapa never decodes pixels, so it cannot scale one
+// down (§6.1).
+func (job *importJob) addLook(ctx context.Context, entry *importEntry,
+ pseudo string) (AddedImage, string, refusal, error) {
+ if job.imagesStopped == "" {
+ if err := job.images.Ready(ctx); err != nil {
+ job.imagesStopped = errNoImageStore.Error()
+ }
+ }
+ if job.imagesStopped != "" {
+ return nil, "", refusal{text: job.imagesStopped}, nil
+ }
+ if err := job.store.bookkeep(ctx, job.lease, noChange); err != nil {
+ return nil, "", refusal{}, err
+ }
+ data, key, why, err := job.downloadLook(ctx, entry.staged.ID, pseudo)
+ if err != nil || why.text != "" {
+ return nil, key, why, err
+ }
+ if err := job.store.bookkeep(ctx, job.lease, noChange); err != nil {
+ return nil, "", refusal{}, err
+ }
+ added, err := job.images.Add(ctx, job.who, data)
+ if why = job.storeRefusal(err); why.text != "" {
+ return nil, key, why, nil
+ }
+ if pseudo == iconPlace && added.Side() > MaxIconSide {
+ if err := job.images.Discard(ctx, job.who,
+ []AddedImage{added}); err != nil {
+ return nil, "", refusal{}, err
+ }
+ return nil, key, refusal{text: lookIconLarge, permanent: true}, nil
+ }
+ return added, key, refusal{}, nil
+}
+
+// downloadLook reads the page object again for a fresh URL and fetches
+// the icon's or the cover's file through the pinned transport.
+func (job *importJob) downloadLook(ctx context.Context, pageID,
+ pseudo string) ([]byte, string, refusal, error) {
+ page, err := job.client.Page(ctx, pageID)
+ if err != nil {
+ return nil, "", refusal{text: fetchReason(err)}, finalOnly(err)
+ }
+ address, limit := "", int64(imageCap)
+ switch {
+ case pseudo == iconPlace && page.Icon != nil:
+ address, limit = page.Icon.URL, MaxIconBytes
+ case pseudo == coverPlace && page.Cover != nil:
+ address = page.Cover.URL
+ }
+ if address == "" {
+ return nil, "", refusal{text: fetchReason(nil)}, nil
+ }
+ key := notion.FileKey(address)
+ data, err := job.files.Fetch(ctx, address, limit)
+ if err != nil {
+ large := notion.CodeOf(err) == notion.CodeTooLarge
+ text := fetchReason(err)
+ if large && pseudo == iconPlace {
+ text = lookIconLarge
+ }
+ return nil, key, refusal{text: text, permanent: large}, nil
+ }
+ return data, key, refusal{}, nil
+}
diff --git a/internal/mapa/import_looks_test.go b/internal/mapa/import_looks_test.go
new file mode 100644
index 0000000..d5bb86c
--- /dev/null
+++ b/internal/mapa/import_looks_test.go
@@ -0,0 +1,242 @@
+package mapa
+
+import (
+ "bytes"
+ "image"
+ "image/color"
+ "image/png"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/notion.git/notiontest"
+)
+
+// I20, I21 and I25 (columns and icons spec §6.1, §9): a Notion page's
+// icon and cover become its look, through the pinned file transport;
+// what Mapa cannot hold is counted, and the page is written without it.
+
+// widePicture is a PNG of one colour, small in bytes and w×h in pixels.
+func widePicture(t *testing.T, width, height int) []byte {
+ t.Helper()
+ canvas := image.NewRGBA(image.Rect(0, 0, width, height))
+ for column := range width {
+ for line := range height {
+ canvas.Set(column, line, color.RGBA{10, 20, 30, 255})
+ }
+ }
+ var out bytes.Buffer
+ if err := png.Encode(&out, canvas); err != nil {
+ t.Fatal(err)
+ }
+ return out.Bytes()
+}
+
+// unhost takes a hosted file away, so its download fails.
+func unhost(ws *notiontest.Workspace, url string) {
+ path := strings.TrimPrefix(url, strings.TrimSuffix(
+ notiontest.HostedPrefix, "/"))
+ path, _, _ = strings.Cut(path, "?")
+ delete(ws.Files, path)
+}
+
+// looksWorld is a workspace with every look AddLooks makes, plus an
+// emoji Mapa lacks, an icon too wide, and an icon whose file is gone.
+func looksWorld(t *testing.T) (*importWorld, notiontest.Looks) {
+ ws := notiontest.NewWorkspace("looks")
+ looks := ws.AddLooks(picture(t, 1), picture(t, 2))
+ odd := ws.Page("", notiontest.Text("Odd emoji"))
+ ws.SetIcon(odd, notiontest.EmojiIcon("A"))
+ wide := ws.Page("", notiontest.Text("Wide icon"))
+ ws.SetIcon(wide, notiontest.FileIcon(ws.Host("wide.png",
+ widePicture(t, 600, 10))))
+ gone := ws.Page("", notiontest.Text("Lost icon"))
+ lost := ws.Host("lost.png", picture(t, 3))
+ ws.SetIcon(gone, notiontest.FileIcon(lost))
+ unhost(ws, lost)
+ // I25: a custom emoji on a host the transport does not pin.
+ foreign := ws.Page("", notiontest.Text("Foreign emoji"))
+ ws.SetIcon(foreign, notiontest.CustomEmojiIcon("far",
+ "https://example.com/far.png"))
+ world := newImportWorld(t, ws)
+ world.useImages()
+ world.connect(ana)
+ return world, looks
+}
+
+func (world *importWorld) lookOf(title string) (Page, Record) {
+ world.t.Helper()
+ page, record, ok := world.pageTitled(title)
+ if !ok {
+ world.t.Fatalf("no page %q", title)
+ }
+ return page, record
+}
+
+// I20 and I25, icons: one on a host the transport does not pin is
+// refused before dialling, and counted.
+//
+// Mutation (make mutate): an emoji icon written without the list's
+// check.
+func TestI20IconsAreImported(t *testing.T) {
+ world, _ := looksWorld(t)
+ run := world.importAs(ana)
+ if run.State != runDone || run.Failed != 0 {
+ t.Fatalf("the run: %+v", run)
+ }
+ if _, record := world.lookOf("Emoji icon"); record.Icon == nil ||
+ record.Icon.Emoji != "🚀" {
+ t.Errorf("the emoji icon: %+v", record.Icon)
+ }
+ for _, title := range []string{"Custom emoji icon", "Uploaded icon"} {
+ page, record := world.lookOf(title)
+ if record.Icon == nil || record.Icon.Image == "" {
+ t.Errorf("%s: icon %+v", title, record.Icon)
+ continue
+ }
+ if attached, _ := world.imagesOf(page.ID); attached != 1 {
+ t.Errorf("%s: %d images attached", title, attached)
+ }
+ }
+ for _, title := range []string{"Notion icon", "Odd emoji", "Wide icon",
+ "Lost icon", "Foreign emoji"} {
+ if _, record := world.lookOf(title); record.Icon != nil {
+ t.Errorf("%s was given an icon: %+v", title, record.Icon)
+ }
+ }
+ if _, pending := world.imagesOf(0); pending != 0 {
+ t.Errorf("%d images left pending: the wide icon holds none", pending)
+ }
+ report, _ := world.store.report(ctx(), run)
+ want := map[string]int{lookIconSet: 1, lookEmoji: 1, lookIconLarge: 1,
+ "couldn't be downloaded": 1, "not from Notion's file store": 1}
+ if report.Icons != 3 || !sameCounts(report.IconFailures, want) {
+ t.Errorf("the report's icons: %d, %+v", report.Icons,
+ report.IconFailures)
+ }
+}
+
+func sameCounts(got []countView, want map[string]int) bool {
+ if len(got) != len(want) {
+ return false
+ }
+ for _, each := range got {
+ if want[each.Label] != each.Count {
+ return false
+ }
+ }
+ return true
+}
+
+// I21 and I25, covers: an uploaded cover and one from Notion's gallery
+// become banners, centred; an Unsplash cover is counted, never fetched.
+//
+// Mutation (make mutate): an external cover fetched without asking the
+// pin.
+func TestI21CoversAreImportedFromThePinOnly(t *testing.T) {
+ world, _ := looksWorld(t)
+ run := world.importAs(ana)
+ for _, title := range []string{"Uploaded cover", "Gallery cover"} {
+ _, record := world.lookOf(title)
+ if record.Banner == nil || record.Banner.Image == "" ||
+ record.Banner.Y != 50 {
+ t.Errorf("%s: banner %+v", title, record.Banner)
+ }
+ }
+ if _, record := world.lookOf("Unsplash cover"); record.Banner != nil {
+ t.Errorf("an Unsplash cover was imported: %+v", record.Banner)
+ }
+ for _, request := range world.server.Requests() {
+ if request.File && strings.Contains(request.Path, "unsplash") {
+ t.Errorf("fetched %s", request.Path)
+ }
+ }
+ report, _ := world.store.report(ctx(), run)
+ if report.Covers != 2 || !sameCounts(report.CoverFailures,
+ map[string]int{lookElsewhere: 1}) {
+ t.Errorf("the report's covers: %d, %+v", report.Covers,
+ report.CoverFailures)
+ }
+ text := world.importPageText()
+ for _, want := range []string{"Icons imported", "Banners not imported",
+ lookElsewhere} {
+ if !strings.Contains(text, want) {
+ t.Errorf("the report does not say %q", want)
+ }
+ }
+}
+
+// I24, re-runs: an unchanged look downloads nothing and writes nothing;
+// an untouched page whose Notion icon changed gets one styled revision;
+// a page whose icon was changed in Mapa is kept.
+//
+// Mutation (make mutate): "unchanged" decided without the look.
+func TestI24ALookChangedInNotionIsStyled(t *testing.T) {
+ ws := notiontest.NewWorkspace("rerun")
+ looks := ws.AddLooks(picture(t, 1), picture(t, 2))
+ world := newImportWorld(t, ws)
+ world.useImages()
+ world.connect(ana)
+ world.importAs(ana)
+ world.server.Reset()
+ events := world.pageEvents()
+ if run := world.importAs(ana); run.Updated != 0 ||
+ world.fileRequests() != 0 || world.pageEvents() != events {
+ t.Fatalf("an unchanged re-run: %+v, %d fetched", run,
+ world.fileRequests())
+ }
+ ws.SetIcon(looks.Emoji, notiontest.EmojiIcon("🌍"))
+ ws.SetIcon(looks.Custom, notiontest.EmojiIcon("🎉"))
+ mine, _ := world.lookOf("Custom emoji icon")
+ if _, err := world.store.SetLook(ctx(), bo, mine.ID, LookChange{
+ SetIcon: true, Icon: &Icon{Emoji: "📌"}}); err != nil {
+ t.Fatal(err)
+ }
+ world.server.Reset()
+ run := world.importAs(ana)
+ if run.Updated != 1 || run.Kept != 1 {
+ t.Fatalf("after Notion's change: %+v", run)
+ }
+ page, record := world.lookOf("Emoji icon")
+ if record.Icon == nil || record.Icon.Emoji != "🌍" {
+ t.Fatalf("the icon: %+v", record.Icon)
+ }
+ world.expectVerbs(page.ID, VerbCreated, VerbStyled)
+ if _, record := world.lookOf("Custom emoji icon"); record.Icon == nil ||
+ record.Icon.Emoji != "📌" {
+ t.Errorf("a page styled in Mapa lost its icon: %+v", record.Icon)
+ }
+}
+
+// expectVerbs is a page's events' verbs, in order.
+func (world *importWorld) expectVerbs(pageID int64, verbs ...string) {
+ world.t.Helper()
+ var got []string
+ world.store.database.Model(&Event{}).Where("object_kind = ? AND "+
+ "object_id = ?", ObjectPage, pageID).Order("id").Pluck("verb", &got)
+ if strings.Join(got, " ") != strings.Join(verbs, " ") {
+ world.t.Errorf("verbs %v, want %v", got, verbs)
+ }
+}
+
+// I24's order: a page renamed, restyled and edited in Notion gets the
+// three revisions, renamed, styled, edited, in one write.
+func TestI24RenamedStyledEditedInOrder(t *testing.T) {
+ ws := newSmall()
+ world := newImportWorld(t, ws.Workspace)
+ world.connect(ana)
+ world.importAs(ana)
+ ws.Retitle(ws.equipment, notiontest.Text("Kit"))
+ ws.SetIcon(ws.equipment, notiontest.EmojiIcon("💻"))
+ ws.set(ws.equipment, 0, notiontest.Para(notiontest.Text("Phones.")))
+ world.server.Reset()
+ if run := world.importAs(ana); run.Failed != 0 || run.Kept != 0 {
+ t.Fatalf("the re-run: %+v", run)
+ }
+ page, record := world.lookOf("Kit")
+ if record.Icon == nil || record.Icon.Emoji != "💻" ||
+ !strings.Contains(record.Body, "Phones.") {
+ t.Fatalf("the page: %+v", record)
+ }
+ world.expectVerbs(page.ID, VerbCreated, VerbRenamed, VerbStyled,
+ VerbEdited)
+}
diff --git a/internal/mapa/import_report.go b/internal/mapa/import_report.go
index b53cc56..f8711cc 100644
--- a/internal/mapa/import_report.go
+++ b/internal/mapa/import_report.go
@@ -24,10 +24,15 @@ type reportView struct {
FailedCodes []countView
Images imageCounts
ImageFailures []countView
- Losses []countView
- Fallbacks, Neutralised, Unshared, Notion int
- Fitted, Kept, FailedPages, NotFoundPages []reportPage
- Placeholders, UnderRow []reportPage
+ // Icons and Covers are the pages' looks imported, and IconFailures
+ // and CoverFailures why the rest were not, by reason (columns and
+ // icons spec §6.1).
+ Icons, Covers int
+ IconFailures, CoverFailures []countView
+ Losses []countView
+ Fallbacks, Neutralised, Unshared, Notion int
+ Fitted, Kept, FailedPages, NotFoundPages []reportPage
+ Placeholders, UnderRow []reportPage
// Pinned and Unpinned are the roots this run offered to the
// runner's sidebar, read from their sealed pin marks (columns and
// icons spec §6.3): pinned, and those that found no free slot.
@@ -62,6 +67,7 @@ func (store *Store) report(ctx context.Context,
Images: imageCounts{Failed: map[string]int{}}, PinLimit: maxPins}
tally := &reportTally{view: view, store: store, ctx: ctx, run: run.ID,
losses: map[string]int{}, codes: map[string]int{},
+ icons: map[string]int{}, covers: map[string]int{},
byKey: map[string]reportRow{}}
opened := make([]reportRow, 0, len(rows))
for _, row := range rows {
@@ -87,7 +93,9 @@ type reportTally struct {
run int64
losses map[string]int
codes map[string]int
- byKey map[string]reportRow
+ // icons and covers count the looks not imported, by reason.
+ icons, covers map[string]int
+ byKey map[string]reportRow
}
func (tally *reportTally) add(entry reportRow) {
@@ -170,6 +178,8 @@ func (tally *reportTally) render(place coordinate, page reportPage) {
for reason, count := range images.Failed {
view.Images.Failed[reason] += count
}
+ tally.look(images.Icon, &view.Icons, tally.icons)
+ tally.look(images.Cover, &view.Covers, tally.covers)
}
result := place.Render
if result == nil {
@@ -231,9 +241,23 @@ func (tally *reportTally) page(place coordinate) reportPage {
return out
}
+// look counts one page's icon or cover: imported, or why not.
+func (tally *reportTally) look(outcome string, imported *int,
+ why map[string]int) {
+ switch outcome {
+ case "":
+ case lookImported:
+ *imported++
+ default:
+ why[outcome]++
+ }
+}
+
func (tally *reportTally) finish() {
tally.view.FailedCodes = sortedCounts(tally.codes, nil)
tally.view.ImageFailures = sortedCounts(tally.view.Images.Failed, nil)
+ tally.view.IconFailures = sortedCounts(tally.icons, nil)
+ tally.view.CoverFailures = sortedCounts(tally.covers, nil)
tally.view.Losses = sortedCounts(tally.losses, lossLabel)
sort.Strings(tally.view.Databases)
}
@@ -290,6 +314,7 @@ var blockNames = map[string]string{
var lossLabels = map[string]string{
notionmd.LossToggle: "Toggles opened out",
notionmd.LossColumns: "Columns laid out one after another",
+ notionmd.LossWidths: "Column widths",
notionmd.LossTabs: "Tabs laid out one after another",
notionmd.LossSynced: "Synced blocks, now separate copies",
notionmd.LossIndent: "Indented blocks moved to the left",
@@ -303,8 +328,6 @@ var lossLabels = map[string]string{
notionmd.LossMarkStar: "Bold or italic on text holding a *",
notionmd.LossMarkLink: "Bold or italic around a link",
notionmd.LossCodeFence: "Code with both kinds of fence",
- notionmd.LossIcon: "Page icons",
- notionmd.LossCover: "Page covers",
notionmd.LossFile: "Files not imported",
notionmd.LossStartNumber: "List start numbers",
notionmd.LossBlockAnchor: "Links to a block, now to its page",
diff --git a/internal/mapa/import_safety_test.go b/internal/mapa/import_safety_test.go
index 586cb0c..a091275 100644
--- a/internal/mapa/import_safety_test.go
+++ b/internal/mapa/import_safety_test.go
@@ -40,8 +40,8 @@ func TestI16TheImportOnlyReads(t *testing.T) {
// crashPoints is every named point of the run and the two methods.
var crashPoints = []string{"survey:read", "survey:walked",
"write:rendered", "create:page", "create:title", "write:committed",
- "update:renamed", "update:edited", "write:fixed", "pin:marked",
- "write:pinned"}
+ "update:renamed", "update:styled", "update:edited", "write:fixed",
+ "pin:marked", "write:pinned"}
// I17, crash safety (spec §14.1). The process dies between every pair
// of statements in the run, ImportCreate and ImportUpdate, at the first
@@ -73,6 +73,10 @@ func crashThenResume(t *testing.T, point string, nth int, rerun bool) {
world.importAs(ana)
ws.set(ws.handbook, 1, notiontest.Para(notiontest.Text("Changed.")))
ws.Retitle(ws.equipment, notiontest.Text("Kit"))
+ // A new icon too, so the styled revision is between the
+ // renamed and the edited (columns and icons spec I24).
+ ws.SetIcon(ws.equipment, notiontest.EmojiIcon("💻"))
+ ws.set(ws.equipment, 0, notiontest.Para(notiontest.Text("Phones.")))
}
lease, err := world.store.StartRun(ctx(), ana, false)
if err != nil {
diff --git a/internal/mapa/import_set.go b/internal/mapa/import_set.go
index 6fcab1b..341604e 100644
--- a/internal/mapa/import_set.go
+++ b/internal/mapa/import_set.go
@@ -29,6 +29,9 @@ type importEntry struct {
revision int64
result notionmd.Result
images *pageImages
+ // look is the icon and banner this run prepared, or nil when it
+ // prepared none (a fix-up after a Resume): the page keeps its own.
+ look *pageLook
}
// importSet is the run's pages in survey order, and the whole map.
diff --git a/internal/mapa/import_store.go b/internal/mapa/import_store.go
index 5d940c6..4dab7a6 100644
--- a/internal/mapa/import_store.go
+++ b/internal/mapa/import_store.go
@@ -26,6 +26,11 @@ type importWrite struct {
place coordinate
title string
body string
+ // icon and banner are the page's look (columns and icons spec
+ // §6.1): written by ImportCreate, and by ImportUpdate's styled
+ // revision when they changed.
+ icon *Icon
+ banner *Banner
// origin is Notion's created and edited times for the page.
origin Origin
// pageID and expect are ImportUpdate's: the page, and the revision
@@ -60,7 +65,8 @@ func (store *Store) ImportCreate(ctx context.Context,
}
origin := write.origin
page, err = tx.create(KindPage, RungTeam, actor, Record{Title: title,
- Body: cleanBody(write.body), Origin: &origin, Imported: true},
+ Body: cleanBody(write.body), Origin: &origin, Imported: true,
+ Icon: write.icon, Banner: write.banner},
actor, VerbCreated, attachOwn(0))
if err != nil {
return err
@@ -84,7 +90,9 @@ func (store *Store) ImportCreate(ctx context.Context,
// not the one the map holds, or it is gone, it returns ErrImportKept and
// writes nothing (spec §13.2). A new title is its own revision first,
// logged renamed, holding exactly the previous body, with drafts on the
-// old revision carried to it; a new body is a second, logged edited.
+// old revision carried to it; a new look is the next, logged styled,
+// holding the same body (columns and icons spec §6.4); a new body is
+// the last, logged edited.
func (store *Store) ImportUpdate(ctx context.Context,
write importWrite) (Page, error) {
title, err := CleanTitle(write.title)
@@ -111,6 +119,12 @@ func (store *Store) ImportUpdate(ctx context.Context,
if err := crashPoint("update:renamed"); err != nil {
return err
}
+ if err := tx.importStyle(&page, &record, actor, write); err != nil {
+ return err
+ }
+ if err := crashPoint("update:styled"); err != nil {
+ return err
+ }
if err := tx.importEdit(&page, &record, actor, write); err != nil {
return err
}
@@ -155,6 +169,25 @@ func (tx *Tx) importRename(page *Page, record *Record, actor int64,
return tx.carryDrafts(page.ID, from, page.Revision)
}
+// importStyle is the styled revision (columns and icons spec §6.4):
+// the new icon and banner over the body as it stands, attaching the
+// run's own images, with drafts carried as a rename's are.
+func (tx *Tx) importStyle(page *Page, record *Record, actor int64,
+ write importWrite) error {
+ next := *record
+ next.Icon, next.Banner, next.Imported = write.icon, write.banner, true
+ if sameLook(*record, next) {
+ return nil
+ }
+ from := page.Revision
+ if err := tx.commit(page, next, actor, VerbStyled,
+ attachOwn(0)); err != nil {
+ return err
+ }
+ *record = next
+ return tx.carryDrafts(page.ID, from, page.Revision)
+}
+
func (tx *Tx) importEdit(page *Page, record *Record, actor int64,
write importWrite) error {
origin := write.origin
diff --git a/internal/mapa/import_write.go b/internal/mapa/import_write.go
index e9d6aff..9a3cebc 100644
--- a/internal/mapa/import_write.go
+++ b/internal/mapa/import_write.go
@@ -58,7 +58,7 @@ func (job *importJob) writePage(ctx context.Context, set *importSet,
// downloaded for it (Fable L15).
return job.outcome(ctx, entry, state, "", storedImages(entry))
}
- images, err := job.prepareImages(ctx, entry)
+ images, err := job.prepare(ctx, entry)
if err != nil {
return err
}
@@ -89,6 +89,24 @@ func (job *importJob) writePage(ctx context.Context, set *importSet,
return job.outcome(ctx, entry, state, code, images)
}
+// prepare fetches what a page's write needs: its blocks' images, then
+// its look (columns and icons spec §6.1), whose images go where the
+// blocks' do: discarded with them, and their places kept with them.
+func (job *importJob) prepare(ctx context.Context,
+ entry *importEntry) (*pageImages, error) {
+ images, err := job.prepareImages(ctx, entry)
+ if err != nil {
+ return nil, err
+ }
+ if entry.look, err = job.prepareLook(ctx, entry,
+ &images.counts); err != nil {
+ return nil, err
+ }
+ images.added = append(images.added, entry.look.added...)
+ images.placed = append(images.placed, entry.look.placed...)
+ return images, nil
+}
+
// render renders a page within its budget.
func (job *importJob) render(ctx context.Context, set *importSet,
entry *importEntry, images *pageImages) (notionmd.Result, error) {
@@ -146,7 +164,8 @@ func (job *importJob) commit(ctx context.Context, set *importSet,
return job.create(ctx, set, entry, body)
}
if entry.current.Title == entry.title &&
- entry.current.Body == cleanBody(body) {
+ entry.current.Body == cleanBody(body) &&
+ sameLook(entry.current, entry.lookRecord()) {
return mapUnchanged, "", nil
}
return job.update(ctx, set, entry, body)
@@ -204,7 +223,18 @@ func (job *importJob) updateOnce(ctx context.Context, entry *importEntry,
func (entry *importEntry) wrote(page Page, body string) {
entry.place.PageID, entry.place.Revision = page.ID, page.Revision
entry.live, entry.revision = true, page.Revision
- entry.current = Record{Title: entry.title, Body: cleanBody(body)}
+ look := entry.lookRecord()
+ entry.current = Record{Title: entry.title, Body: cleanBody(body),
+ Icon: look.Icon, Banner: look.Banner}
+}
+
+// lookRecord is the look the run writes for a page: the one it
+// prepared, else the page's own (columns and icons spec §6.4).
+func (entry *importEntry) lookRecord() Record {
+ if entry.look == nil {
+ return Record{Icon: entry.current.Icon, Banner: entry.current.Banner}
+ }
+ return Record{Icon: entry.look.icon, Banner: entry.look.banner}
}
// create writes a new page, taking the next title when a member took
@@ -250,8 +280,10 @@ func (job *importJob) writeOf(entry *importEntry, body string) importWrite {
if entry.images != nil {
place.ImageLines, placed = entry.images.lines, entry.images.placed
}
+ look := entry.lookRecord()
return importWrite{lease: job.lease, who: job.who, row: entry.row,
place: place, title: entry.title, body: body,
+ icon: look.Icon, banner: look.Banner,
origin: Origin{Source: "notion", Created: entry.staged.Created,
Edited: entry.staged.Edited},
pageID: place.PageID, expect: place.Revision, images: placed}
diff --git a/internal/mapa/markup/testdata/corpus/import.json b/internal/mapa/markup/testdata/corpus/import.json
index 4665ccd..9725913 100644
--- a/internal/mapa/markup/testdata/corpus/import.json
+++ b/internal/mapa/markup/testdata/corpus/import.json
@@ -23,6 +23,8 @@
{"name":"import/columns-nested","body":":::: columns\n\n::: column\nIn.\n\nSide.\n\n:::\n\n::: column\nRight.\n\n:::\n\n::::"},
{"name":"import/columns-fence-text","body":":::: columns\n\n::: column\n​:::\n\n:::\n\n::: column\n​:::: columns\n\n:::\n\n::::"},
{"name":"import/columns-empty","body":":::: columns\n\n::: column\n:::\n\n::: column\nB.\n\n:::\n\n::::"},
+{"name":"import/columns-widths","body":":::: columns\n\n::: column\nNarrow.\n\n:::\n\n::: column\nWide.\n\n:::\n\n::::"},
+{"name":"import/columns-even","body":":::: columns\n\n::: column\nHalf.\n\n:::\n\n::: column\nHalf too.\n\n:::\n\n::::"},
{"name":"import/tabs","body":"**First tab**\n\nIn it."},
{"name":"import/synced","body":"Synced text.\n\nMirrored."},
{"name":"import/synced-unshared","body":"> From Notion: a synced block whose original wasn't shared with the import."},
diff --git a/internal/mapa/markup/testdata/editor.json b/internal/mapa/markup/testdata/editor.json
index 92b1356..f047906 100644
--- a/internal/mapa/markup/testdata/editor.json
+++ b/internal/mapa/markup/testdata/editor.json
@@ -1,4 +1,4 @@
-{"clean":"b0d984ce1f956c774f79a321085144ac52a390607557172fc2428e00675f1e4e","bodies":[
+{"clean":"71b3d9b6135aaa191ce7b72a00d6f227a65b0254b00888707ab426a2b34e7fc5","bodies":[
{"name":"edge/crlf","body":"# [[Acme]]Titl\n\n- # b\n\n![[fichas:c1]][[Acme#^b1|that]]","blocks":["heading:1","item:bullet_list:0:true","paragraph"]},
{"name":"edge/lone-cr","body":"a\n\n*a\nb*\n\n- ![éééééééééééééééééééé](/i/a1)cword![](/i/a1) [[Acme]]\n- ---d~1. ~~|c\n\na","blocks":["paragraph","paragraph","item:bullet_list:0:true","item:bullet_list:0:false","paragraph"]},
{"name":"edge/mixed-line-endings","body":" ^ab\n\n*word","blocks":["paragraph","paragraph"]},
@@ -164,6 +164,8 @@
{"name":"import/columns-nested","body":":::: columns\n\n::: column\nIn.- \n\nword Side.\n\n:::\n\n::: column\nR[[2026-11-12]]ig[ [ ] ] ht.\n\n:::\n\n::::\n\n#","blocks":["columns","column","paragraph","paragraph","column_end","column","paragraph","column_end","columns_end","paragraph"]},
{"name":"import/columns-fence-text","body":":::: columns\n\n::: column\n​# :::\n\numns\n\n:::\n\n::: column\n​:::: - co\n\n:::\n\n::: column\n:::\n\n::: column\n:::\n\n::::","blocks":["columns","column","paragraph","paragraph","column_end","column","paragraph","column_end","column","column_end","column","column_end","columns_end"]},
{"name":"import/columns-empty","body":":::: columns\n\n::: column\n[ od a\n\n:::\n\n::: column\n![[fichas:c1]]\n\n:::\n\n::::","blocks":["columns","column","paragraph","column_end","column","paragraph","column_end","columns_end"]},
+{"name":"import/columns-widths","body":":::: columns\n\n::: column\nNarrow.\n\n:::\n\n::: column\nWid[ ] \ne[ ] .\n\n[[2026-11-12]]\n\n:::\n\n::::\n\n--","blocks":["columns","column","paragraph","column_end","column","paragraph","paragraph","column_end","columns_end","paragraph"]},
+{"name":"import/columns-even","body":":::: columns\n\n::: column\nHa# lf```.[ ] \n\n:::\n\n::: column\nHalf [[Acme#^b1|that]]too.\n\nHalf [[Acme#^b1|that]]too.\n\n:::\n\n::: column\n]a \n\nHalf [[Acme#^b1|that]]too.\n\nHalf [[Acme#^b1|that]] ^abt![changed](/i/a1)oo.\n\n:::\n\n::::","blocks":["columns","column","paragraph","column_end","column","paragraph","paragraph","column_end","column","paragraph","paragraph","paragraph","column_end","columns_end"]},
{"name":"import/tabs","body":".**Firs**\n**t ta```b**\n\n.**Firs**\n**t tab**.**Firs**\n**t tab**\n\n![[fichas:c1]]```![[fichas:c1]]","blocks":["paragraph","paragraph","paragraph"]},
{"name":"import/synced","body":"ced word word text.\n\nrrrroor*ed~~~*.","blocks":["paragraph","paragraph"]},
{"name":"import/synced-unshared","body":"From Notion: a synced block whose or~~~iginal wasn't shared with **th**e import.From Notion: a synced block whose original wasn","blocks":["paragraph"]},
diff --git a/internal/mapa/markup/testdata/golden.json b/internal/mapa/markup/testdata/golden.json
index 153c9fc..e31cd7b 100644
--- a/internal/mapa/markup/testdata/golden.json
+++ b/internal/mapa/markup/testdata/golden.json
@@ -164,6 +164,8 @@
{"name":"import/columns-nested","body":":::: columns\n\n::: column\nIn.\n\nSide.\n\n:::\n\n::: column\nRight.\n\n:::\n\n::::","blocks":[{"kind":"columns","level":2,"ordered":false,"marker":"","start":0,"end":12,"source":":::: columns","plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":14,"end":24,"source":"::: column","column":1,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":25,"end":28,"source":"In.","column":1,"plain":"In.","spans":[{"kind":"text","text":"In.","target":"","anchor":"","url":"","source":"In."}]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":30,"end":35,"source":"Side.","column":1,"plain":"Side.","spans":[{"kind":"text","text":"Side.","target":"","anchor":"","url":"","source":"Side."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":37,"end":40,"source":":::","column":1,"plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":42,"end":52,"source":"::: column","column":2,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":53,"end":59,"source":"Right.","column":2,"plain":"Right.","spans":[{"kind":"text","text":"Right.","target":"","anchor":"","url":"","source":"Right."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":61,"end":64,"source":":::","column":2,"plain":"","spans":[]},{"kind":"columns_end","level":0,"ordered":false,"marker":"","start":66,"end":70,"source":"::::","plain":"","spans":[]}],"links":[],"images":[],"html":"<div mapa-columns=\"2\"><div mapa-column><p>In.</p><p>Side.</p></div><div mapa-column><p>Right.</p></div></div><p><br class=\"ProseMirror-trailingBreak\"></p>"},
{"name":"import/columns-fence-text","body":":::: columns\n\n::: column\n​:::\n\n:::\n\n::: column\n​:::: columns\n\n:::\n\n::::","blocks":[{"kind":"columns","level":2,"ordered":false,"marker":"","start":0,"end":12,"source":":::: columns","plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":14,"end":24,"source":"::: column","column":1,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":25,"end":31,"source":"​:::","column":1,"plain":"​:::","spans":[{"kind":"text","text":"​:::","target":"","anchor":"","url":"","source":"​:::"}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":33,"end":36,"source":":::","column":1,"plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":38,"end":48,"source":"::: column","column":2,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":49,"end":64,"source":"​:::: columns","column":2,"plain":"​:::: columns","spans":[{"kind":"text","text":"​:::: columns","target":"","anchor":"","url":"","source":"​:::: columns"}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":66,"end":69,"source":":::","column":2,"plain":"","spans":[]},{"kind":"columns_end","level":0,"ordered":false,"marker":"","start":71,"end":75,"source":"::::","plain":"","spans":[]}],"links":[],"images":[],"html":"<div mapa-columns=\"2\"><div mapa-column><p>​:::</p></div><div mapa-column><p>​:::: columns</p></div></div><p><br class=\"ProseMirror-trailingBreak\"></p>"},
{"name":"import/columns-empty","body":":::: columns\n\n::: column\n:::\n\n::: column\nB.\n\n:::\n\n::::","blocks":[{"kind":"columns","level":2,"ordered":false,"marker":"","start":0,"end":12,"source":":::: columns","plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":14,"end":24,"source":"::: column","column":1,"plain":"","spans":[]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":25,"end":28,"source":":::","column":1,"plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":30,"end":40,"source":"::: column","column":2,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":41,"end":43,"source":"B.","column":2,"plain":"B.","spans":[{"kind":"text","text":"B.","target":"","anchor":"","url":"","source":"B."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":45,"end":48,"source":":::","column":2,"plain":"","spans":[]},{"kind":"columns_end","level":0,"ordered":false,"marker":"","start":50,"end":54,"source":"::::","plain":"","spans":[]}],"links":[],"images":[],"html":"<div mapa-columns=\"2\"><div mapa-column><p><br class=\"ProseMirror-trailingBreak\"></p></div><div mapa-column><p>B.</p></div></div><p><br class=\"ProseMirror-trailingBreak\"></p>"},
+{"name":"import/columns-widths","body":":::: columns\n\n::: column\nNarrow.\n\n:::\n\n::: column\nWide.\n\n:::\n\n::::","blocks":[{"kind":"columns","level":2,"ordered":false,"marker":"","start":0,"end":12,"source":":::: columns","plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":14,"end":24,"source":"::: column","column":1,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":25,"end":32,"source":"Narrow.","column":1,"plain":"Narrow.","spans":[{"kind":"text","text":"Narrow.","target":"","anchor":"","url":"","source":"Narrow."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":34,"end":37,"source":":::","column":1,"plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":39,"end":49,"source":"::: column","column":2,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":50,"end":55,"source":"Wide.","column":2,"plain":"Wide.","spans":[{"kind":"text","text":"Wide.","target":"","anchor":"","url":"","source":"Wide."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":57,"end":60,"source":":::","column":2,"plain":"","spans":[]},{"kind":"columns_end","level":0,"ordered":false,"marker":"","start":62,"end":66,"source":"::::","plain":"","spans":[]}],"links":[],"images":[],"html":"<div mapa-columns=\"2\"><div mapa-column><p>Narrow.</p></div><div mapa-column><p>Wide.</p></div></div><p><br class=\"ProseMirror-trailingBreak\"></p>"},
+{"name":"import/columns-even","body":":::: columns\n\n::: column\nHalf.\n\n:::\n\n::: column\nHalf too.\n\n:::\n\n::::","blocks":[{"kind":"columns","level":2,"ordered":false,"marker":"","start":0,"end":12,"source":":::: columns","plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":14,"end":24,"source":"::: column","column":1,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":25,"end":30,"source":"Half.","column":1,"plain":"Half.","spans":[{"kind":"text","text":"Half.","target":"","anchor":"","url":"","source":"Half."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":32,"end":35,"source":":::","column":1,"plain":"","spans":[]},{"kind":"column","level":0,"ordered":false,"marker":"","start":37,"end":47,"source":"::: column","column":2,"plain":"","spans":[]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":48,"end":57,"source":"Half too.","column":2,"plain":"Half too.","spans":[{"kind":"text","text":"Half too.","target":"","anchor":"","url":"","source":"Half too."}]},{"kind":"column_end","level":0,"ordered":false,"marker":"","start":59,"end":62,"source":":::","column":2,"plain":"","spans":[]},{"kind":"columns_end","level":0,"ordered":false,"marker":"","start":64,"end":68,"source":"::::","plain":"","spans":[]}],"links":[],"images":[],"html":"<div mapa-columns=\"2\"><div mapa-column><p>Half.</p></div><div mapa-column><p>Half too.</p></div></div><p><br class=\"ProseMirror-trailingBreak\"></p>"},
{"name":"import/tabs","body":"**First tab**\n\nIn it.","blocks":[{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":0,"end":13,"source":"**First tab**","plain":"**First tab**","spans":[{"kind":"text","text":"**First tab**","target":"","anchor":"","url":"","source":"**First tab**"}]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":15,"end":21,"source":"In it.","plain":"In it.","spans":[{"kind":"text","text":"In it.","target":"","anchor":"","url":"","source":"In it."}]}],"links":[],"images":[],"html":"<p><strong>First tab</strong></p><p>In it.</p>"},
{"name":"import/synced","body":"Synced text.\n\nMirrored.","blocks":[{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":0,"end":12,"source":"Synced text.","plain":"Synced text.","spans":[{"kind":"text","text":"Synced text.","target":"","anchor":"","url":"","source":"Synced text."}]},{"kind":"paragraph","level":0,"ordered":false,"marker":"","start":14,"end":23,"source":"Mirrored.","plain":"Mirrored.","spans":[{"kind":"text","text":"Mirrored.","target":"","anchor":"","url":"","source":"Mirrored."}]}],"links":[],"images":[],"html":"<p>Synced text.</p><p>Mirrored.</p>"},
{"name":"import/synced-unshared","body":"> From Notion: a synced block whose original wasn't shared with the import.","blocks":[{"kind":"quote","level":0,"ordered":false,"marker":"","start":0,"end":75,"source":"> From Notion: a synced block whose original wasn't shared with the import.","plain":"From Notion: a synced block whose original wasn't shared with the import.","spans":[{"kind":"text","text":"From Notion: a synced block whose original wasn't shared with the import.","target":"","anchor":"","url":"","source":"From Notion: a synced block whose original wasn't shared with the import."}]}],"links":[],"images":[],"html":"<blockquote><p>From Notion: a synced block whose original wasn&#39;t shared with the import.</p></blockquote><p><br class=\"ProseMirror-trailingBreak\"></p>"},
diff --git a/internal/mapa/notionmd/blocks.go b/internal/mapa/notionmd/blocks.go
index d2a22d8..29e02a7 100644
--- a/internal/mapa/notionmd/blocks.go
+++ b/internal/mapa/notionmd/blocks.go
@@ -148,6 +148,9 @@ func (mapper *mapper) columns(block Block, _ int) {
}
return
}
+ if unevenWidths(block.Children) {
+ mapper.loss(LossWidths)
+ }
mapper.fence(markup.Columns, ":::: columns")
mapper.inColumn = true
for _, column := range block.Children {
@@ -159,6 +162,23 @@ func (mapper *mapper) columns(block Block, _ int) {
mapper.fence(markup.ColumnsEnd, "::::")
}
+// unevenWidths is columns whose width ratios differ: Mapa's layouts are
+// even, so the widths are counted (columns and icons spec §6.2). A
+// column with no ratio is an even share.
+func unevenWidths(columns []Block) bool {
+ even := 1 / float64(len(columns))
+ for _, column := range columns {
+ ratio := column.WidthRatio
+ if ratio == 0 {
+ ratio = even
+ }
+ if ratio-even > 0.001 || even-ratio > 0.001 {
+ return true
+ }
+ }
+ return false
+}
+
// fence adds one of a layout's fence lines.
func (mapper *mapper) fence(kind, line string) {
mapper.out = append(mapper.out, written{kind: kind, literal: line})
diff --git a/internal/mapa/notionmd/fixtures_blocks_test.go b/internal/mapa/notionmd/fixtures_blocks_test.go
index ea164cc..aee4552 100644
--- a/internal/mapa/notionmd/fixtures_blocks_test.go
+++ b/internal/mapa/notionmd/fixtures_blocks_test.go
@@ -81,6 +81,17 @@ func containerFixtures() []fixture {
page("columns-empty", with(Block{Type: "column_list", Known: true},
Block{Type: "column", Known: true},
with(Block{Type: "column", Known: true}, para(txt("B."))))),
+ // Widths that differ are counted; even ones, given or not, are
+ // not (columns and icons spec §6.2).
+ page("columns-widths", with(Block{Type: "column_list", Known: true},
+ with(Block{Type: "column", Known: true, WidthRatio: 0.25},
+ para(txt("Narrow."))),
+ with(Block{Type: "column", Known: true, WidthRatio: 0.75},
+ para(txt("Wide."))))),
+ page("columns-even", with(Block{Type: "column_list", Known: true},
+ with(Block{Type: "column", Known: true, WidthRatio: 0.5},
+ para(txt("Half."))),
+ with(Block{Type: "column", Known: true}, para(txt("Half too."))))),
page("tabs", with(blk("tab", txt("First tab")), para(txt("In it.")))),
page("synced", with(Block{Type: "synced_block", Known: true},
para(txt("Synced text."))), with(Block{Type: "synced_block",
@@ -109,8 +120,11 @@ func containerFixtures() []fixture {
live(hexID("a1"), "Acme"),
page("database", named(Block{Type: "child_database", Known: true,
Title: "Projects"}, "db-1")),
+ // The look is the runner's: the mapper writes nothing of it
+ // (columns and icons spec §6.1).
{Name: "page-icon-cover", Page: Page{ID: "page-icon",
- HasIcon: true, HasCover: true,
+ Icon: &Look{Type: "emoji", Emoji: "🚀"},
+ Cover: &Look{Type: "external", URL: "https://example.com/c.jpg"},
Blocks: []Block{para(txt("A page with an icon and a cover."))}}},
{Name: "parent-and-date", Page: Page{ID: "page-day",
Blocks: []Block{para(txt("What happened that day."))}},
diff --git a/internal/mapa/notionmd/mapper.go b/internal/mapa/notionmd/mapper.go
index ba9a765..f897832 100644
--- a/internal/mapa/notionmd/mapper.go
+++ b/internal/mapa/notionmd/mapper.go
@@ -24,12 +24,6 @@ func render(page Page, options Options) (Result, error) {
page = normalisePage(page)
mapper := &mapper{options: options,
result: Result{Losses: map[string]int{}}}
- if page.HasIcon {
- mapper.loss(LossIcon)
- }
- if page.HasCover {
- mapper.loss(LossCover)
- }
if options.Parent != "" {
mapper.emit(written{kind: markup.Paragraph, lines: []line{{
fixed("In: "), {kind: wiki, target: options.Parent}}}})
diff --git a/internal/mapa/notionmd/render.go b/internal/mapa/notionmd/render.go
index 4d1d8bf..5032827 100644
--- a/internal/mapa/notionmd/render.go
+++ b/internal/mapa/notionmd/render.go
@@ -91,6 +91,7 @@ const (
LossBlock = "block:" // + the Notion type: a block not imported
LossToggle = "toggle"
LossColumns = "columns"
+ LossWidths = "column_widths"
LossTabs = "tabs"
LossSynced = "synced"
LossIndent = "indent"
@@ -104,8 +105,6 @@ const (
LossMarkStar = "mark_star"
LossMarkLink = "mark_link"
LossCodeFence = "code_fence"
- LossIcon = "icon"
- LossCover = "cover"
LossFile = "file"
LossStartNumber = "start_number"
LossBlockAnchor = "block_anchor"
diff --git a/internal/mapa/notionmd/testdata/fixtures/columns-even.json b/internal/mapa/notionmd/testdata/fixtures/columns-even.json
new file mode 100644
index 0000000..fe22cf1
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/fixtures/columns-even.json
@@ -0,0 +1,53 @@
+{
+ "name": "columns-even",
+ "page": {
+ "id": "page-columns-even",
+ "seq": 0,
+ "blocks": [
+ {
+ "id": "",
+ "type": "column_list",
+ "known": true,
+ "children": [
+ {
+ "id": "",
+ "type": "column",
+ "known": true,
+ "width": 0.5,
+ "children": [
+ {
+ "id": "",
+ "type": "paragraph",
+ "known": true,
+ "text": [
+ {
+ "type": "text",
+ "text": "Half."
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "",
+ "type": "column",
+ "known": true,
+ "children": [
+ {
+ "id": "",
+ "type": "paragraph",
+ "known": true,
+ "text": [
+ {
+ "type": "text",
+ "text": "Half too."
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/internal/mapa/notionmd/testdata/fixtures/columns-widths.json b/internal/mapa/notionmd/testdata/fixtures/columns-widths.json
new file mode 100644
index 0000000..ded32c7
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/fixtures/columns-widths.json
@@ -0,0 +1,54 @@
+{
+ "name": "columns-widths",
+ "page": {
+ "id": "page-columns-widths",
+ "seq": 0,
+ "blocks": [
+ {
+ "id": "",
+ "type": "column_list",
+ "known": true,
+ "children": [
+ {
+ "id": "",
+ "type": "column",
+ "known": true,
+ "width": 0.25,
+ "children": [
+ {
+ "id": "",
+ "type": "paragraph",
+ "known": true,
+ "text": [
+ {
+ "type": "text",
+ "text": "Narrow."
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "id": "",
+ "type": "column",
+ "known": true,
+ "width": 0.75,
+ "children": [
+ {
+ "id": "",
+ "type": "paragraph",
+ "known": true,
+ "text": [
+ {
+ "type": "text",
+ "text": "Wide."
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/internal/mapa/notionmd/testdata/fixtures/page-icon-cover.json b/internal/mapa/notionmd/testdata/fixtures/page-icon-cover.json
index 54d8411..c8a4260 100644
--- a/internal/mapa/notionmd/testdata/fixtures/page-icon-cover.json
+++ b/internal/mapa/notionmd/testdata/fixtures/page-icon-cover.json
@@ -2,8 +2,14 @@
"name": "page-icon-cover",
"page": {
"id": "page-icon",
- "icon": true,
- "cover": true,
+ "pageIcon": {
+ "type": "emoji",
+ "emoji": "🚀"
+ },
+ "pageCover": {
+ "type": "external",
+ "url": "https://example.com/c.jpg"
+ },
"seq": 0,
"blocks": [
{
diff --git a/internal/mapa/notionmd/testdata/golden/columns-even.json b/internal/mapa/notionmd/testdata/golden/columns-even.json
new file mode 100644
index 0000000..6337d24
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/golden/columns-even.json
@@ -0,0 +1,5 @@
+{
+ "result": {
+ "Body": ""
+ }
+}
diff --git a/internal/mapa/notionmd/testdata/golden/columns-even.md b/internal/mapa/notionmd/testdata/golden/columns-even.md
new file mode 100644
index 0000000..8d8cdbf
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/golden/columns-even.md
@@ -0,0 +1,13 @@
+:::: columns
+
+::: column
+Half.
+
+:::
+
+::: column
+Half too.
+
+:::
+
+::::
diff --git a/internal/mapa/notionmd/testdata/golden/columns-widths.json b/internal/mapa/notionmd/testdata/golden/columns-widths.json
new file mode 100644
index 0000000..2a56541
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/golden/columns-widths.json
@@ -0,0 +1,8 @@
+{
+ "result": {
+ "Body": "",
+ "losses": {
+ "column_widths": 1
+ }
+ }
+}
diff --git a/internal/mapa/notionmd/testdata/golden/columns-widths.md b/internal/mapa/notionmd/testdata/golden/columns-widths.md
new file mode 100644
index 0000000..8be89be
--- /dev/null
+++ b/internal/mapa/notionmd/testdata/golden/columns-widths.md
@@ -0,0 +1,13 @@
+:::: columns
+
+::: column
+Narrow.
+
+:::
+
+::: column
+Wide.
+
+:::
+
+::::
diff --git a/internal/mapa/notionmd/testdata/golden/page-icon-cover.json b/internal/mapa/notionmd/testdata/golden/page-icon-cover.json
index 66581d1..6337d24 100644
--- a/internal/mapa/notionmd/testdata/golden/page-icon-cover.json
+++ b/internal/mapa/notionmd/testdata/golden/page-icon-cover.json
@@ -1,9 +1,5 @@
{
"result": {
- "Body": "",
- "losses": {
- "cover": 1,
- "icon": 1
- }
+ "Body": ""
}
}
diff --git a/internal/mapa/notionmd/tree.go b/internal/mapa/notionmd/tree.go
index 03e030b..131efc5 100644
--- a/internal/mapa/notionmd/tree.go
+++ b/internal/mapa/notionmd/tree.go
@@ -18,14 +18,25 @@ type Page struct {
Parent string `json:"parent,omitempty"`
Created string `json:"created,omitempty"`
Edited string `json:"edited,omitempty"`
- // HasIcon and HasCover are counted and not imported (§9.1).
- HasIcon bool `json:"icon,omitempty"`
- HasCover bool `json:"cover,omitempty"`
+ // Icon and Cover are the page's look as Notion gives it (columns and
+ // icons spec §6.1). The runner imports them before the page's write;
+ // the mapper writes nothing of them. Their keys are new: a tree
+ // staged before they were read decodes with none.
+ Icon *Look `json:"pageIcon,omitempty"`
+ Cover *Look `json:"pageCover,omitempty"`
// Seq is the page's place in survey order (§9.2).
Seq int `json:"seq"`
Blocks []Block `json:"blocks,omitempty"`
}
+// Look is a page's icon or cover: Type is Notion's (emoji,
+// custom_emoji, file or external), Emoji an emoji icon's, URL the rest's.
+type Look struct {
+ Type string `json:"type"`
+ Emoji string `json:"emoji,omitempty"`
+ URL string `json:"url,omitempty"`
+}
+
// Block is one block and its children.
type Block struct {
ID string `json:"id"`
@@ -41,6 +52,9 @@ type Block struct {
Checked bool `json:"checked,omitempty"`
Toggleable bool `json:"toggleable,omitempty"`
Language string `json:"language,omitempty"`
+ // WidthRatio is a column's share of its column_list, when Notion
+ // gives one (columns and icons spec §6.2): not imported, counted.
+ WidthRatio float64 `json:"width,omitempty"`
// Color is the block's colour, which the subset cannot say: counted.
Color string `json:"color,omitempty"`
// Emoji is a callout's icon when it is an emoji; IconType names any
diff --git a/internal/mapa/templates/import.html b/internal/mapa/templates/import.html
index 2a6e04c..9dad0c6 100644
--- a/internal/mapa/templates/import.html
+++ b/internal/mapa/templates/import.html
@@ -74,6 +74,10 @@
<dt>Images imported</dt><dd>{{number L .Images.Imported}}</dd>
<dt>Images left as links</dt><dd>{{number L .Images.Links}}</dd>
<dt>Images not imported</dt><dd>{{range $i, $c := .ImageFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
+<dt>Icons imported</dt><dd>{{number L .Icons}}</dd>
+<dt>Icons not imported</dt><dd>{{range $i, $c := .IconFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
+<dt>Banners imported</dt><dd>{{number L .Covers}}</dd>
+<dt>Banners not imported</dt><dd>{{range $i, $c := .CoverFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
<dt>Links to pages not shared with the import</dt><dd>{{number L .Unshared}}</dd>
<dt>Links still pointing at Notion</dt><dd>{{number L .Notion}}</dd>
<dt>Text adjusted so Mapa reads it literally</dt><dd>{{number L .Neutralised}}</dd>
diff --git a/scripts/mutate/import_looks.go b/scripts/mutate/import_looks.go
new file mode 100644
index 0000000..afa5ff1
--- /dev/null
+++ b/scripts/mutate/import_looks.go
@@ -0,0 +1,38 @@
+package main
+
+// The columns and icons spec's mutations for the importer's looks
+// (§6.1, §6.4, §9): an emoji icon written unchecked, an external cover
+// fetched without asking the pin, a look left out of "unchanged", and
+// the styled revision skipped.
+
+const (
+ importLooksGo = "internal/mapa/import_looks.go"
+ importWriteGo = "internal/mapa/import_write.go"
+ importStoreGo = "internal/mapa/import_store.go"
+)
+
+var importLookMutations = []mutation{
+ {gate: "I20", test: "TestI20IconsAreImported", pkg: inside,
+ name: "an emoji icon written without the list's check",
+ edits: []edit{{file: importLooksGo,
+ from: "\t\tmade, err := EmojiIcon(icon.Emoji)",
+ to: "\t\tmade, err := &Icon{Emoji: icon.Emoji}, error(nil)"}}},
+ {gate: "I21", test: "TestI21CoversAreImportedFromThePinOnly", pkg: inside,
+ name: "an external cover fetched without asking the pin",
+ edits: []edit{{file: importLooksGo,
+ from: "\tif cover.Type != notion.FileHosted && " +
+ "!job.files.Allowed(cover.URL) {",
+ to: "\tif false {"}}},
+ {gate: "I24", test: "TestI24ALookChangedInNotionIsStyled", pkg: inside,
+ name: "unchanged decided without the look",
+ edits: []edit{{file: importWriteGo,
+ from: "\t\tentry.current.Body == cleanBody(body) &&\n" +
+ "\t\tsameLook(entry.current, entry.lookRecord()) {",
+ to: "\t\tentry.current.Body == cleanBody(body) {"}}},
+ {gate: "I24", test: "TestI24RenamedStyledEditedInOrder", pkg: inside,
+ name: "ImportUpdate writes no styled revision",
+ edits: []edit{{file: importStoreGo,
+ from: "\t\tif err := tx.importStyle(&page, &record, actor, " +
+ "write); err != nil {",
+ to: "\t\tif err := error(nil); err != nil {"}}},
+}
diff --git a/scripts/mutate/main.go b/scripts/mutate/main.go
index bedbf99..d4480da 100644
--- a/scripts/mutate/main.go
+++ b/scripts/mutate/main.go
@@ -47,6 +47,7 @@ func every() []mutation {
all = append(all, columnMutations...)
all = append(all, mapperMutations...)
all = append(all, importMutations...)
+ all = append(all, importLookMutations...)
return append(all, menuMutations...)
}