feat(markdown-transform): add transformation CiceroMark<->OOXML#424
feat(markdown-transform): add transformation CiceroMark<->OOXML#424algomaster99 merged 10 commits intoalgoo-ooxmlfrom
Conversation
|
@dselman @algomaster99 Also, the build fails due to a test. Merging PR will fix this. |
algomaster99
left a comment
There was a problem hiding this comment.
Dropped the comments. Did you even try running the CLI with your changes? It was broken both ways (CiceroMark <-> OOXML) as I have elaborated in the two comments below.
| }, | ||
| ooxml: { | ||
| docs: 'OOXML', | ||
| fileFormat: 'binary', |
There was a problem hiding this comment.
It is not binary. It should be utf-8 only. If you read the output after executing ./packages/markdown-cli/index.js transform --from ciceromark_parsed --to ooxml --input input.json, you will just get <binary data> in the console. Moreover, you can even read and understand what's written in the file so binary makes no sense here.
| docs: 'OOXML', | ||
| fileFormat: 'binary', | ||
| ciceromark_parsed: async(input) => { | ||
| return OoxmlTransformer.toCiceroMark(input); |
There was a problem hiding this comment.
This would throw an error because toCiceroMark is not a static method.
Try taking inspiration from |
|
@algomaster99 Another approach for this can be to convert the OOXML to JSON using Which approach should I go for? |
| const PdfTransformer = require('@accordproject/markdown-pdf').PdfTransformer; | ||
| const DocxTransformer = require('@accordproject/markdown-docx').DocxTransformer; | ||
| const OoxmlTransformer = require('@accordproject/markdown-docx').OoxmlTransformer; | ||
| const CiceroMarkToOOXMLTransfomer = require('@accordproject/markdown-docx').CiceroMarkToOOXMLTransfomer; |
There was a problem hiding this comment.
Please follow the same naming convention as the other transformers. The name of the class is the transformation, while the methods indicate what is being transformed.
What do you mean? You can configure the OOXML for acceptance of delivery in |
I mean for the other way round, where we convert from Also, regarding Dan's changes, we would need to change the naming. Currently, I am thinking of keeping the former same and change. Earlier I thought of Though, both the functions carry |
Yes, we want a single class (OOXMLTransformer?) that can perform OOXML <-> CiceroMark via 2 separate methods. This is the pattern we have used for all the other transformers. And: |
@dselman Your thoughts, @algomaster99 |
Always in for making the codebase more consistent. |
If you check some of the other transforms you will see that the single public (exported) class delegates to visitor classes etc. for the different transforms to keep the code modular and easier to maintain. |
|
@dselman @algomaster99 |
My guess is that your input OOXML is being used as a file path. Note the ENAMETOOLONG error. |
Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
852dadc to
a15508f
Compare
|
@dselman @algomaster99 |
dselman
left a comment
There was a problem hiding this comment.
Getting close! Couple of questions...
| }, | ||
| ooxml: (input) => { | ||
| const t = new OOXMLTransformer(); | ||
| return t.toOOXML(input).ooxml; |
There was a problem hiding this comment.
Do we need the ooxml child attribute here? The other transformations just return the output.
There was a problem hiding this comment.
@dselman
Yes, actually OOXMLTransfomer returns {ooxml, variableFrequency}.
There was a problem hiding this comment.
What is variable frequency and why does the caller need it?
There was a problem hiding this comment.
It returns the count of different variables present in a template.
We need it because there is a requirement to provide a unique identifier to rich text input in MS-WORD which is generated using this.
There was a problem hiding this comment.
What is variable frequency and why does the caller need it?
MS Word would require it for rendering all the variables.
There was a problem hiding this comment.
Generating a unique idea is not the problem but getting back to attach event listeners is. Moreover, we want to keep this ID as close as possible to the actual variable name as they are means to inform the client which variable they are interacting with.
Shipper1 is the title and if someone edits, it would mean that they want to modify the shipper variable.
There was a problem hiding this comment.
I am looking for ways to make us not require to export the counter variable. But we shall use it for OOXML generation as we want to make the title of the content control unique.
There was a problem hiding this comment.
@K-Kumar-01 I think you can remove exporting of counter. I can demonstrate how we can do without it in the next meeting.
There was a problem hiding this comment.
@algomaster99
That would need refactoring first then. I will create a separate PR that will deal with the above.
Once that is done, I will merge it.
Since, currently only windows are available on my pc it might take some time to close these PRs.
PS: HDD corruption made Linux vanish 😢. Will reinstall it.
| return t.toCiceroMark(input, options); | ||
| }, | ||
| }, | ||
| ooxml: { |
There was a problem hiding this comment.
Don't you also need to register the ciceromark_parsed -> ooxml transform?
There was a problem hiding this comment.
The transformer is converting both ooxml<->Ciceromark
There was a problem hiding this comment.
My point is it looks like you only registered the ciceromark_parsed -> ooxml transformation. You will need to add a similar block to do the reverse, under a new ooxml block.
There was a problem hiding this comment.
Please check that you can transform from a markdown file to ooxml and the reverse by running the CLI.
There was a problem hiding this comment.
@dselman
AFAIR, I was able to convert both transformations ooxml<->ciceromark_parsed when I pushed the commit. However, I will recheck and let you know ASAP.
There was a problem hiding this comment.
@dselman
Apologies for the delay. I have checked and it converts CiceroMark_parsed <-> OOXML. So, this feature is as we expected.
| describe('markdown-cli (ooxml)', () => { | ||
| // Partial Acceptance test | ||
| const inputOOXMLFile = path.resolve(__dirname, 'data/acceptance', 'partial_acceptance.xml'); | ||
| const expectedCiceroMarkParsed = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'data/acceptance', 'partial_acceptance.json'), 'utf8')); | ||
|
|
||
| describe('#parse', () => { | ||
| it('should generate a ciceromark_parsed from ooxml', async () => { | ||
| const result = await Commands.transform(inputOOXMLFile, 'ooxml', [], 'ciceromark_parsed', null, {}, {}); | ||
| JSON.parse(result).should.deep.equal(expectedCiceroMarkParsed); | ||
| }); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
You can probably check for roundtrip by passing the roundtrip: true option. Check example.
| }, | ||
| ooxml: (input) => { | ||
| const t = new OOXMLTransformer(); | ||
| return t.toOOXML(input).ooxml; |
There was a problem hiding this comment.
What is variable frequency and why does the caller need it?
MS Word would require it for rendering all the variables.
| }); | ||
|
|
||
| describe('#ooxml', () => { | ||
| it('ooxml->ciceromark_parsed', async () => { |
There was a problem hiding this comment.
Spaces before and after ->.
|
@K-Kumar-01 Did you get time to look at the changes I suggested? |
@algomaster99 |
Roundtrip check for test in cli Remove the json file Test statement changes Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
algomaster99
left a comment
There was a problem hiding this comment.
Looks good to me. The tests are failing though, and the reason is not #422 .
I have the reason. I deleted the json for the wrong package, mistakenly. 😅 |
Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
algomaster99
left a comment
There was a problem hiding this comment.
I have another general suggestion about the naming of the test file and I know it is coming quite in this review process. Partial acceptance sounds like that your test is paritally correct. I think omitted-acceptance-of-delivery would be a better name.
@dselman I think @K-Kumar-01 is done with this. Could you look at it again?
| it('should roundtrip ciceromark_parsed <-> ooxml', async () => { | ||
| const result = await Commands.transform(inputOOXMLFile, 'ooxml', [], 'ciceromark_parsed', null, {}, { roundtrip: true }); | ||
| result.should.equal(fs.readFileSync(inputOOXMLFile, 'utf-8')); | ||
| }); |
There was a problem hiding this comment.
I think you would also need to check for going from cicero mark to OOXML. And for that, you would need to create a JSON file partial_acceptance.json.
There was a problem hiding this comment.
@algomaster99 Will update the filenames and tests ASAP.
There was a problem hiding this comment.
I think you would also need to check for going from cicero mark to OOXML. And for that, you would need to create a JSON file partial_acceptance.json.
@algomaster99
Regarding this, we already check for the conversion test so why do we do this one. roundtrip: true also pass so I am not able to understand the need to add this.
In transform.js, we have already done the test for both.
There was a problem hiding this comment.
Regarding this, we already check for the conversion test so why do we do this one. roundtrip: true also pass so I am not able to understand the need to add this.
We aren't checking for equality for ciceromark_parsed in between so that's why it's needed.
In transform.js, we have already done the test for both.
Yeah, I am aware. I even pointed this out in the meeting. With that logic, I think we can completely remove any testing related to this PR from markdown-cli.
Signed-off-by: K-Kumar-01 <kushalkumargupta4@gmail.com>
|
I am not understanding why the test fails. |
|
@K-Kumar-01 It's difficult to find out this way. You can use diff editors or just run |
Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
add json file for test update the transform function Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
algomaster99
left a comment
There was a problem hiding this comment.
One minor change and then we can merge.
Also, you haven't merged the latest changes correctly and that's why changes related to thematic break, etc are appearing in this PR.
| const partialAcceptanceXML = fs.readFileSync(path.resolve(__dirname, 'data/acceptance', 'omitted-acceptance-of-delivery.xml'), 'utf8'); | ||
| const partialAcceptanceCiceroMarkParsed = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'data/acceptance', 'omitted-acceptance-of-delivery.json'), 'utf8')); |
There was a problem hiding this comment.
If you have changed to omitted above, do those changes here as well.
Signed-off-by: k-kumar-01 <kushalkumargupta4@gmail.com>
There was a problem hiding this comment.
@dselman I think this is done. Could you have a final look and if you think alike, go ahead with squash and merge?





Signed-off-by: K-Kumar-01 kushalkumargupta4@gmail.com
Adds the transformation
CiceroMark<->OOXMLin the transformation graph.Changes
OOXML->CiceroMarkCiceroMark->OOXML.Author Checklist
--signoffoption of git commit.masterfromfork:branchname