From 73363ff6cd4e4adef32ec25a499decd12722f92d Mon Sep 17 00:00:00 2001 From: SuchiraD Date: Mon, 15 Dec 2025 13:42:17 +0800 Subject: [PATCH] Added a parameter to allow nested IFs --- README.md | 8 + .../__snapshots__/templating.test.ts.snap | 5438 +++++++++++------ .../ifStatementsOnSameLineSkipValidation.docx | Bin 0 -> 13767 bytes src/__tests__/templating.test.ts | 22 + src/main.ts | 2 + src/processTemplate.ts | 2 +- src/types.ts | 9 + 7 files changed, 3731 insertions(+), 1750 deletions(-) create mode 100644 src/__tests__/fixtures/ifStatementsOnSameLineSkipValidation.docx diff --git a/README.md b/README.md index 782e70c..d512dcd 100755 --- a/README.md +++ b/README.md @@ -161,6 +161,14 @@ const report = await createReport({ * (Default: 1) */ compressionLevel?: number; + /** + * Whether to allow nested IF commands within the same paragraph or table row. + * By default, the library throws an error when it detects an IF command + * nested within another IF command on the same line or table row. + * Set to true to skip this validation check. + * (Default: false) + */ + allowNestedIf?: boolean; }); ``` diff --git a/src/__tests__/__snapshots__/templating.test.ts.snap b/src/__tests__/__snapshots__/templating.test.ts.snap index 35880f0..da99845 100644 --- a/src/__tests__/__snapshots__/templating.test.ts.snap +++ b/src/__tests__/__snapshots__/templating.test.ts.snap @@ -27894,6 +27894,976 @@ exports[`noSandbox Template processing INS in header and footer 1`] = ` exports[`noSandbox Template processing Nested IF statements on same line 1`] = `[Error: Invalid IF command nested into another IF command on the same line: IF b]`; +exports[`noSandbox Template processing Nested IF statements on same line with allowNestedIf: true 1`] = ` +" + + + + + + + + + + + + + This line should be displayed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + text + + + + + + should be visible + + + + + + , + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This should also be visible in the same line + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +" +`; + exports[`noSandbox Template processing Nested IF statements on same row1 1`] = `[Error: Invalid IF command nested into another IF command on the same table row: IF b]`; exports[`noSandbox Template processing Nested IF statements on same row2 1`] = `[Error: Invalid IF command nested into another IF command on the same table row: IF b]`; @@ -57118,7 +58088,360 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "686B7280", + "w14:paraId": "686B7280", + "w14:textId": "77777777", + "w:rsidP": "005B2341", + "w:rsidR": "005B2341", + "w:rsidRDefault": "005B2341", + "w:rsidRPr": "007856C0", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:paraId": "576C70BA", + "w14:textId": "651026D3", + "w:rsidP": "007856C0", + "w:rsidR": "005B2341", + "w:rsidRDefault": "005B2341", + }, + "_children": [ + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "junyao", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": { + "w:type": "spellStart", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:proofErr", + }, + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w:ascii": "Microsoft JhengHei", + "w:cs": "Microsoft JhengHei", + "w:eastAsia": "Microsoft JhengHei", + "w:hAnsi": "Microsoft JhengHei", + "w:hint": "eastAsia", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rFonts", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": { + "w:type": "spellEnd", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:proofErr", + }, + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:paraId": "64757D95", + "w14:textId": "77777777", + "w:rsidP": "005B2341", + "w:rsidR": "005B2341", + "w:rsidRDefault": "005B2341", + "w:rsidRPr": "007856C0", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:paraId": "0A5FB851", + "w14:textId": "77777777", + "w:rsidP": "005B2341", + "w:rsidR": "005B2341", + "w:rsidRDefault": "005B2341", + "w:rsidRPr": "007856C0", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:paraId": "152EA038", + "w14:textId": "264863A8", + "w:rsidP": "005B2341", + "w:rsidR": "005B2341", + "w:rsidRDefault": "005B2341", + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "hong", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": { + "w:type": "spellStart", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:proofErr", + }, + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w:ascii": "MS Gothic", + "w:cs": "MS Gothic", + "w:eastAsia": "MS Gothic", + "w:hAnsi": "MS Gothic", + "w:hint": "eastAsia", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rFonts", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + { + "_attrs": { + "w:type": "spellEnd", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:proofErr", + }, + { + "_attrs": { + "w:rsidRPr": "007856C0", + }, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:paraId": "38C53EF0", "w14:textId": "77777777", "w:rsidP": "005B2341", "w:rsidR": "005B2341", @@ -57132,11 +58455,12 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "576C70BA", - "w14:textId": "651026D3", - "w:rsidP": "007856C0", + "w14:paraId": "020C58AE", + "w14:textId": "4A70A699", + "w:rsidP": "005B2341", "w:rsidR": "005B2341", "w:rsidRDefault": "005B2341", + "w:rsidRPr": "007856C0", }, "_children": [ { @@ -57287,7 +58611,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "64757D95", + "w14:paraId": "2EB2B65F", "w14:textId": "77777777", "w:rsidP": "005B2341", "w:rsidR": "005B2341", @@ -57301,9 +58625,9 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "0A5FB851", + "w14:paraId": "33412000", "w14:textId": "77777777", - "w:rsidP": "005B2341", + "w:rsidP": "007856C0", "w:rsidR": "005B2341", "w:rsidRDefault": "005B2341", "w:rsidRPr": "007856C0", @@ -57315,42 +58639,141 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "152EA038", - "w14:textId": "264863A8", - "w:rsidP": "005B2341", "w:rsidR": "005B2341", - "w:rsidRDefault": "005B2341", "w:rsidRPr": "007856C0", + "w:rsidSect": "0019199C", }, "_children": [ { "_attrs": { - "w:rsidRPr": "007856C0", + "w:h": "16840", + "w:w": "11900", }, - "_children": [ - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "hong", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], + "_children": [], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:r", + "_tag": "w:pgSz", }, { - "_attrs": {}, + "_attrs": { + "w:bottom": "1440", + "w:footer": "708", + "w:gutter": "0", + "w:header": "708", + "w:left": "1440", + "w:right": "1440", + "w:top": "1440", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgMar", + }, + { + "_attrs": { + "w:space": "708", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:cols", + }, + { + "_attrs": { + "w:linePitch": "360", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:docGrid", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:sectPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:body", + }, + ], + "_fTextNode": false, + "_tag": "w:document", +} +`; + +exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Chinese) with custom delimiter 1`] = ` +{ + "_attrs": { + "mc:Ignorable": "w14 w15 w16se w16cid wp14", + "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", + "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", + "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", + "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", + "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", + "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", + "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", + "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", + "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", + "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", + "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", + "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", + "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", + "xmlns:o": "urn:schemas-microsoft-com:office:office", + "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + "xmlns:v": "urn:schemas-microsoft-com:vml", + "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + "xmlns:w10": "urn:schemas-microsoft-com:office:word", + "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", + "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", + "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", + "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", + "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", + "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", + "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", + "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", + "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", + "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", + "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + }, + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w14:paraId": "6BF6C63C", + "w14:textId": "03D60101", + "w:rsidP": "00F95E1F", + "w:rsidR": "00F35C33", + "w:rsidRDefault": "00D85011", + "w:rsidRPr": "00F95E1F", + }, + "_children": [ + { + "_attrs": { + "w:id": "0", + "w:name": "_GoBack", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:bookmarkStart", + }, + { + "_attrs": { + "w:id": "0", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:bookmarkEnd", + }, + { + "_attrs": { + "w:rsidRPr": "00F95E1F", + }, "_children": [ { "_attrs": { @@ -57361,7 +58784,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "", + "_text": "hong", }, ], "_fTextNode": false, @@ -57384,7 +58807,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "007856C0", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -57440,7 +58863,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "007856C0", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -57471,12 +58894,12 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "38C53EF0", - "w14:textId": "77777777", - "w:rsidP": "005B2341", - "w:rsidR": "005B2341", - "w:rsidRDefault": "005B2341", - "w:rsidRPr": "007856C0", + "w14:paraId": "60A37F38", + "w14:textId": "4190B879", + "w:rsidP": "00F95E1F", + "w:rsidR": "00D85011", + "w:rsidRDefault": "00D85011", + "w:rsidRPr": "00F95E1F", }, "_children": [], "_fTextNode": false, @@ -57485,17 +58908,17 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "020C58AE", - "w14:textId": "4A70A699", - "w:rsidP": "005B2341", - "w:rsidR": "005B2341", - "w:rsidRDefault": "005B2341", - "w:rsidRPr": "007856C0", + "w14:paraId": "297A6708", + "w14:textId": "0C0851F2", + "w:rsidP": "00F95E1F", + "w:rsidR": "00D85011", + "w:rsidRDefault": "00D85011", + "w:rsidRPr": "00F95E1F", }, "_children": [ { "_attrs": { - "w:rsidRPr": "007856C0", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -57519,30 +58942,6 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch "_parent": [Circular], "_tag": "w:r", }, - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, { "_attrs": { "w:type": "spellStart", @@ -57554,7 +58953,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "007856C0", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -57610,7 +59009,7 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "007856C0", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -57641,26 +59040,12 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "2EB2B65F", - "w14:textId": "77777777", - "w:rsidP": "005B2341", - "w:rsidR": "005B2341", - "w:rsidRDefault": "005B2341", - "w:rsidRPr": "007856C0", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w14:paraId": "33412000", - "w14:textId": "77777777", - "w:rsidP": "007856C0", - "w:rsidR": "005B2341", - "w:rsidRDefault": "005B2341", - "w:rsidRPr": "007856C0", + "w14:paraId": "6FE1B114", + "w14:textId": "315C8C84", + "w:rsidP": "00F95E1F", + "w:rsidR": "00D85011", + "w:rsidRDefault": "00D85011", + "w:rsidRPr": "00F95E1F", }, "_children": [], "_fTextNode": false, @@ -57669,141 +59054,42 @@ exports[`sandbox Template processing 107a non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidR": "005B2341", - "w:rsidRPr": "007856C0", - "w:rsidSect": "0019199C", - }, - "_children": [ - { - "_attrs": { - "w:h": "16840", - "w:w": "11900", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pgSz", - }, - { - "_attrs": { - "w:bottom": "1440", - "w:footer": "708", - "w:gutter": "0", - "w:header": "708", - "w:left": "1440", - "w:right": "1440", - "w:top": "1440", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pgMar", - }, - { - "_attrs": { - "w:space": "708", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:cols", - }, - { - "_attrs": { - "w:linePitch": "360", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:docGrid", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:sectPr", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:body", - }, - ], - "_fTextNode": false, - "_tag": "w:document", -} -`; - -exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Chinese) with custom delimiter 1`] = ` -{ - "_attrs": { - "mc:Ignorable": "w14 w15 w16se w16cid wp14", - "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", - "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", - "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", - "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", - "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", - "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", - "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", - "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", - "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", - "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", - "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", - "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", - "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", - "xmlns:o": "urn:schemas-microsoft-com:office:office", - "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", - "xmlns:v": "urn:schemas-microsoft-com:vml", - "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "xmlns:w10": "urn:schemas-microsoft-com:office:word", - "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", - "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", - "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", - "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", - "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", - "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", - "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", - "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", - "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", - "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", - "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w14:paraId": "6BF6C63C", - "w14:textId": "03D60101", + "w14:paraId": "6742E140", + "w14:textId": "43F12D8C", "w:rsidP": "00F95E1F", - "w:rsidR": "00F35C33", - "w:rsidRDefault": "00D85011", + "w:rsidR": "00F95E1F", + "w:rsidRDefault": "00F95E1F", "w:rsidRPr": "00F95E1F", }, "_children": [ { "_attrs": { - "w:id": "0", - "w:name": "_GoBack", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:bookmarkStart", - }, - { - "_attrs": { - "w:id": "0", + "w:rsidRPr": "00F95E1F", }, - "_children": [], + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "hong", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:bookmarkEnd", + "_tag": "w:r", }, { - "_attrs": { - "w:rsidRPr": "00F95E1F", - }, + "_attrs": {}, "_children": [ { "_attrs": { @@ -57814,7 +59100,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "hong", + "_text": "", }, ], "_fTextNode": false, @@ -57924,11 +59210,11 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "60A37F38", - "w14:textId": "4190B879", + "w14:paraId": "0BC84266", + "w14:textId": "77777777", "w:rsidP": "00F95E1F", - "w:rsidR": "00D85011", - "w:rsidRDefault": "00D85011", + "w:rsidR": "00F95E1F", + "w:rsidRDefault": "00F95E1F", "w:rsidRPr": "00F95E1F", }, "_children": [], @@ -57938,12 +59224,11 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "297A6708", - "w14:textId": "0C0851F2", + "w14:paraId": "46877074", + "w14:textId": "338B35A6", "w:rsidP": "00F95E1F", - "w:rsidR": "00D85011", - "w:rsidRDefault": "00D85011", - "w:rsidRPr": "00F95E1F", + "w:rsidR": "00F95E1F", + "w:rsidRDefault": "00F95E1F", }, "_children": [ { @@ -57972,6 +59257,30 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_parent": [Circular], "_tag": "w:r", }, + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "xml:space": "preserve", + }, + "_children": [ + { + "_children": [], + "_fTextNode": true, + "_parent": [Circular], + "_text": "", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:t", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:r", + }, { "_attrs": { "w:type": "spellStart", @@ -58070,12 +59379,11 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "6FE1B114", - "w14:textId": "315C8C84", + "w14:paraId": "7E960016", + "w14:textId": "5B8E4394", "w:rsidP": "00F95E1F", - "w:rsidR": "00D85011", - "w:rsidRDefault": "00D85011", - "w:rsidRPr": "00F95E1F", + "w:rsidR": "00F95E1F", + "w:rsidRDefault": "00F95E1F", }, "_children": [], "_fTextNode": false, @@ -58084,8 +59392,8 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "6742E140", - "w14:textId": "43F12D8C", + "w14:paraId": "107BB8B5", + "w14:textId": "46BE478F", "w:rsidP": "00F95E1F", "w:rsidR": "00F95E1F", "w:rsidRDefault": "00F95E1F", @@ -58240,7 +59548,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "0BC84266", + "w14:paraId": "7569C168", "w14:textId": "77777777", "w:rsidP": "00F95E1F", "w:rsidR": "00F95E1F", @@ -58254,11 +59562,12 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "46877074", - "w14:textId": "338B35A6", + "w14:paraId": "752DA1D2", + "w14:textId": "511C7589", "w:rsidP": "00F95E1F", "w:rsidR": "00F95E1F", "w:rsidRDefault": "00F95E1F", + "w:rsidRPr": "00F95E1F", }, "_children": [ { @@ -58409,11 +59718,12 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "7E960016", - "w14:textId": "5B8E4394", + "w14:paraId": "7BC35AB4", + "w14:textId": "77777777", "w:rsidP": "00F95E1F", "w:rsidR": "00F95E1F", "w:rsidRDefault": "00F95E1F", + "w:rsidRPr": "00F95E1F", }, "_children": [], "_fTextNode": false, @@ -58422,19 +59732,145 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "107BB8B5", - "w14:textId": "46BE478F", - "w:rsidP": "00F95E1F", "w:rsidR": "00F95E1F", - "w:rsidRDefault": "00F95E1F", "w:rsidRPr": "00F95E1F", + "w:rsidSect": "0019199C", }, "_children": [ { "_attrs": { - "w:rsidRPr": "00F95E1F", + "w:h": "16840", + "w:w": "11900", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgSz", + }, + { + "_attrs": { + "w:bottom": "1440", + "w:footer": "708", + "w:gutter": "0", + "w:header": "708", + "w:left": "1440", + "w:right": "1440", + "w:top": "1440", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pgMar", + }, + { + "_attrs": { + "w:space": "708", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:cols", + }, + { + "_attrs": { + "w:linePitch": "360", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:docGrid", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:sectPr", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:body", + }, + ], + "_fTextNode": false, + "_tag": "w:document", +} +`; + +exports[`sandbox Template processing 112a failFast: false lists all errors in the document before failing. 1`] = ` +[ + [Error: Error executing command 'notavailable': ReferenceError: notavailable is not defined], + [Error: Error executing command 'something': ReferenceError: something is not defined], + [Error: Invalid command: END-FOR company], + [Error: Unterminated FOR-loop ('FOR company'). Make sure each FOR loop has a corresponding END-FOR command.], +] +`; + +exports[`sandbox Template processing 112b failFast: true has the same behaviour as when failFast is undefined 1`] = `[Error: Error executing command 'notavailable': ReferenceError: notavailable is not defined]`; + +exports[`sandbox Template processing 131 correctly handles Office 365 .docx files 1`] = ` +{ + "_attrs": { + "mc:Ignorable": "w14 w15 wp14", + "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", + "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", + "xmlns:o": "urn:schemas-microsoft-com:office:office", + "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + "xmlns:v": "urn:schemas-microsoft-com:vml", + "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + "xmlns:w10": "urn:schemas-microsoft-com:office:word", + "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", + "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", + "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", + "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", + "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", + "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", + "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", + "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", + "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + }, + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w14:paraId": "3BFEFB25", + "wp14:noSpellErr": "1", + "wp14:textId": "2AD722EA", + "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordml", + }, + "_children": [ + { + "_attrs": { + "w:id": "0", + "w:name": "_GoBack", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:bookmarkStart", + }, + { + "_attrs": { + "w:id": "0", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:bookmarkEnd", + }, + { + "_attrs": { + "w:rsidR": "4C197E99", }, "_children": [ + { + "_attrs": {}, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, { "_attrs": { "xml:space": "preserve", @@ -58444,21 +59880,13 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "hong", + "_text": "first value!", }, ], "_fTextNode": false, "_parent": [Circular], "_tag": "w:t", }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - { - "_attrs": {}, - "_children": [ { "_attrs": { "xml:space": "preserve", @@ -58482,7 +59910,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:type": "spellStart", + "w:type": "gramStart", }, "_children": [], "_fTextNode": false, @@ -58491,26 +59919,12 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "00F95E1F", + "w:rsidR": "4C197E99", }, "_children": [ { "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:ascii": "MS Gothic", - "w:cs": "MS Gothic", - "w:eastAsia": "MS Gothic", - "w:hAnsi": "MS Gothic", - "w:hint": "eastAsia", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rFonts", - }, - ], + "_children": [], "_fTextNode": false, "_parent": [Circular], "_tag": "w:rPr", @@ -58538,7 +59952,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:type": "spellEnd", + "w:type": "gramEnd", }, "_children": [], "_fTextNode": false, @@ -58547,9 +59961,16 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "00F95E1F", + "w:rsidR": "4C197E99", }, "_children": [ + { + "_attrs": {}, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, { "_attrs": { "xml:space": "preserve", @@ -58559,7 +59980,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "", + "_text": " ", }, ], "_fTextNode": false, @@ -58578,57 +59999,105 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w14:paraId": "7569C168", - "w14:textId": "77777777", - "w:rsidP": "00F95E1F", - "w:rsidR": "00F95E1F", - "w:rsidRDefault": "00F95E1F", - "w:rsidRPr": "00F95E1F", + "w14:paraId": "5DAB0FCA", + "w14:textId": "67F23F00", + "w:rsidP": "4C197E99", + "w:rsidR": "4C197E99", + "w:rsidRDefault": "4C197E99", }, - "_children": [], + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w:val": "Normal", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pStyle", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pPr", + }, + ], "_fTextNode": false, "_parent": [Circular], "_tag": "w:p", }, { "_attrs": { - "w14:paraId": "752DA1D2", - "w14:textId": "511C7589", - "w:rsidP": "00F95E1F", - "w:rsidR": "00F95E1F", - "w:rsidRDefault": "00F95E1F", - "w:rsidRPr": "00F95E1F", + "w14:paraId": "4DEFE58C", + "w14:textId": "03755723", + "w:rsidP": "4C197E99", + "w:rsidR": "4C197E99", + "w:rsidRDefault": "4C197E99", }, "_children": [ { - "_attrs": { - "w:rsidRPr": "00F95E1F", - }, + "_attrs": {}, "_children": [ { "_attrs": { - "xml:space": "preserve", + "w:val": "Normal", }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "junyao", - }, - ], + "_children": [], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:t", + "_tag": "w:pStyle", }, ], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:r", + "_tag": "w:pPr", }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:p", + }, + { + "_attrs": { + "w14:noSpellErr": "1", + "w14:paraId": "664E8C7B", + "w14:textId": "388D7CD7", + "w:rsidP": "4C197E99", + "w:rsidR": "4C197E99", + "w:rsidRDefault": "4C197E99", + }, + "_children": [ { "_attrs": {}, "_children": [ + { + "_attrs": { + "w:val": "Normal", + }, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pStyle", + }, + ], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:pPr", + }, + { + "_attrs": { + "w:rsidR": "4C197E99", + }, + "_children": [ + { + "_attrs": {}, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, { "_attrs": { "xml:space": "preserve", @@ -58638,7 +60107,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "", + "_text": "second value!", }, ], "_fTextNode": false, @@ -58652,7 +60121,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:type": "spellStart", + "w:type": "gramStart", }, "_children": [], "_fTextNode": false, @@ -58661,26 +60130,12 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "00F95E1F", + "w:rsidR": "4C197E99", }, "_children": [ { "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:ascii": "Microsoft JhengHei", - "w:cs": "Microsoft JhengHei", - "w:eastAsia": "Microsoft JhengHei", - "w:hAnsi": "Microsoft JhengHei", - "w:hint": "eastAsia", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rFonts", - }, - ], + "_children": [], "_fTextNode": false, "_parent": [Circular], "_tag": "w:rPr", @@ -58708,7 +60163,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:type": "spellEnd", + "w:type": "gramEnd", }, "_children": [], "_fTextNode": false, @@ -58717,9 +60172,16 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:rsidRPr": "00F95E1F", + "w:rsidR": "4C197E99", }, "_children": [ + { + "_attrs": {}, + "_children": [], + "_fTextNode": false, + "_parent": [Circular], + "_tag": "w:rPr", + }, { "_attrs": { "xml:space": "preserve", @@ -58747,30 +60209,13 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch "_tag": "w:p", }, { - "_attrs": { - "w14:paraId": "7BC35AB4", - "w14:textId": "77777777", - "w:rsidP": "00F95E1F", - "w:rsidR": "00F95E1F", - "w:rsidRDefault": "00F95E1F", - "w:rsidRPr": "00F95E1F", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w:rsidR": "00F95E1F", - "w:rsidRPr": "00F95E1F", - "w:rsidSect": "0019199C", - }, + "_attrs": {}, "_children": [ { "_attrs": { - "w:h": "16840", - "w:w": "11900", + "w:h": "16838", + "w:orient": "portrait", + "w:w": "11906", }, "_children": [], "_fTextNode": false, @@ -58780,9 +60225,9 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch { "_attrs": { "w:bottom": "1440", - "w:footer": "708", + "w:footer": "720", "w:gutter": "0", - "w:header": "708", + "w:header": "720", "w:left": "1440", "w:right": "1440", "w:top": "1440", @@ -58794,7 +60239,7 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch }, { "_attrs": { - "w:space": "708", + "w:space": "720", }, "_children": [], "_fTextNode": false, @@ -58826,21 +60271,1008 @@ exports[`sandbox Template processing 107b non-alphanumeric INS commands (e.g. Ch } `; -exports[`sandbox Template processing 112a failFast: false lists all errors in the document before failing. 1`] = ` -[ - [Error: Error executing command 'notavailable': ReferenceError: notavailable is not defined], - [Error: Error executing command 'something': ReferenceError: something is not defined], - [Error: Invalid command: END-FOR company], - [Error: Unterminated FOR-loop ('FOR company'). Make sure each FOR loop has a corresponding END-FOR command.], -] +exports[`sandbox Template processing Access current element index from FOR loop 1`] = ` +" + + + + + + + + + Company + + + + + + + ( + 0 + + + + + + + + + + + + + + + + + ) + + + + + + + : + + + MEGACORP + + + + + + + + + + + + + + + + + + + + + Executives: + + + + + + + + + + + + 0 + + + + + + + + + + + + Excellent CEO + + + + + + + + + + + + 1 + + + + + + + + + + + + Someone + + + + + + + + + + Company + + + + + + + ( + 1 + + + + + + + + + + + + + + + + + ) + + + + + + + : + + + SUPERCORP + + + + + + + + + + + + + + + + + + + + + Executives: + + + + + + + + + + + + 0 + + + + + + + + + + + + John Smith + + + + + + + + + + Company + + + + + + + ( + 2 + + + + + + + + + + + + + + + + + ) + + + + + + + : + + + ULTRACORP + + + + + + + + + + + + + + + + + + + + + Executives: + + + + + + + + + + + + 0 + + + + + + + + + + + + Who else + + + + + + + + + + + + 1 + + + + + + + + + + + + Can't be me + + + + + + + + + + + +" +`; + +exports[`sandbox Template processing Dynamic table columns 1`] = ` +" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Column 1 + + + + + + + + + + + + + + + + + + + Column 2 + + + + + + + + + + + + + + + + + + + Column 3 + + + + + + + + + + + + + + + + + + + + + + + + + + +" +`; + +exports[`sandbox Template processing Dynamic table columns with dynamic rows 1`] = ` +" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Row 1 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 1 + + + + + + + + + + + + + + + + + + Row 1 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 2 + + + + + + + + + + + + + + + + + + Row 1 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 3 + + + + + + + + + + + + + + + + + + + + + + + Row 2 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 1 + + + + + + + + + + + + + + + + + + Row 2 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 2 + + + + + + + + + + + + + + + + + + Row 2 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 3 + + + + + + + + + + + + + + + + + + + + + + + Row 3 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 1 + + + + + + + + + + + + + + + + + + Row 3 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 2 + + + + + + + + + + + + + + + + + + Row 3 + + + + + + + + + + + + + + - + + + + + + + + + + + + + Column 3 + + + + + + + + + + + + + + + + + + + + + + + + + + +" +`; + +exports[`sandbox Template processing HTML in table (see PR #233) 1`] = ` +" + + + + + + + + + + + + + + + + + + + + + + + + + + + + First Name + + + + + + + + + + + + + + + + + + + + + + + + + + Last Name + + + + + + + + + + + + + + + + + + Smith + + + + + + + + + + + + + +" `; -exports[`sandbox Template processing 112b failFast: true has the same behaviour as when failFast is undefined 1`] = `[Error: Error executing command 'notavailable': ReferenceError: notavailable is not defined]`; - -exports[`sandbox Template processing 131 correctly handles Office 365 .docx files 1`] = ` +exports[`sandbox Template processing INS command is an array (see issue #214) 1`] = ` { "_attrs": { - "mc:Ignorable": "w14 w15 wp14", + "mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14", + "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", + "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", + "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", + "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", + "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", + "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", + "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", + "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", + "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", + "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", + "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", "xmlns:o": "urn:schemas-microsoft-com:office:office", @@ -58850,155 +61282,74 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file "xmlns:w10": "urn:schemas-microsoft-com:office:word", "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", + "xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml", + "xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex", + "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", + "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", - "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w14:paraId": "3BFEFB25", - "wp14:noSpellErr": "1", - "wp14:textId": "2AD722EA", - "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordml", - }, - "_children": [ - { - "_attrs": { - "w:id": "0", - "w:name": "_GoBack", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:bookmarkStart", - }, - { - "_attrs": { - "w:id": "0", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:bookmarkEnd", - }, + "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", + }, + "_children": [ + { + "_attrs": {}, + "_children": [ + { + "_attrs": { + "w14:paraId": "3A705D94", + "w14:textId": "044CEA80", + "w:rsidP": "00C863B5", + "w:rsidR": "00C863B5", + "w:rsidRDefault": "00C863B5", + }, + "_children": [ { - "_attrs": { - "w:rsidR": "4C197E99", - }, + "_attrs": {}, "_children": [ { "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "first value!", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - { - "_attrs": { - "xml:space": "preserve", - }, "_children": [ { + "_attrs": { + "w:val": "es-ES", + }, "_children": [], - "_fTextNode": true, + "_fTextNode": false, "_parent": [Circular], - "_text": "", + "_tag": "w:lang", }, ], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:t", + "_tag": "w:rPr", }, ], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:r", - }, - { - "_attrs": { - "w:type": "gramStart", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:proofErr", + "_tag": "w:pPr", }, { - "_attrs": { - "w:rsidR": "4C197E99", - }, + "_attrs": {}, "_children": [ { "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - { - "_attrs": { - "xml:space": "preserve", - }, "_children": [ { + "_attrs": { + "w:val": "es-ES", + }, "_children": [], - "_fTextNode": true, + "_fTextNode": false, "_parent": [Circular], - "_text": "", + "_tag": "w:lang", }, ], "_fTextNode": false, "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - { - "_attrs": { - "w:type": "gramEnd", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:proofErr", - }, - { - "_attrs": { - "w:rsidR": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], "_tag": "w:rPr", }, { @@ -59010,7 +61361,7 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": " ", + "_text": "a,b,c", }, ], "_fTextNode": false, @@ -59029,189 +61380,17 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file }, { "_attrs": { - "w14:paraId": "5DAB0FCA", - "w14:textId": "67F23F00", - "w:rsidP": "4C197E99", - "w:rsidR": "4C197E99", - "w:rsidRDefault": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:val": "Normal", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pStyle", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pPr", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w14:paraId": "4DEFE58C", - "w14:textId": "03755723", - "w:rsidP": "4C197E99", - "w:rsidR": "4C197E99", - "w:rsidRDefault": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:val": "Normal", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pStyle", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pPr", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w14:noSpellErr": "1", - "w14:paraId": "664E8C7B", - "w14:textId": "388D7CD7", - "w:rsidP": "4C197E99", - "w:rsidR": "4C197E99", - "w:rsidRDefault": "4C197E99", + "w14:paraId": "743B5CEB", + "w14:textId": "6C1E73F1", + "w:rsidP": "00C863B5", + "w:rsidR": "00D310BE", + "w:rsidRDefault": "00FE460C", + "w:rsidRPr": "00C863B5", }, "_children": [ { "_attrs": {}, "_children": [ - { - "_attrs": { - "w:val": "Normal", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pStyle", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pPr", - }, - { - "_attrs": { - "w:rsidR": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "second value!", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - { - "_attrs": { - "w:type": "gramStart", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:proofErr", - }, - { - "_attrs": { - "w:rsidR": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - { - "_attrs": { - "w:type": "gramEnd", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:proofErr", - }, - { - "_attrs": { - "w:rsidR": "4C197E99", - }, - "_children": [ - { - "_attrs": {}, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, { "_attrs": { "xml:space": "preserve", @@ -59221,7 +61400,7 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file "_children": [], "_fTextNode": true, "_parent": [Circular], - "_text": "", + "_text": "1,2,3", }, ], "_fTextNode": false, @@ -59239,13 +61418,15 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file "_tag": "w:p", }, { - "_attrs": {}, + "_attrs": { + "w:rsidR": "00D310BE", + "w:rsidRPr": "00C863B5", + }, "_children": [ { "_attrs": { - "w:h": "16838", - "w:orient": "portrait", - "w:w": "11906", + "w:h": "15840", + "w:w": "12240", }, "_children": [], "_fTextNode": false, @@ -59254,13 +61435,13 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file }, { "_attrs": { - "w:bottom": "1440", - "w:footer": "720", + "w:bottom": "1417", + "w:footer": "708", "w:gutter": "0", - "w:header": "720", - "w:left": "1440", - "w:right": "1440", - "w:top": "1440", + "w:header": "708", + "w:left": "1701", + "w:right": "1701", + "w:top": "1417", }, "_children": [], "_fTextNode": false, @@ -59269,7 +61450,7 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file }, { "_attrs": { - "w:space": "720", + "w:space": "708", }, "_children": [], "_fTextNode": false, @@ -59301,1246 +61482,1007 @@ exports[`sandbox Template processing 131 correctly handles Office 365 .docx file } `; -exports[`sandbox Template processing Access current element index from FOR loop 1`] = ` +exports[`sandbox Template processing INS in header and footer 1`] = ` " - + - - + + + + + this goes into the body + + + + + + + + + + + + + + + + + + + + + + + + +" +`; + +exports[`sandbox Template processing Nested IF statements on same line 1`] = `[Error: Invalid IF command nested into another IF command on the same line: IF b]`; + +exports[`sandbox Template processing Nested IF statements on same line with allowNestedIf: true 1`] = ` +" + + + + + + + + + + + + + This line should be displayed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + - - + - Company + text - + - - + + + should be visible + + + + + + , + + + + + - ( - 0 - - + - - + - - + - - + - ) + - + + - - + - : + - - MEGACORP + + + + + - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + This should also be visible in the same line + + + + + + + + + + + + + + + + + + + + + - + - - + - + + + - - + - Executives: + + + + + + + + + + + + + This line should be displayed + + + + + + in a loop - + - - - - - + + + - 0 - + + + + This line should be displayed - - + + + + in a loop - + + + + + + + - + + + + This line should be displayed - - Excellent CEO + + + + + in a loop - + - - - - - + + + - 1 - + + + + This line should be displayed - - + + + + in a loop - + + + + + + + - + + + + This line should be displayed - - Someone + + + + + in a loop - - - + + - - + - Company + + + + + + + + + + + + + + + + + + + + + + - + + - - + - ( - 1 - - + + - - + + - - + - - + - ) + - + - - + - : + - - SUPERCORP + + + + + + - + + + + + - + + + + + - - - + + - - + - - + + + + - - + - Executives: + - - - - - - - - - - 0 + + + + + + + + + + + + + + - + + + + + + + + + + - - John Smith + + + + + + - - - - + + - - + - Company + + - + - - + + + + + + + + + + + + + + - ( - 2 - + - - + - + - - + - ) + - + + - - + - : + - - ULTRACORP + + + + + + - + + + + - + + + + + + + + + - - - + - - + - - + + + - - + - Executives: + - - - - - - - - - + - 0 + + + + + + - - - - Who else - - - - - - - - - - - - 1 + + + - + - + + + + This - + - + + + + line should be displayed in a loop - - Can't be me + + + + + in same line, - - - - - - - - - - -" -`; - -exports[`sandbox Template processing Dynamic table columns 1`] = ` -" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 1 - - - - - - - - - - - - - - - - - - - Column 2 - - - - - - - - - - - - - - - - - - - Column 3 - - - - - - - + + + + + - + - - - - + + + + - + - - - - - - - - - -" -`; - -exports[`sandbox Template processing Dynamic table columns with dynamic rows 1`] = ` -" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Row 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 1 - - - - - - - - - - - - - - - - - - Row 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 2 - - - - - - - - - - - - - - - - - - Row 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 3 - - - - - - - - - - - - - - - - - - - - - - - Row 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 1 - - - - - - - - - - - - - - - - - - Row 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 2 - - - - - - - - - - - - - - - - - - Row 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 3 - - - - - - - - - - - - - - - - - - - - - - - Row 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 1 - - - - - - - - - - - - - - - - - - Row 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 2 - - - - - - - - - - - - - - - - - - Row 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - Column 3 - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + - + - - - - + + + + - + - - - - - - - - - -" -`; - -exports[`sandbox Template processing HTML in table (see PR #233) 1`] = ` -" - - - - - - - - - - - - - - - - - - - - - - - - - - - - First Name - - - - - - - - - - - - - - - - - - - - - - - - - - Last Name - - - - - - - - - - - - - - - - - - Smith - - - - - - - - - - - - - -" -`; - -exports[`sandbox Template processing INS command is an array (see issue #214) 1`] = ` -{ - "_attrs": { - "mc:Ignorable": "w14 w15 w16se w16cid w16 w16cex wp14", - "xmlns:aink": "http://schemas.microsoft.com/office/drawing/2016/ink", - "xmlns:am3d": "http://schemas.microsoft.com/office/drawing/2017/model3d", - "xmlns:cx": "http://schemas.microsoft.com/office/drawing/2014/chartex", - "xmlns:cx1": "http://schemas.microsoft.com/office/drawing/2015/9/8/chartex", - "xmlns:cx2": "http://schemas.microsoft.com/office/drawing/2015/10/21/chartex", - "xmlns:cx3": "http://schemas.microsoft.com/office/drawing/2016/5/9/chartex", - "xmlns:cx4": "http://schemas.microsoft.com/office/drawing/2016/5/10/chartex", - "xmlns:cx5": "http://schemas.microsoft.com/office/drawing/2016/5/11/chartex", - "xmlns:cx6": "http://schemas.microsoft.com/office/drawing/2016/5/12/chartex", - "xmlns:cx7": "http://schemas.microsoft.com/office/drawing/2016/5/13/chartex", - "xmlns:cx8": "http://schemas.microsoft.com/office/drawing/2016/5/14/chartex", - "xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math", - "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", - "xmlns:o": "urn:schemas-microsoft-com:office:office", - "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships", - "xmlns:v": "urn:schemas-microsoft-com:vml", - "xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main", - "xmlns:w10": "urn:schemas-microsoft-com:office:word", - "xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml", - "xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml", - "xmlns:w16": "http://schemas.microsoft.com/office/word/2018/wordml", - "xmlns:w16cex": "http://schemas.microsoft.com/office/word/2018/wordml/cex", - "xmlns:w16cid": "http://schemas.microsoft.com/office/word/2016/wordml/cid", - "xmlns:w16se": "http://schemas.microsoft.com/office/word/2015/wordml/symex", - "xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml", - "xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", - "xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing", - "xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas", - "xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup", - "xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk", - "xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w14:paraId": "3A705D94", - "w14:textId": "044CEA80", - "w:rsidP": "00C863B5", - "w:rsidR": "00C863B5", - "w:rsidRDefault": "00C863B5", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:val": "es-ES", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:lang", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pPr", - }, - { - "_attrs": {}, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "w:val": "es-ES", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:lang", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:rPr", - }, - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "a,b,c", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w14:paraId": "743B5CEB", - "w14:textId": "6C1E73F1", - "w:rsidP": "00C863B5", - "w:rsidR": "00D310BE", - "w:rsidRDefault": "00FE460C", - "w:rsidRPr": "00C863B5", - }, - "_children": [ - { - "_attrs": {}, - "_children": [ - { - "_attrs": { - "xml:space": "preserve", - }, - "_children": [ - { - "_children": [], - "_fTextNode": true, - "_parent": [Circular], - "_text": "1,2,3", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:t", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:r", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:p", - }, - { - "_attrs": { - "w:rsidR": "00D310BE", - "w:rsidRPr": "00C863B5", - }, - "_children": [ - { - "_attrs": { - "w:h": "15840", - "w:w": "12240", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pgSz", - }, - { - "_attrs": { - "w:bottom": "1417", - "w:footer": "708", - "w:gutter": "0", - "w:header": "708", - "w:left": "1701", - "w:right": "1701", - "w:top": "1417", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:pgMar", - }, - { - "_attrs": { - "w:space": "708", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:cols", - }, - { - "_attrs": { - "w:linePitch": "360", - }, - "_children": [], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:docGrid", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:sectPr", - }, - ], - "_fTextNode": false, - "_parent": [Circular], - "_tag": "w:body", - }, - ], - "_fTextNode": false, - "_tag": "w:document", -} -`; - -exports[`sandbox Template processing INS in header and footer 1`] = ` -" - - - - - + + + - this goes into the body + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This + + + + + + + line should be displayed in a loop + + + + + + in same line, + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -60548,8 +62490,6 @@ exports[`sandbox Template processing INS in header and footer 1`] = ` " `; -exports[`sandbox Template processing Nested IF statements on same line 1`] = `[Error: Invalid IF command nested into another IF command on the same line: IF b]`; - exports[`sandbox Template processing Nested IF statements on same row1 1`] = `[Error: Invalid IF command nested into another IF command on the same table row: IF b]`; exports[`sandbox Template processing Nested IF statements on same row2 1`] = `[Error: Invalid IF command nested into another IF command on the same table row: IF b]`; diff --git a/src/__tests__/fixtures/ifStatementsOnSameLineSkipValidation.docx b/src/__tests__/fixtures/ifStatementsOnSameLineSkipValidation.docx new file mode 100644 index 0000000000000000000000000000000000000000..11f147692edaeb965fdedd5ff127758de119c9c2 GIT binary patch literal 13767 zcmeHugzFaP*1k|%{m z;Rq7b^PS2|!f?lH7s@+%WsrCnDbyWZ#nLH~B|d{H&NdI&ri(sFODDWsNJ!`;4BE+TDsTBQ-9 z1BstnPtUJX%iG9)qkt@q2I=4u-d)3cPZ__B4d6VK2||uFWatcM)-YEfp)|#%P}Y_$mR?`DmY3gYAL)yZ&&?;!csOQ?IBzFu zUt*^y!$)*Ne|^;H*L?1910)A`6fwAcwcCNqIJh@?86y^_91Dz8M~j%ohKPR%OPlOL z+5aeXzh44tPDDAqU`SG5kZrHL^drrOG50gW;#UhXO;5;jZsD#FytXMU9~cwf+EhlG zxY)kUI_&|aJ7TzY;iKR`EP)M=|BCW;Rqt;8!%kKGXMZcz)o?sbugkcvNd$J2F9)5 z0@kVKnnQ*dqW4z$3#7#R=LQyfEwEKJN)V#`(8;!)Jsnf5)i-|BX^@!w5 z#HyW;3b&i@ec#SD3=rq^QWByh0r6;o!uVQuL{m5Z)EN9i3R+sl_C03&1NM(EwoUXO#kDtzoJIOh^yX(PsYlypwUHYpCl zN}g1d)=!!-MropJ`Unmx5-j5fT9C+G zFVa%JvP_UG3}kiOF+~U6n8=@HvSi_G(54Ay;hltWJ)GD)VTK5-xBM|!T_MtPNW15c-v#hFh`{t66tX5Y@FKse;uL9j&J~s99L(FH zXiSXToae^#I{ai!CJQt4BWb$_PSXXs`NbKwFLSR^B zA9cxEe*D4xrcBx5gcjSp&CCzS+TJQkTbtx3W6?eT7oV6N0g0U`F<~K7af%Hj%BV=L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!uJ@&YHi@lL5 z%iKThNIG8+4CnPt;l#)B-Y1$AYaRPVQz+3wD;^;{dWk=z_12rwU$fT``l(_l?NM1^ z6D>CoL47t0^lJU+C+*O3wP{9)e3rs%hNb1?JeJJ^Zu-JiV-6b^jyLurcRn0tktx{I z`pBov6-rDEQ5v!9MS<0%Cb4fj$?!DjiLe?eX6Nr*n z&C$q7Mx5pf%fECM+HE*^07X#SO@w9E4q{RzAa&Np#dwLW0#aHxyn zn%f8a_1}x=An#~^Db?S9@$!#<<`4Nd-@nL7{#C(W`T2i90f0mx1MN?2{a=B<5|{sg z)&q%1|3PE^75-PA+aF*6pdap^@c)DL_N%5}xle!SdPMj?m{7l}_;tJZ4;9ep|5Wkk z&EsF;zwTxH0k6RM7yREl8^3~oO_l!uhg1F&{7d5etA<~5xj!^~r240Zzhrj5;{O`3 y|3Cu(!88ECe}wN};eQ=4{|pzR{}cS5!>61iIM6(P`xXQi& { + const template = await fs.promises.readFile( + path.join( + __dirname, + 'fixtures', + 'ifStatementsOnSameLineSkipValidation.docx' + ) + ); + + const result = await createReport( + { + noSandbox, + template, + data: { ranges: [1, 2, 3, 4, 5] }, + cmdDelimiter: ['{{', '}}'], + allowNestedIf: true, + }, + 'XML' + ); + expect(result).toMatchSnapshot(); + }); + it('Dynamic table columns', async () => { const template = await fs.promises.readFile( path.join(__dirname, 'fixtures', 'dynamic-columns.docx') diff --git a/src/main.ts b/src/main.ts index 5749068..87f5ad4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -166,6 +166,7 @@ async function createReport( indentXml: options.indentXml ?? true, preserveSpace: options.preserveSpace ?? true, compressionLevel: options.compressionLevel ?? 1, + allowNestedIf: options.allowNestedIf ?? false, }; const xmlOptions = { literalXmlDelimiter, @@ -351,6 +352,7 @@ export async function listCommands( indentXml: true, preserveSpace: true, compressionLevel: 1, + allowNestedIf: false, }; const { jsTemplate, mainDocument, zip } = await parseTemplate(template); diff --git a/src/processTemplate.ts b/src/processTemplate.ts index f617237..9077ad3 100755 --- a/src/processTemplate.ts +++ b/src/processTemplate.ts @@ -826,7 +826,7 @@ const processForIf = async ( const curLoop = getCurLoop(ctx); if (!(curLoop && curLoop.varName === varName)) { // Check whether we already started a nested IF without and END-IF for this p or tr tag - if (isIf) { + if (isIf && !ctx.options.allowNestedIf) { const parentPorTrNode = findParentPorTrNode(node); const parentPorTrNodeTag = parentPorTrNode != null diff --git a/src/types.ts b/src/types.ts index 608fce2..015568b 100755 --- a/src/types.ts +++ b/src/types.ts @@ -145,6 +145,14 @@ export type UserOptions = { * (Default: 1) */ compressionLevel?: number; + /** + * Whether to allow nested IF commands within the same paragraph or table row. + * By default (false), the library throws an error when it detects an IF command + * nested within another IF command on the same line or table row. + * Set to true to skip this validation check. + * (Default: false) + */ + allowNestedIf?: boolean; }; export type CreateReportOptions = { @@ -163,6 +171,7 @@ export type CreateReportOptions = { indentXml: boolean; preserveSpace: boolean; compressionLevel: number; + allowNestedIf: boolean; }; export type SandBox = {