Repository navigation
Architecture en
中文 · English
Lineae's editing model is a ProseMirror document tree carried by Tiptap; MathLive handles interactive math input; a standalone LaTeX module handles parsing and serialisation. The .tex source is always the authoritative document, and the TeX engine is the authority on final typesetting. On top of this, the desktop app provides a native workspace rendered by real LuaLaTeX.
Browser UI / Tauri shell (ribbon, status bar, settings panel)
|
v
Work modes: Document / Source / Split
|
v
Tiptap / ProseMirror <----> MathLive
|
v
LaTeX import and export (byte-preserving source)
|
+---- recognised syntax -> editable document nodes
|
+---- unrecognised syntax -> preserved source blocks
|
v
.tex files / projects
Engine profiles (XeLaTeX / LuaLaTeX / pdfLaTeX)
|
+---- web: JS typesetting pipeline (layout + pagination)
+---- desktop: native LuaLaTeX workspace (rtex rendering + hybrid editing)
BibTeX / BibLaTeX module
+---- parsing, validation, editing, serialisation, citation checks
-
src/main.jsassembles the editor, ribbon, source view, project sidebar, and display controls. - All changes go through ProseMirror transactions, so selection mapping, undo, and redo are unified.
- Document / Source / Split modes share one document model; Source mode is an explicit edit of the whole document and rebuilds the editable projection when applied.
-
latex/typeset-layout.mjsderives font size, baselines, indents, and page capacity from\documentclassand font/spacing declarations, and plans pagination at block and visual-line boundaries. The pdfLaTeX path additionally detects font packages (lmodern,mathpazo,newtxtext,helvet, …) to derive the Computer Modern font stack. -
src/typesetting/engine-profile.mjsprovides a uniform profile interface for the three engines:documentStyle(), paragraph parameters, and CJK precision assessment. -
src/typesetting/engine-resolution.mjsinfers the engine from the source:% !TeX programmagic comments, engine primitives (\XeTeX…,\directlua), and characteristic packages (xeCJK,luatexja). Explicit choices win; conflicting evidence falls back to the global default, with conflicts pinned to source locations. -
src/editor/typeset-pagination.jsonly generates background sheets andtranslatestyles; it never inserts nodes into the ProseMirror document or writes layout state onto editable nodes. -
latex/geometry.mjsusesarticle.clsnative page dimensions when nogeometrypackage is present, instead of geometry's default margins. -
assets/fonts/latin-modernbundles Latin Modern OTF; the pdfLaTeX profile switches to a Computer Modern / CMU stack.
-
src/ui/native-tex-preview.mjsandsrc/editor/native-surface/implement direct editing of pages rendered by rtex 0.0.8 (bundled distribution): prose, inline and display math, tables. - Hybrid editing pipeline (
docs/native-tex/hybrid-line-editing.md): ProseMirror owns input, composition, selection, and history for the lifetime of an edit; the native page owns the confirmed glyphs. Obsolete glyphs are masked until that sheet has painted the matching revision, and a late complete page cannot roll back newer paragraph ink. - Sessions are hosted by Rust's
tex_session.rs(experimental, trusted documents only): the bundled rtex is preferred, otherwise a system TeX Live LuaLaTeX is auto-detected (RTEX_TEXLIVE_BIN,LINEAE_RTEX_PATHoverride); missing tools are reported and never silently substituted. - Content the glyph painter cannot draw (Type 1/TTC fonts, images, TikZ, …) uses a revision-frozen whole-page PDF rendered by the bundled PDF.js 4.10.38; "Export clean PDF" is available only for a confirmed current frame.
- Unknown or stale geometry never writes a guessed source range; edits apply only to verified source spans.
- The legacy JS pipeline remains as a fallback and can be restored in settings (after a restart).
-
src/project/maintains the project file tree, the\include/\inputdependency graph, and main-file resolution. - Engine selection resolves per project (
project.resolveTypesetting), with conflict diagnostics located in specific files and source positions. - Document mode supports continuous cross-file editing, cross-file selection and replacement, and project-wide outline jumps.
-
src/editor/latex-codec.jsconverts between supported LaTeX and the editor tree; parsing and editing checkpoints preserve untouched source byte-for-byte. -
latex/document.mjskeeps the preamble, document boundary, and opaque source blocks. -
latex/inline.mjsrecognises supported inline syntax;latex/tables.mjsrecognises a restricted tabular syntax, andlatex/tblr.mjs/latex/tabularx.mjsadapt supported source tables to the existing Table nodes while retaining source ranges, so cell edits patch rather than rebuild;latex/packages.mjsresolves package dependencies needed on export.
The BibTeX/BibLaTeX engine is separate from the editor UI and has its own public API and tests:
- Parsing, validation, entry editing, serialisation
- Diagnostics
- Scanning
.texsources for citations - Pre-compilation checks
Documentation: docs/bib-engine/ (API, architecture).
- Dependencies are locked in
package-lock.json; CI usesnpm ci. - esbuild bundles
apps/web/src/main.jsintoapps/web/editor.mjs. - MathLive is vendored as a standalone asset into
apps/web/vendor/mathlive. -
editor.mjsand vendor assets are deployment artifacts and are not committed.
pages.yml builds on every push to main, runs the LaTeX / config / bibliography / browser regression tests, and deploys to GitHub Pages (http://lineae.aminiam.com/).
Desktop artifacts are built by desktop.yml (Windows), macos-release.yml (Apple Silicon), and linux-release.yml (x86_64); native TeX baselines and acceptance run remotely via native-tex.yml. See Development and Desktop.
The web JS typesetting is not calibrated against TeX line breaking or arbitrary package expansion:
- Font metrics, kerning, and paragraph spacing are approximations.
- Editing a supported block may change whitespace, comments, and command spelling in the source.
- Complex package constructs and source details need dedicated adapters and a lossless syntax model.
The desktop native workspace, rendered by real LuaLaTeX, is the reference and target for typesetting fidelity; the web pipeline keeps calibrating metrics, math layout, spacing, and pagination against the engine profiles.