Skip to content

fix(array): preserve tags on empty final rows - #4277

Merged
grigoriy-reshetniak merged 2 commits into
KaTeX:mainfrom
lprnmns:fix/empty-align-tag
Sep 5, 2026
Merged

grigoriy-reshetniak merged 2 commits into
KaTeX:mainfrom
lprnmns:fix/empty-align-tag

Conversation

@lprnmns

@lprnmns lprnmns commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What is the previous behavior before this PR?

An explicit \tag on an empty final row of an align environment is recorded, but the row is then removed as a trailing empty row. This leaves the row and tag arrays out of alignment, so the visible tag column is empty.

What is the new behavior after this PR?

Final empty rows are retained when they carry a manual tag. Automatic empty trailing rows and rows disabled with \nonumber continue to be removed.

The regression test fails on the previous implementation because the visible tag span is absent and passes with the fix.

Validation:

  • ESLint
  • Stylelint
  • TypeScript (tsc --noEmit)
  • Jest: 8 suites, 1306 tests, 125 snapshots
  • Full production build
  • git diff --check

Fixes #3898

@greptile-apps

greptile-apps Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR preserves an otherwise removable empty final array row when that row carries a manual tag.

  • Distinguishes manual tag arrays from automatic or disabled boolean tag states during trailing-row cleanup.
  • Adds a rendering regression test confirming that the final row’s explicit tag remains visible.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The manual-tag representation is uniquely array-valued, and retaining its row restores body/tag alignment while preserving existing cleanup for automatic and disabled tags.

Important Files Changed

Filename Overview
src/environments/array.ts Updates trailing-empty-row cleanup so explicit manual tags retain their corresponding row without changing automatic-tag or nonumber behavior.
test/katex-spec.ts Adds focused coverage proving that a manual tag on an empty final align row appears in rendered output.

Reviews (1): Last reviewed commit: "fix(array): preserve tags on empty final..." | Re-trigger Greptile

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (314f856) to head (a7dbbbf).
⚠️ Report is 176 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4277      +/-   ##
==========================================
+ Coverage   93.15%   93.45%   +0.29%     
==========================================
  Files          91       92       +1     
  Lines        6795     6858      +63     
  Branches     1582     1609      +27     
==========================================
+ Hits         6330     6409      +79     
- Misses        429      447      +18     
+ Partials       36        2      -34     
Files with missing lines Coverage Δ
src/environments/array.ts 98.06% <100.00%> (ø)

... and 16 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 49904aa...a7dbbbf. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@grigoriy-reshetniak

Copy link
Copy Markdown
Member

Thank you, looks good!

@edemaine edemaine left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I confirmed against pdfLaTeX with amsmath: preserving an empty final row carrying \tag or \tag* matches LaTeX, including empty tags and tags combined with \nonumber. The Array.isArray check looks appropriate.

One other discrepancy I noticed: LaTeX distinguishes align from aligned. A bare trailing \\ creates another row in align, including automatic numbering, but is discarded in aligned. KaTeX currently discards it in both. Something we might want to fix someday... though its kind of annoying behavior.

@grigoriy-reshetniak
grigoriy-reshetniak merged commit 02d552c into KaTeX:main Sep 5, 2026
9 checks passed
KaTeX-bot added a commit that referenced this pull request Sep 5, 2026
## [0.18.6](v0.18.5...v0.18.6) (2026-09-05)

### Bug Fixes

* **array:** preserve tags on empty final rows ([#4277](#4277)) ([02d552c](02d552c))
@KaTeX-bot

Copy link
Copy Markdown
Member

🎉 This PR is included in version 0.18.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tag in empty {align} row not showing

4 participants