Conversation
Codecov Report
@@ Coverage Diff @@
## master #2138 +/- ##
==========================================
+ Coverage 94.75% 94.75% +<.01%
==========================================
Files 82 83 +1
Lines 5315 5316 +1
Branches 927 927
==========================================
+ Hits 5036 5037 +1
Misses 256 256
Partials 23 23
Continue to review full report at Codecov.
|
Move \newcommand back to macros for now
|
@ylemkimon Could you clarify the sense in which |
|
@edemaine Furthermore, this is required in two pending PRs:
|
| it("should prevent expansion", () => { | ||
| expect`\gdef\foo{1}\foo`.toParse(); | ||
| expect`\gdef\foo{1}\foo`.toParse(new Settings({maxExpand: 2})); | ||
| expect`\gdef\foo{1}\foo`.not.toParse(new Settings({maxExpand: 1})); |
There was a problem hiding this comment.
It looks like the behavior was wrong before this PR. It it safe to say that the following will pass now?
expect`\gdef\foo{1}\foo`.toParse(new Settings({maxExpand: 1}));
There was a problem hiding this comment.
@kevinbarabash That seems better!
| case "internal": { | ||
| break; | ||
| } |
There was a problem hiding this comment.
In reality we should never have to handle this case since all all internal nodes in the AST should get expanded, right?
There was a problem hiding this comment.
I believe the \def function returns an internal node (at least that's what the PR main text says), and this throws it away.
Edit: Oops, I see: yes, maybe not possible in render-a11y-string.js, given that they're eaten by Parser.js. This might just be to handle lint?
| @@ -0,0 +1,79 @@ | |||
| //@flow | |||
There was a problem hiding this comment.
The name of this file feels a bit misleading. Could you renamed it to internal.js?
There was a problem hiding this comment.
I think assignment refers to \def and \gdef which is the purpose of this file. (The idea is that other commands might also generate internal.) I could see calling it def.js. The name assignment.js is presumably future-proofing for an eventual \let definition? But I'd still lean toward def.js.
There was a problem hiding this comment.
The reason why I suggested internal.js was that it also handles \global, but if \global can only be used with \def then def.js should be fine as well.
|
@ylemkimon Thanks for the explanation! I see now and agree. Ideally we should mention in a comment somewhere that KaTeX macros correspond to TeX gullet and KaTeX functions correspond to TeX stomach. I was (mostly) aware of this, but wasn't really aware of how
|
| expect`\global\def\foo{}\foo`.toParseLike``; | ||
| // TODO: This doesn't work yet; \global needs to expand argument. | ||
| //expect`\def\DEF{\def}\global\DEF\foo{}\foo`.toParseLike``; | ||
| expect`\def\DEF{\def}\global\DEF\foo{}\foo`.toParseLike``; |
There was a problem hiding this comment.
It turns out this fixes another test case.
k4b7
left a comment
There was a problem hiding this comment.
LGTM. Thanks for improving the behavior of \def.
TeX primitive commands are more like functions, so move to functions and return new parseNode type
internal, which is skipped duringparseExpression.