Skip to content

Equations: Word (OMML) import, layout and save, plus an equation editor like Word's - #191

Merged
echelon merged 9 commits into
storytold:mainfrom
gledguri:pr/equations
Oct 10, 2026
Merged

echelon merged 9 commits into
storytold:mainfrom
gledguri:pr/equations

Conversation

@gledguri

Copy link
Copy Markdown
Contributor

Closes #24.

What's in it

Word equations (commit 1). OMML is read into a math tree (fractions, scripts, radicals, n-ary operators, delimiters, functions, limits, accents, bars, boxes, equation arrays, matrices, phantoms), laid out with the OpenType MATH table (Cambria Math when installed, otherwise STIX Two Math or another open math font), drawn on screen and in PDF, and written back as OMML. Display equations sit on their own centred line. Previously equations were flattened to plain text.

An equation editor modelled on Word's (commit 2).

  • Insert › Equation edits in place, with an Equation tab: ready-made equations, Unicode/LaTeX input and professional ↔ linear conversion, Normal Text, eight symbol sets, and structure galleries (fraction, script, radical, integral, large operator, bracket, function, accent, limit and log, operator, matrix) with tiles rendered by the math engine.
  • Typing builds up like Word (a/b, x^2, √, ∑… then space); Math AutoCorrect turns \alpha, \sqrt… into symbols; Tab moves between empty slots; arrows and Backspace work through structures.
  • The right-click menu has structure commands (fraction type, radical degree, limit position, matrix rows/columns, remove brackets…).
  • A trailing #(n) numbers a display equation at the right margin; # alone numbers it automatically. DOCX output keeps numbers Word-compatible.

Testing

  • cargo xtask ci passes (fmt, clippy, tests, assets, layers, wasm).
  • DOCX round-trip tests for OMML, and used on macOS with Word documents containing equations.

🤖 Generated with Claude Code

gledguri and others added 9 commits October 10, 2026 00:32
Equations were flattened to plain text on import. Now OMML is read into a
math tree (fractions, scripts, radicals, n-ary operators, delimiters,
functions, limits, accents, bars, boxes, equation arrays, matrices,
phantoms), laid out with the OpenType MATH table (Cambria Math when
installed, else STIX Two Math and other open math fonts), drawn to screen
and PDF, and written back as the original OMML. Display equations sit on
their own centred line. insert.equation parses the linear format into
structure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… numbers

Insert › Equation now opens an equation for in-place editing, with the
Equation tab: ready-made equations, Unicode/LaTeX input and conversion
(professional ↔ linear), Normal Text, eight symbol sets, and the eleven
structure galleries (fraction, script, radical, integral, large operator,
bracket, function, accent, limit and log, operator, matrix) with tiles
rendered by the math engine. Typing builds up like Word (a/b, x^2, √, ∑…
then space), Math AutoCorrect turns \alpha, \sqrt… into symbols, Tab moves
between empty slots, arrows/Backspace work through structures, and the
right-click menu has structure commands (fraction type, radical degree,
limit position, matrix rows/columns, remove brackets…). A trailing #(n)
numbers a display equation with the number at the right margin; # alone
numbers it automatically. DOCX output keeps numbers Word-compatible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts resolved:
- session.rs: keep main's whole-stack undo snapshot (history + redo) and the
  PR's equation exit and "Typing" grouping for equation.type.
- layout/para.rs: keep main's ParaLayout.shown and picture-on-baseline line
  metrics; equations keep counting their ascent/descent like text. Display
  equation lines are neither justified nor space-shrunk.
- ui-egui: page_at takes the layout; the Equation tab joins
  contextual_tabs() next to Table/Picture Format; Picture Format tab kept.
- formats: main's flow model builds InlineObject::Equation without the PR's
  `math` tree (empty = parse linear); doc -> flow uses the linear form.
- i18n ja/zh: union. docs/parity.md regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rainian

The catalogs that landed on main after storytold#191 was opened lacked the Equation
tab and equation command labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clean room: the ready-made equation list used another product's gallery entry
names and order. Same formulas (and ids), with our own descriptive labels,
grouped by subject (geometry, algebra, calculus, trigonometry, probability).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, Read Aloud, keytips)

Conflicts: both sides' new modules, Session fields (Prefs/read_aloud and the
equation state), layout Ctx (BoxBudget and eq_count), ParaLayout (left_out and
maths/displays), keys.rs (keytips guard plus equation keys), WordApp fields,
i18n rows (union), ROADMAP rows (main's picture row, the equations row).
docs/parity.md regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echelon
echelon merged commit 10eb879 into storytold:main Oct 10, 2026
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Merged — thank you for the contribution, @gledguri! 🎉 Equations with OMML import/save, layout from the OpenType MATH table, and an in-place editor with its own tab is a huge piece of work. While merging main into your branch I:

  • gave the built-in equation gallery our own descriptive names and grouping (the formulas are maths facts, but we keep the clean-room line by not mirroring another product's gallery names/order);
  • made the equations row in ROADMAP.md consistent;
  • added the Equation strings to the Brazilian Portuguese, Spanish and Ukrainian catalogs;
  • made Equation one of main's contextual tabs (with Table and Picture Format) and reconciled it with LaTeX (.tex) import and export (#7) #11's LaTeX Inline::Equation in the flow model (an empty math now means "parse linear").
    A follow-up worth doing someday: formats::latex and your doc::math_latex both convert LaTeX and could share code.

If you haven't already, come join us on Discord: https://discord.gg/artcraft — we'd love to have you there.

@Neeraj-Parekh

Copy link
Copy Markdown

Subscribing — validating releases on Ubuntu 26.04 (posted #1971). Interested in live TeX-math preview on top of the OMML work here; happy to test .tex round-trips and equation edge cases when there's something to try.

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.

[feat] Equation editor

3 participants