gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit8342cd288342cd28Merge branch 'notes9-no-poll' into mainAtlas8342cd28/reports/003-md-tables.md

5.5 KB

  1. # Report 003 (w1): markdown tables (notes.worldapi.org#5)
  2. **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.
  3. **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.
  4. **Commits** (branch w1-md-tables): `9acc27f` (code + tests + README) and the report/STATUS/LOG commit after it. Not pushed, not deployed, no `.env` read.
  5. **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").
  6. - 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.
  7. **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.
  8. - Desktop: a 3-column grid, header + 2 rows, the header "Note | x" right-aligned.
  9. - Phone: the wide column is cut at the box edge and scrolls; the page does not scroll sideways.
  10. - 0 saturated pixels.
  11. **Real data** (a copy of the live storage, az5b2): all 28 live notes rendered with the old and the new md-editor.
  12. - 27 are identical (editor DOM, value, roundTrip, canonical).
  13. - 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.
  14. - 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.
  15. - Both versions are lossless on all 28 notes (an untouched editor returns the stored text).
  16. - Server answers (realdata-baseline, 294): only `/md-editor.js` differs.
  17. - The live-data copies and their outputs have been deleted.
  18. **Open issues:**
  19. - Upstream (worldapi-components + tickets `markdown.hl`): not done, by design (see below).
  20. - `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.
  21. - 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).
  22. ## Details
  23. ### Table syntax (GFM subset)
  24. - **Header row:** any line that has a delimiter row under it with the same number of cells.
  25. - **Delimiter row:** must contain a `|`. Each cell is `:?-+:?`, and the colons set the alignment: left, center or right.
  26. - **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.
  27. - **Splitting:** cells are split at every `|` that is not escaped. Inside code spans, `\|` is a pipe too, as in GFM.
  28. - **Outer pipes:** optional.
  29. - **Paragraphs:** a table can interrupt a paragraph (the lines above it stay a paragraph).
  30. - **Writing:** changed tables are written padded to the column widths, e.g. `| :--- | :-: | --: |`.
  31. - **Lossless:** an untouched table is written back byte for byte, like every other block.
  32. ### Typing (what the new gate does with real keys)
  33. 1. It types `| Item | Qty | Note \| x |` Enter, then `|:---|:---:|---:|` Enter, which makes a table and puts the caret in an empty body row.
  34. 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`.
  35. 3. The line `a | b stays text` stays a paragraph.
  36. The 7 new checks:
  37. 1. The `<table>` has the right cells, alignment (`data-align` and the computed text-align), `<strong>`, `<code>`, a typed pipe, and `\|` in the header.
  38. 2. The paragraphs around the table are right.
  39. 3. The Markdown is right.
  40. 4. After a reload from the server, the table is the same.
  41. 5. On the phone, the table scrolls inside its box and the page does not overflow.
  42. 6. Editing one cell changes only that cell.
  43. 7. Offline (server stopped), the table renders from IndexedDB.
  44. ### Upstream change (not done here: other app folders are off limits)
  45. 1. **worldapi-components/md-editor.js:**
  46. - Take `shared/md-editor.js` from `9acc27f` as it is.
  47. - Update `test/run.mjs` `PASTED`: replace `c1 c2` with `| c1 | c2 |\n| --- | --- |`.
  48. - Add table cases to its test page and README (the subset list, the `--md-table-border` variable).
  49. 2. **tickets:**
  50. - `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.
  51. - Then re-vendor md-editor.js.
  52. 3. The same copy goes to the other apps that vendor it.
  53. ### Process
  54. - Ports used: 8701–8719 only.
  55. - Every server and Chrome was stopped by its PID. The one other hybriel process running belongs to routger-w12 and was left alone.
  56. - Hybriel: no bug found (no `.hl` file changed).

Branches

Latest commits

  • 8342cd28Merge branch 'notes9-no-poll' into mainAtlas
  • 1f0457a5|||PR make provisional rejected-draft setup deterministicAtlas
  • 996768bf|||PR WIP sequence note creation before provisional-id adoptionAtlas
  • c49ce093|||PR WIP remove notes polling and use framework reachabilityAtlas
  • c028ac61Merge branch 'notes-pr7-kunibert' into mainAtlas
  • 9cc92bdfKeep conflict and history fixes while awaiting queued save supportAtlas
  • a5c27cb6Allow real edits back to earlier text and honor configured identAtlas
  • 15c46ced|||PR Preserve note edits, conflict bases and visible historyAtlas
  • 4c6e0bf6Merge branch 'notes13-day61' into mainAtlas
  • eb51864f|||PR Back/Forward via navigate, server drafts, Hybriel day61Atlas
  • 3537cf7eMerge branch 'vendor-day59' into mainAtlas
  • c13d188b|||PR Vendor Hybriel day59Atlas
  • 24c95433Merge branch 'notes17-ghost-note' into mainAtlas
  • ae1075b2Preserve rejected drafts during note ID adoptionAtlas
  • 383cce23|||PR Prevent saved local edits from restoring deleted notesAtlas
  • 99ca1cf6Merge branch 'vendor-day56' into mainAtlas
  • 649cef37|||PR Vendor Hybriel day56Atlas
  • aadd0abcMerge branch 'hl-standard-2' into mainAtlas
  • 52ffac9f|||PR Keyboard and reload checks for the notes gate (HL-STANDARD F21, F5)Atlas
  • 617ee8c0Merge branch 'hl-standard' into mainAtlas