notes
All repositories: gitoria
5.5 KB
# Report 003 (w1): markdown tables (notes.worldapi.org#5)**Renderer:** `shared/md-editor.js` is the only Markdown renderer in notes (view, editor, offline; no server-side renderer). It is a vendored copy of the shared component worldapi-components `md-editor.js` (byte-identical before this change, md5 9aecd5c1, as are the copies in tickets). I fixed notes' copy only. Upstream: see "Upstream change" below.**Changed:** the parser, the editor model (block `table`, cells = items), `<table>` render (thin grey lines, no colour, scrolls inside its box), and a verified lossless writer (`\|` escapes). Enter on a typed delimiter row turns the rows into a table. Tab / Shift+Tab / Enter move between cells and add rows; Enter in an empty last row leaves the table. Backspace/Delete never merge a table with its neighbours. Plus 7 new gate checks, the README and the mission brief.**Commits** (branch w1-md-tables): `9acc27f` (code + tests + README) and the report/STATUS/LOG commit after it. Not pushed, not deployed, no `.env` read.**Gate** `tests/browser.mjs` (ports 8701–8709): **50/0** before, **57/0** after (50 old + 7 new). The new tests on the old code fail (crash at "tables: typed to the end").- Component suite (worldapi-components `test/run.mjs`, scratch copy, ports 8714–8719): old 81/0, new 79/2. Both failures are the intended change: a pasted HTML `<table>` now becomes a table instead of the text "c1 c2". New is 81/0 with that one expectation updated.**Screenshots I looked at:** `.scratch/gate-tables-desktop.png` and `.scratch/gate-tables-phone.png`. I cannot display images here, so I read them as ASCII renders plus a pixel colour count.- Desktop: a 3-column grid, header + 2 rows, the header "Note | x" right-aligned.- Phone: the wide column is cut at the box edge and scrolls; the page does not scroll sideways.- 0 saturated pixels.**Real data** (a copy of the live storage, az5b2): all 28 live notes rendered with the old and the new md-editor.- 27 are identical (editor DOM, value, roundTrip, canonical).- 1 differs: `0muh6u7rvy53`, the only note with tables. Its 21 pipe lines became 4 tables (2 columns; 5/2/3/3 rows), and no pipe text is left over.- In the app on the copy, its tables showed 285 ms (desktop) and 96 ms (phone) after the click, inside the box, with no page overflow.- Both versions are lossless on all 28 notes (an untouched editor returns the stored text).- Server answers (realdata-baseline, 294): only `/md-editor.js` differs.- The live-data copies and their outputs have been deleted.**Open issues:**- Upstream (worldapi-components + tickets `markdown.hl`): not done, by design (see below).- `tests/short-id-switch.mjs` was not run: its fixed ports 8720/8721 are outside my slot. It runs no browser and does not touch md-editor.- On the first load with an empty browser copy, opening `/note/<id>` directly did not open the note until it was clicked in the sidebar. I saw this on the data copy and did not investigate it (it may also happen on the old code).## Details### Table syntax (GFM subset)- **Header row:** any line that has a delimiter row under it with the same number of cells.- **Delimiter row:** must contain a `|`. Each cell is `:?-+:?`, and the colons set the alignment: left, center or right.- **Body rows:** go up to a blank line, a heading, a fence or a list item. Missing cells are padded and extra cells are dropped.- **Splitting:** cells are split at every `|` that is not escaped. Inside code spans, `\|` is a pipe too, as in GFM.- **Outer pipes:** optional.- **Paragraphs:** a table can interrupt a paragraph (the lines above it stay a paragraph).- **Writing:** changed tables are written padded to the column widths, e.g. `| :--- | :-: | --: |`.- **Lossless:** an untouched table is written back byte for byte, like every other block.### Typing (what the new gate does with real keys)1. It types `| Item | Qty | Note \| x |` Enter, then `|:---|:---:|---:|` Enter, which makes a table and puts the caret in an empty body row.2. It types `**milk**` Tab `` `2` `` Tab `a|b` Enter `bread` Tab `1` Tab `<long word>` Enter Enter (leaving the table), then `after the table`.3. The line `a | b stays text` stays a paragraph.The 7 new checks:1. The `<table>` has the right cells, alignment (`data-align` and the computed text-align), `<strong>`, `<code>`, a typed pipe, and `\|` in the header.2. The paragraphs around the table are right.3. The Markdown is right.4. After a reload from the server, the table is the same.5. On the phone, the table scrolls inside its box and the page does not overflow.6. Editing one cell changes only that cell.7. Offline (server stopped), the table renders from IndexedDB.### Upstream change (not done here: other app folders are off limits)1. **worldapi-components/md-editor.js:**- Take `shared/md-editor.js` from `9acc27f` as it is.- Update `test/run.mjs` `PASTED`: replace `c1 c2` with `| c1 | c2 |\n| --- | --- |`.- Add table cases to its test page and README (the subset list, the `--md-table-border` variable).2. **tickets:**- `lib/markdown.hl`, the server-side renderer that md-editor's parser is a port of, needs the same table rules (`rowCells`, `unpipe`, `alignsOf`, `tableAt`). Otherwise tickets would show a table in the editor but plain text on the page.- Then re-vendor md-editor.js.3. The same copy goes to the other apps that vendor it.### Process- Ports used: 8701–8719 only.- Every server and Chrome was stopped by its PID. The one other hybriel process running belongs to routger-w12 and was left alone.- Hybriel: no bug found (no `.hl` file changed).
Branches
Latest commits
- 78ba0073notes: an ident access key (Authorization: Bearer idt_…) reads and writes its identity's notes through /api/me and /api/notes; gate tests/ident-access-notes.mjs (ident#27)mre
- 3de46dacnotes: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 73+5 failing → 78 passedmre
- 5909d458notes: MdEditor from components 59704ce (text on the clipboard always pastes, a file manager copy still attaches; pipe rows without a delimiter row; tickets#49, notes#5)mre
- 98bd6a98N5b: pipe rows without a delimiter row are a table (MdEditor ad4e929, plain copy); gate tests/dashboard-table.mjs; reportmre
- dbf93319N5 report: components gate rerun 613 passed, 0 failedmre
- 3a8bc0d2N5: empty Table-button table is written as a real pipe table (MdEditor 4bd1112, plain copy); gate tests/table-button.mjs; reportmre
- c16bd443N5: step 1 report (tables pass locally; his DASHBOARD note has no delimiter row)mre
- 6091320anotes: MdEditor 7437e32 (surface drawn at once when the page is claimed); gate measures claim-to-text on 5 note loads at 1280 and 390mre
- 0aa9277enotes: move each component's styles into its own Style block (shell and header selector in main.hl, list, editor frame and delete question in notes.hl); styles.hl keeps the theme inherit, the accent and the message colour; .gitignore ignores a bin symlink too; tests/shots.mjs for the pixel comparemre
- 9ba01de3notes: write the standby service out in full so the boot gate can read the main servicemre
- 98cab40anotes: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
- 1fadb473notes gate: the editor table now has 1 px cell lines from the notes thememre
- 8762115cnotes: take the components e54f83a (paste as Markdown, text typed before the editor is built is kept, Table button); table lines come from the notes thememre
- ac23e194ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 2804f0d3Merge branch 'iw-ident-widget'mre
- 52d8d242notes: e2e script checks Log out and the selector in the header instead of the user menumre
- e5abf7b7notes header: the selector alone top right plus Log out as before the theme missions; the user icon is gonemre
- a2e343aeident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 7a889b82notes: MdEditor with the Table button, typed pipe rows and the theme's table look (components mt-tables); a table note is named by its header words; gate checks that fail on mainmre
- b96c7f70theme: sync from layouts 4994037 (list rows stack, td word-keep, heading code, edited tap target)mre