Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/processTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,10 @@ const processCmd: CommandProcessor = async (
// END-FOR
// END-IF
} else if (cmdName === 'END-FOR' || cmdName === 'END-IF') {
processEndForIf(node, ctx, cmd, cmdName, cmdRest);
const result = processEndForIf(node, ctx, cmd, cmdName, cmdRest);
if (typeof result === 'string') {
return result;
}

// INS <expression>
} else if (cmdName === 'INS') {
Expand Down Expand Up @@ -897,7 +900,7 @@ const processEndForIf = (
cmd: string,
cmdName: string,
cmdRest: string
): void => {
): string | undefined => {
const isIf = cmdName === 'END-IF';
const curLoop = getCurLoop(ctx);
if (!curLoop)
Expand Down Expand Up @@ -957,6 +960,15 @@ const processEndForIf = (
} else {
// loop finished
ctx.loops.pop();
const paragraphPropertiesNode =
node._parent?._parent?._parent?._children[0];
if (
paragraphPropertiesNode &&
paragraphPropertiesNode._children[0] &&
(paragraphPropertiesNode._children[0] as NonTextNode)._tag === 'w:sectPr'
) {
return ''; // If this paragraph has section properties, we don't want to remove it, so we return an empty string
}
}
};

Expand Down
Loading