From 77a0e00fa1974ac2e25cd4f6069aa87e2d0f04e0 Mon Sep 17 00:00:00 2001 From: k-kumar-01 Date: Fri, 11 Jun 2021 11:08:12 +0530 Subject: [PATCH] feat: add text and emphasis transformers - #397 Declares OOXML as instance variable Signed-off-by: k-kumar-01 --- .../src/CiceroMarkToOOXMLTransformer.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/markdown-docx/src/CiceroMarkToOOXMLTransformer.js b/packages/markdown-docx/src/CiceroMarkToOOXMLTransformer.js index 4e9bc636..9d9bd07d 100644 --- a/packages/markdown-docx/src/CiceroMarkToOOXMLTransformer.js +++ b/packages/markdown-docx/src/CiceroMarkToOOXMLTransformer.js @@ -30,13 +30,19 @@ const definedNodes = { emphasize: 'org.accordproject.commonmark.Emph', }; -let globalOOXML = ''; - /** * Transforms the ciceromark to OOXML */ class CiceroMarkToOOXMLTransfomer { + + /** + * Declares the OOXML variable + */ + constructor() { + this.globalOOXML = ''; + } + /** * Gets the class of a given CiceroMark node. * @@ -77,7 +83,7 @@ class CiceroMarkToOOXMLTransfomer { node.nodes.forEach(subNode => { ooxml += this.getNodes(subNode, counter,); }); - globalOOXML = `${globalOOXML}${ooxml}`; + this.globalOOXML = `${this.globalOOXML}${ooxml}`; } return ''; } @@ -91,12 +97,12 @@ class CiceroMarkToOOXMLTransfomer { * @returns {string} Converted OOXML string i.e. CicecoMark->OOXML */ toOOXML(ciceromark, counter, ooxml = '') { - globalOOXML = ooxml; + this.globalOOXML = ooxml; ciceromark.nodes.forEach(node => { this.getNodes(node, counter); }); - globalOOXML = wrapAroundDefaultDocxTags(globalOOXML); - return globalOOXML; + this.globalOOXML = wrapAroundDefaultDocxTags(this.globalOOXML); + return this.globalOOXML; } }