-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix #946 #949
Fix #946 #949
Conversation
I wonder if we can test some these behaviors with unit tests that verify that one |
I put in the test case from #946 into the screenshotter tests. I haven't thought of a more elegant way to test the parse comparison. |
I was hoping the following added tests in describe("An aligned environment", function() {
...
it("should eliminate final newline 1", function() {
expect("\\begin{aligned}x&y\\\\&z\\\\\\end{aligned}")
.toParseLike("\\begin{aligned}x&y\\\\&w\\end{aligned}");
});
it("should eliminate final newline 2", function() {
expect("\\begin{aligned}x&y\\\\z&w\\\\\\end{aligned}")
.toParseLike("\\begin{aligned}x&y\\\\z&w\\end{aligned}");
}); I guess we could add a test that confirms the right number of rows in the parsed align table. |
@edemaine thanks for checking that. I would've expected that to work. :\ |
The code that that removes a trailing Maybe I can think of a unit test that works on Not right away though. My next few days are pretty booked up. If someone would like to suggest a test sooner than that, feel free. |
But the Parser.js imports environments.js which imports array.js and we do call the handler for a particular environment when we encounter it from Parser.js. I'd be interested in seeing how those parse trees diff for those case where we expect them to be the same. |
The most recent commit fixes a bug and adds two tests that confirm the correct number of rows. |
Can anyone suggest why Travis has not completed its check? Or what I can try to get it working? When I ran |
@ronkok not sure why. I'm going to "update branch" and see if that does anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in reviewing this. Code changes look good, requesting a minor update to one of the tests. See inline comments for details.
test/katex-spec.js
Outdated
@@ -1251,6 +1251,11 @@ describe("A begin/end parser", function() { | |||
it("should allow \\cr as a line terminator", function() { | |||
expect("\\begin{matrix}a&b\\cr c&d\\end{matrix}").toParse(); | |||
}); | |||
|
|||
it("should eat a final newline", function() { | |||
const m3 = getParsed("\\begin{matrix}a&b\\\\ c&d \\end{matrix}")[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the TeX code be:
\\begin{matrix}a&b\\\\ c&d \\\\ \\end{matrix}
to include the extra newline that's supposed to get eaten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right you are. I'll make the change and resubmit.
&& lastRow.value.length === 1 | ||
&& lastRow.value[0].value.length === 0) { | ||
&& lastRow.length === 1 | ||
&& lastRow[0].value.value[0].value.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this... I wish our parse tree was nicer.
@kevinbarabash Thank you. That did the trick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@ronkok thanks for fixing that test. |
FWIW, I think this rather significant bug fix is worth a release. Thanks guys for making it happen! |
Issue #946 identified a case in which
array.js
ate the final row of a well-writtenaligned
environment.This PR modifies code from PR #479 to fix this problem and to also continue to eat a trailing
\\
submitted to any environment.