Add markdown-table-wrap-pretty: display-only pretty rendering of pipe tables - #7
Merged
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 oforg-latex-preview(or inline image previews).markdown-table-wrap.elis 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-wrapwraps 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:C-nwalks raw lines, big tables scroll);modification-hooks(theorg-latex-previewpattern — notread-only, which would break undo);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 inmarkdown-mode,gfm-mode,md-ts-mode, andorg-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).Makefile—compile/lint/check-parens/testgeneralized to cover both packages;lint-packagenow 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
markdown-table-wrap-pretty--table-bounds/--table-regions. Once Help editor integrations rewrite Markdown tables without drifting or hanging #2 (helper-table-inspection) landsmarkdown-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.--normalize-org-lineis the one isolated piece to drop.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.max-cell-heightdefcustom that existed in the prototype but was never wired into rendering (the publicmarkdown-table-wrap-celltakes 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.