Skip to content

compiler: parse \marginpar and set the note in the right margin (#505) - #555

Closed
d-q222 wants to merge 2 commits into
mainfrom
agent/daniel-muse-lead-2/marginpar-compiler
Closed

d-q222 wants to merge 2 commits into
mainfrom
agent/daniel-muse-lead-2/marginpar-compiler

Conversation

@d-q222

@d-q222 d-q222 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #505 (compiler half — render-pipeline placement is a separate draft PR, blocked on a vendor/compiler re-pin past this commit).

What changed

  • \marginpar[<left>]{<right>} parses to a new Inline::Marginpar carrying the one-sided {<right>} note (a present [<left>] is consumed with a warning); unsupported_feature gone. Incremental span-shifting/block signatures and the Core 14 layout updated (skips the note, no mark).
  • Stated simplification: always the right margin (no two-sided alternation, \reversemarginpar), no collision avoidance between close notes — documented in the supported-latex description and module docs.
  • Generated inventory artifacts regenerated (both copies, Mac bundle included).

Tests

  • crates/compiler: full suite independently re-verified fresh, 100% green (341 passed, 0 failed), including 2 new marginpar parser unit tests and the generated_artifacts_are_current regen check.

Split rationale

The render-pipeline placement side is behind an off-by-default marginpar cargo feature (cargo check --features marginpar fails with exactly 5 E0599: no variant named Marginpar, since flashtex-cli/render-pipeline build against the frozen crates/render-pipeline/vendor/compiler snapshot, currently pinned to PR #316 — see vendor/VENDORING.md). Splitting so this compiler-only half is immediately mergeable; the pipeline half follows as a draft PR pending the re-pin.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet Muse supervisor; split from muse/marginpar for the compiler-PR-first/pipeline-draft-second pattern)
Co-authored-by: d-q222 [email protected]

🤖 Generated with Claude Code

\marginpar[<left>]{<right>} now parses to a new Inline::Marginpar
carrying the one-sided {<right>} note (a present [<left>] is consumed
with a warning); the unsupported_feature diagnostic is gone in the real
compiler, incremental span-shifting/block signatures and the Core 14
layout (skips the note, no mark) updated. Stated simplification: always
the right margin (no two-sided alternation, \reversemarginpar), no
collision avoidance between close notes.

Render-pipeline placement lands separately (needs a vendor/compiler
re-pin past this commit to compile the new Inline variant) — see the
paired draft PR.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet Muse supervisor; split
compiler-only files from muse/marginpar 3473c632/9c819976 for the
compiler-PR-first/pipeline-draft-second pattern)
Co-authored-by: d-q222 <[email protected]>
Append-shaped conflicts: keep main's fnsymbol entries alongside this
branch's marginpar in parser.rs dispatch/vocabulary and supported.rs.
docs/user/compiler.md and the supported-latex inventory regenerated via
crates/compiler/scripts/render_supported_latex.sh; mac bundled copy synced.

Implementation-Agent: fable-rebase-b
Commit-Executor: fable-rebase-b (direct; Cursor usage limit)
GoKubar added a commit that referenced this pull request Sep 15, 2026
* compiler: implement \thepage via the \pageref late-binding path

\thepage parses to a new Inline::ThePage resolved at layout time to the
physical page being set, formatted in the \pagenumbering style in force
there (previously: unknown_command). \pagenumbering now emits a
zero-width Inline::PageNumbering marker that resets the displayed page
counter to 1 and switches the style; labels capture the styled page text
so \pageref (and cleveref page refs) match. Unknown styles fall back to
arabic, keeping the command accepted as before.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: muse-spark-1.3-contributor

* compiler: support \captionof{figure/table}[short]{text} outside floats

caption.sty's standalone caption form reuses \caption's exact machinery
(counter step, Figure/Table N: prefix, FigureCaption block) with the float
type given explicitly instead of read from the enclosing environment.
The [short] list-of-figures argument is consumed and ignored; unknown
types diagnose and fall back to paragraph text like \caption outside a
figure. Inventory entry plus regenerated supported-LaTeX artifacts.

Implementation-Agent: muse-spark-1.3-contributor

* compiler: parse \marginpar and set the note in the right margin (#505)

\marginpar[<left>]{<right>} now parses to a new Inline::Marginpar
carrying the one-sided {<right>} note (a present [<left>] is consumed
with a warning); the unsupported_feature diagnostic is gone in the real
compiler, incremental span-shifting/block signatures and the Core 14
layout (skips the note, no mark) updated. Stated simplification: always
the right margin (no two-sided alternation, \reversemarginpar), no
collision avoidance between close notes.

Render-pipeline placement lands separately (needs a vendor/compiler
re-pin past this commit to compile the new Inline variant) — see the
paired draft PR.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet Muse supervisor; split
compiler-only files from muse/marginpar 3473c632/9c819976 for the
compiler-PR-first/pipeline-draft-second pattern)
Co-authored-by: d-q222 <[email protected]>

* compiler: add basic biblatex support

What changed:
- add project-relative biblatex resource loading, numeric citations, notes, sorting, and bibliography rendering
- route biblatex commands through a dedicated compiler module

What was run:
- CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-biblatex cargo test --manifest-path crates/compiler/Cargo.toml --test biblatex -- --nocapture: 7 passed

Next step:
- commit focused coverage and regenerated support inventories

Lane-Owner: daniel-parent (mac-m5pro-dq222)
Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session); trailers added by daniel-parent
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* compiler: cover biblatex support

What changed:
- add coverage for citations, notes, textcite, nocite, sorting, undefined keys, and headings
- regenerate compiler and macOS supported-LaTeX inventories and user docs

What was run:
- CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-biblatex cargo test --manifest-path crates/compiler/Cargo.toml --test biblatex -- --nocapture: test result: ok. 7 passed; 0 failed
- sh crates/compiler/scripts/render_supported_latex.sh: completed

Next step:
- run the final full compiler test suite

Lane-Owner: daniel-parent (mac-m5pro-dq222)
Implementation-Agent: codex gpt-5.6-luna (max)
Commit-Executor: codex (this session); trailers added by daniel-parent
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* compiler: route eqnarray/eqnarray* through multirow displays (#520)

eqnarray/eqnarray* now parse via multirow_environment (rows on \\, 3
cells on &), numbered against the shared equation counter (* unnumbers
all, \nonumber/\notag unnumbers one row); N rows consume N+1 numbers
per ltmath.dtx. Both envs moved from the unimplemented to the
implemented inventory.

Render-pipeline layout (RowsEnv::EqnArray, right/centred/left columns,
kernel arraycolsep spacing) lands separately — see the paired draft PR;
it has no compile-time dependency on this commit (RowsEnv reads the
environment name from source text), but its end-to-end geometry test
stays #[ignore]d until a vendor/compiler re-pin lets it see real
eqnarray output instead of the vendored plain-text fallback.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet Muse supervisor; split
compiler-only files from muse/eqnarray for the compiler-PR-first/
pipeline-draft-second pattern)
Co-authored-by: d-q222 <[email protected]>

* compiler: keep biblatex's parser arms out of the recursive command frame

What changed:
- `\addbibresource` and `\printbibliography` move out of `P::command` into
  `#[inline(never)]` helpers (`add_bib_resource`, `print_bibliography`);
  `biblatex_cite` is `#[inline(never)]` too.
- The biblatex `\citeauthor`/`\citeyear` dispatch moves from the `command`
  arm to the top of `natbib_cite`.
- Why: `P::command` is on the stack once per nested sub-parse. In debug
  builds every local of every arm gets its own slot, so #558's inline arms
  grew each nesting level by 1440 bytes. Combined with #601, 32 nested
  tabulars (#577's STREAM_DEPTH_LIMIT, kept at 32) overflowed the 2 MiB
  debug test thread in
  robustness::nested_sub_parses_hit_tex_grouping_capacity_instead_of_the_stack
  (found by the integration preview, #609).

What was run:
- Stack per nesting level (debug), measured with a scratch probe that prints
  the stack address in `parse_stream` at each depth (not committed):
  | construct | #601 | #601+#558 before | #601+#558 after |
  | tabular   | 57232 | 58672 | 57360 |
  | footnote  | 31424 | 32864 | 31552 |
  | colorbox  | 30928 | 32368 | 31056 |
  | rotatebox | 32048 | 33488 | 32176 |
  | uline     | 30336 | 31776 | 30464 |
- #601 + #558 (merge), debug, CARGO_BUILD_JOBS=4:
  cargo test --test robustness --test biblatex
  biblatex: test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
  robustness: test result: ok. 14 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 41.06s
- This branch, debug:
  biblatex: test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
  robustness: test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 40.81s
  natbib: test result: ok. 15 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
  --lib cite: test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 331 filtered out; finished in 0.00s

Next step: merge into the integration preview (#609) and rerun there.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

* integration: regenerate supported-latex artifacts on the combined head

crates/compiler/scripts/render_supported_latex.sh over the five merged
PRs: 333 -> 341 text commands, 62 -> 64 environments (eqnarray,
eqnarray*), 23 -> 24 packages (biblatex); Mac bundled copy synced.

Implementation-Agent: fable-integration-cmp
Commit-Executor: fable-integration-cmp (direct; Cursor usage limit)

* integration: regenerate bridge and paragraph-layout lockfiles for flashtex-bibliography

PR #558 added flashtex-bibliography to flashtex-compiler's dependencies
but only updated crates/compiler/Cargo.lock. bridge and paragraph-layout
path-depend on the real compiler, so their lockfiles gain the same entry;
flashtex-cli and render-pipeline build against the vendored compiler
snapshot and are unchanged. Verified CI-style with
cargo build --release --locked for all five crates.

Implementation-Agent: fable-integration-cmp
Commit-Executor: fable-integration-cmp (direct; Cursor usage limit)

---------

Co-authored-by: muse-spark-1.3-contributor <[email protected]>
Co-authored-by: d-q222 <[email protected]>
@GoKubar

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Landed via #645, an integration branch that merged this PR with git merge --no-ff alongside its siblings — so your commits and authorship are preserved in main's history.

GitHub could not auto-close this: #645 was squash-merged, which creates a new commit, so this branch's tip is not an ancestor of main even though its content is. I verified the feature is present on main before closing.

Why the work was batched: these PRs all append to the same compiler/pipeline hub files (parser.rs, supported-latex.json, supported.rs, vocabulary.rs, adapter.rs), so every individual merge knocked the rest into conflict. Merging them one at a time lost several PRs to repeated races; batching them into one --no-ff branch landed them cleanly.

Reopen if you find anything of yours that did not make it across.

— orchestrator-astra (Commander)

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/daniel-muse-lead-2/marginpar-compiler branch September 16, 2026 04:18
ItsAkilesh pushed a commit to ItsAkilesh/flashtex that referenced this pull request Sep 18, 2026
What changed:
- `crates/render-pipeline/Cargo.toml` declares a new off-by-default feature
  `compiler-node-surface`. It carries no behaviour of its own: every arm it
  adds is the inert answer the pipeline already gave for a compiler node the
  current pin (`c95977d6`) cannot produce.
- The pipeline's exhaustive matches and node constructors now cover main's
  compiler surface behind that feature: `parser::Block::Penalty`/`Tabbing`,
  `parser::Inline::ThePage`/`PageNumbering`/`TabStop`/`TabJump`/`Marginpar`/
  `Penalty`/`PagePenalty`/`Discretionary`, `VSpace`/`HSpace` glue components,
  `math::Nucleus::TextRun`/`SideSet`/`Lap` and `math::Accent::Mathring`
  (compiler flash-tex#549, flash-tex#551, flash-tex#555, flash-tex#568, flash-tex#581, flash-tex#583, flash-tex#587, flash-tex#606, flash-tex#616).
  `adapter::vspace_block` is a new cfg'd constructor beside the existing
  `line_break_inline`; the one open-coded `Inline::LineBreak { .. }` left in
  the `\opening` lowering now goes through `line_break_inline` too.
- `tabbing` is lowered to flush-left paragraphs with one `unsupported_block`
  limitation, the way `LetterBlock` is, so no row is dropped by the re-pin.
- `docs/integration/repin-runbook.md`: the exact re-pin commands, the three
  vendor directories that must move (`compiler`, `tex-expansion`, and a new
  `bibliography`), the lockfile and `#[ignore]` edits `--locked` CI needs, the
  measured test deltas and the PRs the pin unblocks.

No file under `vendor/` is touched: the vendor swap used to measure all of
this was scratch-only and reverted. `git diff --stat origin/main...HEAD`
contains zero `vendor/` paths.

What was run:
Whole `crates/render-pipeline` suite, CARGO_BUILD_JOBS=4, --no-fail-fast:
  origin/main, pinned vendor, feature off:   469 passed, 13 failed
  this branch, pinned vendor, feature off:   469 passed, 13 failed (same 13)
  this branch, vendor re-pinned, feature on: 485 passed, 0 failed
The 13 red-on-main tests (letter_class_geometry x5, frame_env, underline_sout
x4, uline x2, xcolor_oracle) all pass after the re-pin.
Two re-pin-gated #[ignore]s also pass against the re-pinned vendor:
  test frame_draws_a_rule_border_around_its_content ... ok
  test coloneqq_decomposes_like_mathtools ... ok
crates/flashtex-cli against the same re-pinned vendor:
  test result: ok. 58 passed; 0 failed
cargo check --all-targets on this branch at the current pin: 0 errors.

Next step:
The integration lane applies docs/integration/repin-runbook.md section 3 --
swap the three vendor trees, move `compiler-node-surface` (and
`linebreak-skip`) into `default`, refresh both Cargo.locks, drop the two
`#[ignore]`s, update vendor/VENDORING.md.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.

render-pipeline: \marginpar is unsupported

2 participants