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
- 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- edeab20fnotes mission 015: mission, report, LOG, STATUSmre
- 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
- 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre
- 84b574c4notes mission 015: re-vendor plugins from hybriel f9614007 (incl. web, #117)mre
- 447da53dnotes mission 014: report — remaining gates and lisbeth E2E proofmre
- fd9f92c3notes mission 014: report (partial), LOG, STATUSmre
- b2501360notes mission 014: open() sets asking=false before flush(0) (hybriel#196)mre
- 9414ce59notes mission 014: merge theme 76f99f6, components 3794c59, strict single-press openAsk (fails on old open())mre
- c08c655anotes 013: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
- 21c8f65dnotes mission 012: STATUSmre
- 0bbb3dd9notes mission 012: delete section of the browser gate de-flaked (openAsk: calm wait, press again when the question closes by itself); report 012mre
- f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmre
- 1a8603d1notes mission 011 WIP: deploy.sh gate summary also matches check-theme, browser.mjs logout via the user menumre
- dae2e508notes mission 011 WIP: theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ListFirst, styles cut to the app's own, check-theme gate, e2e auditmre
- fd36da27notes mission 010: the note editor is the Hybriel MdEditor block (components.hybriel 1442e58, verbatim); md-editor.js, its route, script tag and offlineFiles retired; gate 66/0, realdata-offline 12/0, round-trip and Chrome E2E tests; report 010mre
- efa92170notes tests/identkit.mjs: refuse a taken ident port, cold-wait deadline, emit, identities; mission 009 reportmre
- f3dec0f1Merge branch 'w7'mre
- d1cf966dre-vendor hybriel 97bcf128: offlineFiles for the editor script, 44 px taps, 390 px offline checks, mission 008mre
- 4a610a21paths: projects moved into /media/STORAGE/projects/WorldAPI/mre