feat(markdown-docx): add optional transformer - #397#441
feat(markdown-docx): add optional transformer - #397#441algomaster99 merged 5 commits intoalgoo-ooxmlfrom
Conversation
transformation logic:OOXML<->CiceroMark tests for optional update tests for other(xml changes in variable and clause) Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
dselman
left a comment
There was a problem hiding this comment.
I'm finding the code hard to follow, as you add more special cases. In general terms I would structure the code as a transformation from treeA -> treeB with a switch statement to handle different nodes in treeA, converting them to nodes in treeB. In particular I found the part where you compare lengths of arrays to hard coded values confusing.
| </w:rPr> | ||
| <w:alias w:val="Shipper1 | org.accordproject.organization.Organization"/> | ||
| <w:tag w:val="shipper"/> | ||
| <w:tag w:val="org.accordproject.ciceromark.Variable----shipper"/> |
There was a problem hiding this comment.
What are tag and alias used for? Could we make them consistent. E.g.
org.acme.Thing/name ?
There was a problem hiding this comment.
w:alias: the name which is displayed by word on hovering on content control.
w:tag: Bind the office JS API handles for elements with similar tags.
Could we make them consistent. E.g.org.acme.Thing/name ?
I do not understand what exactly you mean here. I have introduced the first thing to distinguish the type of content control as we discussed in the meeting.
Actually, this is what I am doing but I was handling it with if statements.
I agree here but this is done to insert the sibling children of a node under the same parent. |
|
@algomaster99 |
|
@dselman @algomaster99 |
algomaster99
left a comment
There was a problem hiding this comment.
First iteration of review done. Look at the comments.
Also, add a test case when hasSome is false. You will need to see how nodes behave in that case. Currently, you have made nodes = whenSome.
transform both whenSome and whenNone nodes add tests for hasSome:false update the xml Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
|
@algomaster99 EDIT: The conditions may seem to be a bit terrifying 😅 but it was the only implementation I can think of. |
algomaster99
left a comment
There was a problem hiding this comment.
Dropped some comments which I think you really need to look into. Please try to incorporate them. I will try to take out some time and refactor your code a bit over the weekend.
…iables, add generic method for nesting Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
|
@algomaster99 |
|
@algomaster99 @dselman |
algomaster99
left a comment
There was a problem hiding this comment.
Left some comments. There are some things I don't understand so I might give more reviews on this PR in future.
| // Contains the tags for optional or conditional nodes. | ||
| // Optional/conditional themselves can act contain multiple inline nodes. | ||
| // However, they are not block elements and are present inside | ||
| // paragraph or clause nodes so an extra array is needed to store their info. |
Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
|
@algomaster99 |
|
|
||
| /** | ||
| * Inserts Baskerville Old Face font family OOXML tag. | ||
| * Inserts Baskerville Old Face font family OOXML tag to distinguish nodes of whenNone/whenFalse |
There was a problem hiding this comment.
Try to put yourself in a person's shoe who is not that familiar with this code.
They try to interpret this function and they found out that it has something to do with optional or condition nodes. They look at the CiceroMark properties and see that in fact, whenSome and whenNone exist. However, they would definitely question "what are whenTrue and whenFalse for?" Given then context, they would deduce that whenTrue and whenFalse are also attributes in the CiceroMark which is false!
In fact this is true wherever you have metioned the above terms so you need to rectify that. Probably a better wording would be:
Inserts a different fontface so that the hidden contents can be distinguished. There can be two types of hidden content -
1) when `hasSome` is true, the content inside `whenNone` is hidden.
2) when `hasSome` is false, the content inside `whenSome` is hidden.
I know this takes time and it may not be commensurate for the time you spend thinking over it. But I can promise you that you only will forget the same code you have written 4 months later given you don't work on this project for that long.
There was a problem hiding this comment.
@algomaster99 Actually, this is not quite the right description. the font family is for else condition always. It does not matter whether they are hidden or visible.
There was a problem hiding this comment.
If they are visible, then we do not want to change the font.
There was a problem hiding this comment.
@algomaster99
Does this sound right?
Inserts a different font family so that the conditional/optional content(else condition) can be distinguished. They can be of following types:-
1) `whenNone` nodes for optional(to be distinguished from `whenSome`)
2) `whenFalse` nodes for conditional(to be distinguished from `whenTrue`)There was a problem hiding this comment.
Okay, so the font face has been introduced to handle conditional as well? I thought you would make a separate PR for that.
There was a problem hiding this comment.
@algomaster99
It will automatically deal with that when I make the PR for conditional. Optional and Conditional are identically same. Just some node keys changing.
There was a problem hiding this comment.
@algomaster99
I will update the JSDOC for conditional in that PR. Currently, I will only make it only for optional. Does it sound fine?
There was a problem hiding this comment.
Sounds good. You could have applied the same logic for the variables too but that's okay. We can merge this one.
Anyway, just try to focus on one feature at a time. It causes confusion otherwise.
|
@K-Kumar-01 Shall I proceed for merge if all tests are passing? |
Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
|
@algomaster99 Sure |


Signed-off-by: k-kumar-01 kushalkumargupta4@gmail.com
Add the logic to transform
Optionalnodes fromCiceroMark<->OOXML.Changes
Author Checklist
--signoffoption of git commit.masterfromfork:branchname