@gitbrent I've encountered another error in the parseTextToLines() function.
When you have an auto paged table, and you have text that is an array for some reason other than to add the breakline option (e.g. to add superscript) and that cell is in the last row on an autopaged table on a slide, it gets broken up into multiple table rows, the superscript goes into it's own row on the new slide, and powerpoint complains that the presentation needs repairs.
each item in the text array ends up getting treated as a separate tokenized array in inputLines2, which then gets treated as separate table rows later. I think you have some logic to reconcile this somewhere because the issue only crops up when the rows are split between slides.
I think the correct way to handle this is to ensure all the items that were in the text array go into the same tokenized lineCells array, unless they have the breakLine option, or a newline character in which case you add the breakLine option in step 2 on line 86.
This PR refactors step 3 by moving the lineCells declaration outside of the processing of inputLines1, it still checks if the last item in lineCells has options.breakLine = true, and if so appends it to inputLines2 and flushes the buffer (to preserve the existing functionality), then after iterating over all the items in inputLines1 it appends the remaining lineCells to inputLines2, thus reconciling the items from the text array that were separated in step 2.
@gitbrent I've encountered another error in the parseTextToLines() function.
When you have an auto paged table, and you have text that is an array for some reason other than to add the breakline option (e.g. to add superscript) and that cell is in the last row on an autopaged table on a slide, it gets broken up into multiple table rows, the superscript goes into it's own row on the new slide, and powerpoint complains that the presentation needs repairs.
I have a simple example repository to preproduce this issue here: https://github.com/mikemeerschaert/pptxgen-autopage-text-array-in-last-row-error
I examined the code in the parseTextToLines() function and I think I spotted the problem
Steps:
inputCells
inputLines1
arrayinputLines1
array ant tokenize each line of text into thelineCells
array, and append that toinputLines2
array.The issue is in step 3 - If you include a text object that looks like this:
each item in the
text
array ends up getting treated as a separate tokenized array ininputLines2
, which then gets treated as separate table rows later. I think you have some logic to reconcile this somewhere because the issue only crops up when the rows are split between slides.I think the correct way to handle this is to ensure all the items that were in the text array go into the same tokenized
lineCells
array, unless they have thebreakLine
option, or a newline character in which case you add thebreakLine
option in step 2 on line 86.This PR refactors step 3 by moving the
lineCells
declaration outside of the processing ofinputLines1
, it still checks if the last item inlineCells
hasoptions.breakLine = true
, and if so appends it toinputLines2
and flushes the buffer (to preserve the existing functionality), then after iterating over all the items ininputLines1
it appends the remaininglineCells
toinputLines2
, thus reconciling the items from the text array that were separated in step 2.