Fixes data-latex content for Table Rows - #1528
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1528 +/- ##
===========================================
+ Coverage 86.93% 86.97% +0.04%
===========================================
Files 388 390 +2
Lines 87571 88213 +642
Branches 3290 3352 +62
===========================================
+ Hits 76129 76726 +597
- Misses 11442 11487 +45 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dpvc
left a comment
There was a problem hiding this comment.
This is a big improvement, but there still seem to be some issues. Those are probably actually problems with the attributes of the child nodes in many cases. Perhaps they can be improved? (I haven't looked into the problem, but it may be due to modifying the parser.string value for substitutions.)
|
Thanks for looking at these tests in more detail. I have to admit I mainly focussed on the expressions in |
ensure labels will get the right latex attribute
Summary (cleaned up and greatly enhanced by co-pilot)Fixes several cases where the Problems
Fixes
New
|
| Property | Set where | Purpose |
|---|---|---|
rawLatex |
ArrayItem.captureLatex(), and copied onto the mtable/wrapping mstyle node in setTableLatex() / EndTable() |
Caches the raw, unmodified LaTeX source of the array/table environment (\begin{name}...\end{name}), captured before column-template substitutions or nested-environment parsing can corrupt the parser's string. |
rawLatexName |
Alongside rawLatex everywhere it's set |
The environment name (array, matrix, etc.), needed to detect "broken" data-latex values and to rebuild \begin{name}...\end{name} wrappers. |
rawLatexStart |
captureLatex(), only when the matching \end{name} can't be found up front (e.g. \newenvironment-defined environments) |
Parser position right after \begin{name}, so the source can be sliced out later once the environment has actually finished parsing. |
rawLatexGen |
captureLatex(), alongside rawLatexStart |
Snapshot of the envSplice generation counter, used to detect whether the stashed rawLatexStart position has been invalidated before trusting it. |
How they fit together
- On
\begin{name},captureLatex()grabs the raw source immediately, or stashes a
start position + generation if the end isn't available yet. - On table close,
setTableLatex()usesrawLatexif captured, else recovers it
fromrawLatexStart/rawLatexGen(if the generation still matches), else
reconstructs it from the rows' owndata-latex. FilterUtil.fixArrayLatex(a new postprocessing filter in theTeX.tspipeline)
walks allmtablenodes and replacesdata-latexwith the cachedrawLatexonly
when the existing value looks broken/missing (FilterUtil.isBrokenArrayLatex).
|
PS: As discussed earlier, what is still missing:
The |
| let depth = 0; | ||
| let nested = 0; | ||
| let i = 0; | ||
| while (i < str.length) { |
There was a problem hiding this comment.
PR #1539 has replaced loops that look through the parser string by hand so that they use GetNext() instead. That way, they will handle comments properly, which this loop doesn't. It would be good to adjust this loop now, so that we don't forget it later when #1539 lands.
The alternative would be to handle comments here, taking into account the legacyComments option (which isn't in place yet, but will be when that PR is merged). But I tried to reduce the number of places where you had to take comments into account by hand, so it would be best to use GetNext() instead. It works like str.charAt(i), but skips spaces and comments, and takes multi-character unicode characters into account (so if you use c = parser.getNext(), you would use parser.i += c.length to move past c).
dpvc
left a comment
There was a problem hiding this comment.
This looks good now. If you merge now, I'll make the changes needed for the loop in the PR for the comments support.
Rows in Tables did not get a meaningful
data-latexattribute. E.g., for\begin{array}{c}a\end{array}we gotdata-latex="{c}".This PR fixes this by explicitly collecting the LaTeX elements and then adding them to the final node, combined with
&.