-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge case where regex in row_spec_latex fails #881
Comments
I can confirm the bug in the latest devel version. I'll take a look... |
This is a tricky issue to fix. The problem is that at this point the code is working with a single long character string containing the latex for the whole table, and it needs to make changes to some of the lines within the table. It is using regular expressions to try to identify the substring corresponding to each line and then substituting the modified version of that substring, and as you saw, sometimes it gets it wrong. I think I'm unlikely to be able to fix it without messing up something else, so all I can offer is a workaround to make sure this never happens. If you replace
I think someone else will have to put together a PR that doesn't require the workaround. |
yeah, that makes sense. I'll try your solution, but by the looks of it it solves my immediate problem, cheers! btw, do you think maybe a solution might be to add $ and ^ to the regex and thereby make sure it's matching the whole string? (I'm not at my computer to test this now, but I'm now thinking the same issue might occur in the first column as well? or maybe not because of the extra &.. 🐤) |
No, you don't want to match the whole string. The whole table is in one string, with each line just being a substring in it. It would probably work to look for the new line marker ("\" in LaTeX), but that's tricky because the table might contain escaped backslashes, and can contain both escaped and unescaped LaTeX macros, so it has to be done very carefully. I concluded that a bigger change is needed: maybe split the table into individual rows so your suggestion would work, or go even further and use the |
There is a regex in the
row_spec_latex
function, which fails if two rows differ only in the last column, where one is empty, and the other has a value.In that case no duplicated rows are registered, so the regex below replaces the wrong row.
The two examples below first show an example of the function working fine, because row 3 only matches row 3.
In the second example however, row 3 without the "extra" is also matched by row 2, and the striping gets misplaced..
The text was updated successfully, but these errors were encountered: