~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

The iOS app draws Markdown's tables

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:ios/markdown-tables

What changes

Tables in Markdown are drawn as tables in the iOS app, wherever it draws Markdown: READMEs, pull and issue descriptions, comments, release notes and commit messages. They showed as words with pipes in them.

The head row is filled, cells keep their marks, links and pictures, and each column keeps its alignment. A table wider than the page scrolls sideways, as a code block does. A cell of more than a line wraps at 260 points, so one long sentence doesn't make the whole table wide. Head cells stay on one line, so the fill runs evenly along the row.

Why

The parser follows GitHub's flavour: a line of cells, a line of dashes with as many columns under it, then a row to a line up to a blank line or one with no pipe. Anything else stays words, as a | b does in a sentence. It's in its own file with only Foundation, so ios/check-models.sh tests it on Linux.

How it was checked

just ios-look repository on the recorded README's table, and pull-open with a sample description, light and dark: alignments, marks, a link, a long cell, a short row, a table wider than the page scrolled to its end, and a line with a pipe that isn't a table. ios/check-models.sh now covers the head, alignments, an escaped pipe, short and long rows, and what isn't a table.

Shortcomings

Whether a cell wraps goes by its count of letters, as a grid can't measure a wrapped cell, so a cell near 36 letters may wrap when it needn't, or be cut close. A very long head cell makes its column wide. A long description folded partway through a table shows it cut there, until it's opened. ios/ isn't built by CI.

🤖 Generated with Claude Code

table-light.png

table-dark.png

Approved

This pull adds a MarkdownTable parser and draws its tables in the iOS app as a scrolling Grid. I read the whole diff and found nothing that must change.

  • Parser: It requires a pipe on both the header and dashes lines, and it requires the same column count on both. Rows are padded or truncated to the header's width. Escaped pipes and a trailing \| are handled. ModelCheck covers the cases I traced.
  • Block parsing: A table starts only when the line above the dashes is the last paragraph line, and it ends at a line with no pipe. flush() emits it, and a blank line still ends the paragraph as before.
  • Not checked: I couldn't build the app. Self.plain, which cell calls, exists in Markdown.swift.
  • Changeset: The change is under ios/, so I don't think harness/changes.sh asks for a change file.
  • Layout: Wrapping goes by letter count, as your Shortcomings section says. I'm leaving that as an accepted trade-off.
Merged as ab8779f