feat(core): make multiline env, newline breaks and bar rendering configurable - #22
Open
iasandcb wants to merge 2 commits into
Open
feat(core): make multiline env, newline breaks and bar rendering configurable#22iasandcb wants to merge 2 commits into
iasandcb wants to merge 2 commits into
Conversation
✅ Deploy Preview for marvelous-muffin-35eb19 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
createTrie mutated the module-level SYMBOLMAP, so passing `symbols` to one AsciiMath instance changed the output of every other instance in the process - including instances constructed earlier, since the tex lookup resolves against the shared map at tokenize time. Copy the map in createTrie and hand it to the Trie instead.
…igurable Three behaviours were hardcoded with no way to opt out: - codegen wrapped multiline expressions in `aligned` - the tokenizer required a blank line to emit a line break - an unpaired `|` was always rendered as `\\mid` Expose them as `multilineEnv`, `singleNewlineBreak` and `barAsMid` on AsciiMathConfig. All three default to the current behaviour, so this is backwards compatible.
iasandcb
force-pushed
the
feat/render-options
branch
from
August 18, 2026 08:13
d889811 to
260e9b5
Compare
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.
Three rendering behaviours are hardcoded with no way to opt out:
alignedcodegen.ts\n) required to emit\\trie.ts|rendered as\midparser.tsEach is a reasonable default, but each is also a matter of house style. I
maintain an Obsidian plugin whose vault convention differs on all three, and
the only way to get there today is to patch the built bundle.
Change
Three new optional fields on
AsciiMathConfig:All three default to the existing behaviour, so this is backwards compatible.
Implementation notes
codegentakes an options object as a second argument and threads itthrough its own recursion.
Triegains a newline threshold (2 or 1) set fromsingleNewlineBreak.barAsMidis read from a module-scoped variable thatparser()sets onentry.
walkrecurses through roughly 30 call sites and threading anoptions object through all of them would be a large diff for a single
boolean.
parseris synchronous and non-reentrant so this is safe, but ifyou would rather see it threaded explicitly I am happy to redo it — it is
mechanical, just noisy.
A fourth customisation I needed —
normwithout\left/\right—required no core change at all; the existing
symbolsextension point coversit. That may be worth a line in the README, since it is not obvious that
built-in tokens can be overridden and not just extended.
Tests
test/render-options.test.ts, 11 cases covering defaults, each optionindividually, and all four composed. One snapshot line changes.