Skip to content

Add markdown-table-wrap-pretty: display-only pretty rendering of pipe tables - #7

Merged
dnouri merged 2 commits into
dnouri:mainfrom
SayreBlades:feat/pretty-display
Aug 6, 2026
Merged

Add markdown-table-wrap-pretty: display-only pretty rendering of pipe tables#7
dnouri merged 2 commits into
dnouri:mainfrom
SayreBlades:feat/pretty-display

Conversation

@SayreBlades

Copy link
Copy Markdown
Contributor

Summary

Adds markdown-table-wrap-pretty.el — a new, opt-in display companion package that renders markdown and org pipe tables as a wrapped, Unicode box-drawing "pretty" view on top of the canonical raw table text, and toggles between that view and the editable source in place. It is the table analogue of org-latex-preview (or inline image previews).

markdown-table-wrap.el is unchanged. The new file is a separate package (Package-Requires: ((emacs \"28.1\") (markdown-table-wrap \"0.2.0\"))) that depends only on the engine's public API.

Why display-only (not buffer mutation)

markdown-table-wrap wraps a long cell into multiple | ... | rows, but pipe-table syntax has no row-spanning, so any real renderer (cmark-gfm, pandoc, GitHub, org HTML export) sees N independent data rows, not one wrapped cell. Mutating the buffer looks right in Emacs but is semantically broken the moment the text leaves Emacs. This keeps the buffer canonical — export/copy/share/push always see a real table — and makes the pretty rendering a disposable display layer:

  • one display overlay per raw line (so C-n walks raw lines, big tables scroll);
  • editing auto-reveals the raw source via modification-hooks (the org-latex-preview pattern — not read-only, which would break undo);
  • resize re-renders pretty tables losslessly from canonical (never unwrap).

This is the display-only successor to the closed #4 (which mutated the buffer), and the read-only complement to #2: #2 is about safely rewriting table text; this is about displaying a pretty rendering over canonical text without rewriting it.

What's included

  • markdown-table-wrap-pretty.el — the package: commands (-toggle/-buffer/-region), a buffer-local minor mode, defcustoms, and the renderer. Supports GFM + org (|---+---| separators and width cookies normalized for rendering only; #+TBLFM: lines left untouched). Detection is universal/line-based (no tree-sitter dep), so it works in markdown-mode, gfm-mode, md-ts-mode, and org-mode.
  • test/markdown-table-wrap-pretty-test.el — 32 ERT tests for the pure helpers (parsing, row/separator rendering in plain + Unicode forms, inline-span styling, org normalization, prefix-aware display groups).
  • Makefilecompile/lint/check-parens/test generalized to cover both packages; lint-package now refreshes archives so real package dependencies resolve.
  • README.org — documents the optional display layer (commands, customization, install/keys).

make check (compile + checkdoc + package-lint + tests) is green: 199 tests pass (1 pre-existing expected failure in the core).

Notes / open questions

  • Detection duplicates Help editor integrations rewrite Markdown tables without drifting or hanging #2. This carries its own markdown-table-wrap-pretty--table-bounds/--table-regions. Once Help editor integrations rewrite Markdown tables without drifting or hanging #2 (helper-table-inspection) lands markdown-table-wrap-table-bounds/-regions, these should delegate to the upstream functions. Built to merge independently now; happy to de-dup after Help editor integrations rewrite Markdown tables without drifting or hanging #2.
  • Org scope. The engine's README is GFM-only; this ships org support too (already built and tested). If you'd prefer GFM-only for a first cut, --normalize-org-line is the one isolated piece to drop.
  • Co-packaging on MELPA. Both files ship from one repo; with the current MELPA recipe (markdown-table-wrap) the pretty file rides along (autoloaded, minor mode off by default → no behavior change for existing users). If you'd prefer it as a separately-installable/versioned package, it just needs its own MELPA recipe.
  • I dropped an unused max-cell-height defcustom that existed in the prototype but was never wired into rendering (the public markdown-table-wrap-cell takes no height cap). Easy to re-add as a real feature if wanted.

Happy to split org support out, adjust naming/keys, or rebase detection onto #2's branch.

… tables

Add a new, opt-in package (separate from the pure wrapping engine) that
renders markdown/org pipe tables as a wrapped, Unicode box-drawing view
ON TOP OF the canonical raw text, and toggles between that view and the
editable source in place -- the table analogue of `org-latex-preview'.

The buffer is never mutated, so export/copy/share/push always see a
valid single-row-per-record table; the pretty rendering is a disposable
display layer (per-line overlays, auto-revealed on edit via
modification-hooks, losslessly re-rendered on window resize).

markdown-table-wrap.el is unchanged; the new file depends only on its
public API.  GFM and org are both supported (org separators and width
cookies are normalized for rendering only).  Adds an ERT suite for the
pure helpers and wires the Makefile/README for the second package.
The MELPA recipe builds this repo as a single package (`markdown-table-wrap',
main file markdown-table-wrap.el) containing both .el files.  Treat the
display companion accordingly so melpazoid is green:

- Drop the per-file Version and Package-Requires from
  markdown-table-wrap-pretty.el: in a single package only the main file
  declares those, and the companion's `(require 'markdown-table-wrap)' is
  satisfied intra-package.  (If split into a separate MELPA package later,
  re-add its Package-Requires.)
- Makefile: set package-lint-main-file so local `make lint-package' matches
  melpazoid's single-package model (resolves "Package-Requires outside the
  main file have no effect").
- Use (derived-mode-p 'markdown-mode 'md-ts-mode) instead of
  (or (derived-mode-p 'markdown-mode) (eq major-mode 'md-ts-mode))
  (melpazoid style note).

make check (compile + checkdoc + package-lint + tests) green.
@dnouri
dnouri merged commit f846b77 into dnouri:main Aug 6, 2026
4 checks passed
@SayreBlades
SayreBlades deleted the feat/pretty-display branch August 7, 2026 00:48
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.

2 participants