-
-
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
Add assignString to AssignmentNodes #2980
Conversation
return new AssignmentNode(new SymbolNode(name), value) | ||
const assignmentNode = new AssignmentNode(new SymbolNode(name), value) | ||
assignmentNode.assignString = assignString | ||
return assignmentNode |
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.
@josdejong please let me know what you think about this, because it does not feel totally right to me as well doing it by assigning the assignString directly to the object. Maybe its better to provide it as param? but then some more checks in the constructor would be needed, because of node.index
which is optional. Or as a separate chainable method, like
return new AssignmentNode(...)
.setAssignString(assignString)
Again, all this is actually because of the :=
assignString for the toTex representation.
Found the commit were the assignment was changed to |
Thanks for working out this PR @webdeb . It is an interesting idea to make the assigns string ( There are workarounds for this BTW: with a simple regex you can replace |
Thank you for looking into it!
I agree, I just thought, that for some cases, you want this to be a real variable definition, like:
whatever.. also, wasn't sure if this was a strong requirement back then. So I thought a flexible solution would fit all needs, if required. |
Btw, before opening a new issue, can the handler be globally configured or would you suggest just monkey-patching the |
I've listed the change from
You can always write a wrapper function |
I'll close this PR now since we will go for another solution (simply replacing |
The assignment operator used in |
@josdejong I guess, you mean the other way around ;)? |
😂 ha, sorry, you're right, I updated my comment. |
Thank you! |
This PR replaces the default behaviour of AssignmentNode and FunctionAssignmentNode to use
:=
as the Latex output for assignment String. It also forces the ConditionalNode to use:=
for the condition, trueExpr and falseExpr.Additionally it uses the
assignString
intoHTML
andtoString
methods.In the usual cases for AssignmentNode and FunctionAssignmentNode the user can decide which
assignString
to use. Either by providing the token as "(a := 3)" or by changing the assignString programmatically. Like:The default assignString is
=
, as the:=
is mostly used for definitions, like in the conditional node case. And most visitors are used to the simple=
syntax.#2979