gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita43b5d2da43b5d2dmission brief 005mrea43b5d2d/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

  • a43b5d2dmission brief 005mre
  • 04a625edmission 004: re-vendor hybriel a832f73b (native bin + plugins as tickets), compose HL_CACHE_DIR volume + tmpfs /tmp, deploy URL wait 120 s, tests wait 120 s per start; gate 57/0 old and new; real-data same output. Not deployed.mre
  • aefb9d44mission brief w4mre
  • 202098b3docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 304f6a9dnotes mission 003 (#5): report, STATUS, LOGmre
  • 9acc27f8notes mission 003 (#5): GitHub pipe tables in md-editor (parse, render, type, write) + gate checksmre
  • 2149e902notes mission 002 (4/4): code order — README file map + same-output test, STATUS, LOG, report; tests/letcount.py, tests/realdata-baseline.mjs, tests/realdata-compare.pymre
  • 47db4fc1notes mission 002 (3/4): code order — let only where reassigned (58 dropped; 34 left: 19 reassigned, 15 loop-bound); gates 50/0 + 18/0, live-data run = step 2mre
  • 3f8cb383notes mission 002 (2/4): code order — topics, map, thin wrappers: lib/util.hl, lib/notes(-helpers).hl, lib/users.hl (+userOfLoginCode, tagOf), lib/api(-helpers).hl; project.hl = map; login routes take &req/&sessions (failed-login reason now kept); dead notes#1 functions removed; gates 50/0 + 18/0mre
  • 8cda5412notes mission 002 (1/4): code order — files moved: lib/notes.hl, lib/users.hl, lib/jsoncheck.hl, components/styles.hl (imports only); gates 50/0 + 18/0, live-data run identicalmre
  • 47dad68bnotes: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 50/0 + 18/0mre
  • a4a2b2aeantcolony#40: tracker missions moved too — references to them in missions/reports/LOG.md updatedmre
  • 3dea0ef2notes: Hybriel master 190aa11d (fc838894 GC correctness, #126 closure scopes, #127); gate 50/0mre
  • e27c7d71notes: Hybriel master 8efba065 (#126 GC by bytes, #48 lambda params copy; audit: nothing to fix; gate 50/0)mre
  • 124613b6antcolony#40: mission references point to the moved missionsmre
  • 1ca2f34dantcolony#40: history (LOG.md), worker briefs (missions/) and reports moved here from antcolony, numbered per project; old numbers in antcolony docs/mission-map.mdmre
  • 2bebebdanotes: Hybriel master ff51cf46 (re-vendor round)mre
  • 3eff126dnotes#3: installable app (manifest + own icon/favicon; notes' own sw.js kept)mre
  • 9883c540deploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • eee693b8deploy.sh: never send .git or .gitignore to Byrodinmre