Skip to content

feat: table alignment, markdown extensions, frontmatter box, --line-range, math rendering - #25

Merged
borghei merged 8 commits into
mainfrom
feat/rendering
Oct 1, 2026
Merged

borghei merged 8 commits into
mainfrom
feat/rendering

Conversation

@borghei

@borghei borghei commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Table column alignment. :--, --: and :-: are honoured, including wrapped and CJK cells.
  • Markdown extensions. Superscript ^x^, spoilers ||x||, definition lists, and callouts with custom titles (> [!NOTE] Title, plus Obsidian types). <sub> and <sup> render as Unicode sub/superscripts.
  • Frontmatter. With --frontmatter, YAML, TOML and JSON frontmatter render as a key/value box instead of being parsed as markdown. JSON frontmatter is now recognised and stripped by default.
  • --line-range for the pager path, bat-style, keeping code fences well-formed when a range cuts through one. Implies --plain.
  • Math. $…$, $$…$$ and ```math render as Unicode: Greek letters, operators, fractions, roots, sub/superscripts, matrices and cases. Prose like "$5 and $10" is left alone. ASCII mode shows cleaned LaTeX.

Behaviour changes

  • A paragraph followed by a line starting : becomes a definition list.
  • ```math blocks render as math instead of a code box.
  • Display math in the middle of a sentence moves onto its own lines.

Single-tilde ~x~ stays strikethrough, as on GitHub. Underline and highlight are not enabled.

Testing

New tests/rendering_features.rs (through the real pipeline), unit tests for math, frontmatter and line ranges, security tests for the new text paths, and an extended ASCII fixture. No existing snapshot changed. fmt, clippy and the full suite pass locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UVcvmQrSXd2eyt32g4ko19

Header and body cells are padded left, centred or right per the table's
:--, :-: and --: markers, line by line for wrapped cells, measured in
display columns so CJK and emoji cells stay aligned.
…allout titles

- ^sup^ and ~sub~ render with Unicode super/subscript characters when
  every character has one, else ^(x) / _(x) (always in ASCII mode).
  ~~strikethrough~~ is unchanged; a single-tilde pair is now subscript.
- ||spoiler|| keeps its bars visible and draws the text in its own
  background colour until selected or copied.
- Definition lists: bold term, definitions indented under a marker.
- Alerts and Obsidian callouts show their custom title (> [!NOTE] Title,
  > [!info]- Title); Obsidian types map onto the five alert colours and
  fold markers are ignored.
- Table cells convert super/subscripts too.

underline stays off: comrak's extension turns __bold__ into underline.
--frontmatter (or frontmatter = true) used to feed the metadata to the
markdown parser, which drew a rule and a setext heading made of the
keys. The block is now drawn as a bordered key/value box titled
"frontmatter": top-level keys, scalars unquoted, lists comma-joined,
nested values raw. YAML (---), TOML (+++) and JSON ({ at byte 0)
frontmatter are recognised; JSON is now also stripped by default.
Unterminated or keyless blocks still render as markdown.
bat-style ranges (START:END, START:, :END, N; repeatable; 1-based,
inclusive) select lines of the markdown source before it is rendered.
A range that cuts a fenced code block reopens the fence with its info
string and closes it, so the block stays well-formed and highlighted;
disjoint runs are kept apart by a blank line. Invalid ranges are a usage
error (exit 2). The reader has no start-at-line hook, so --line-range
implies --plain.
Inline $…$, display $$…$$ and ```math blocks (math_code is now on)
go through a dependency-free LaTeX-to-Unicode approximation instead of
showing raw LaTeX: Greek letters, operators, relations, arrows and big
operators; \mathbb/\mathcal/\mathfrak letters; Unicode super- and
subscripts with ^(…)/_(…) fallbacks; \frac as a/b with parentheses
around compound sides; \sqrt and \sqrt[n]; \text and \mathrm as plain
text; matrix, pmatrix, bmatrix, Bmatrix, vmatrix, array, cases, aligned
and gathered laid out in rows with padded columns and bracket glyphs.
Unknown commands are kept verbatim, nesting is capped, malformed input
never panics. Display math sits on its own indented lines; inline math
keeps the code colour; table cells render math too. ASCII mode shows
the LaTeX source with \left/\right and spacing commands removed. A
```math block's copy hint still yields its LaTeX source.
… scripts

comrak's subscript extension turned GitHub's ~struck~ into subscript.
It is off again, so ~x~ and ~~x~~ both strike through as in v0.9.0;
^sup^ stays. Inline and block HTML <sub>/<sup> now use the same Unicode
script mapping, with the _(x) / ^(x) fallback (always in ASCII mode).
@borghei
borghei merged commit 7ba1e89 into main Oct 1, 2026
8 checks passed
@borghei
borghei deleted the feat/rendering branch October 1, 2026 16:05
@borghei borghei mentioned this pull request Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant