erdos / stencil

templating engine for DOCX and PPTX files
https://stencil.erdos.dev
Eclipse Public License 2.0
111 stars 12 forks source link

For loops cause issue with numbered bullet points #137

Open poweriton opened 2 years ago

poweriton commented 2 years ago

Describe the bug If a for loop wraps a number of sets of bullet points then every iteration of the loop produces a number incremental from the last.

To Reproduce So we have a for loop around a 2 page letter, within the letter exists a numbered list. When the second letter merges it produces numbers that continue from the previous letter.

Expected behavior I expected this to restart the numbering on every new merge.

Office versions:

Environment where template is rendered:

erdostw commented 2 years ago

hi, could you share a simplified example template? 🙇

poweriton commented 2 years ago

Please find the test template example attached.

The for loop just needs more than one item to see the problem output

From: Janos Erdos @.> Sent: 12 August 2022 13:46 To: erdos/stencil @.> Cc: Alex Power @.>; Author @.> Subject: Re: [erdos/stencil] For loops cause issue with numbered bullet points (Issue #137)

hi, could you share a simplified example template? 🙇

— Reply to this email directly, view it on GitHubhttps://github.com/erdos/stencil/issues/137#issuecomment-1213074353, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHXS762NVBLS3LFULKAVXQTVYZBSJANCNFSM56LKU72A. You are receiving this because you authored the thread.Message ID: @.**@.>>

erdos commented 2 years ago

Thanks for the detailed report and the example! It seems like the problem is that numbered paragraphs are reusing the same numId so the numbering just continues.

In some cases this is desirable, for example for the following template, we want the numbering to be continuous:

{%for name in names%}
1. {%=name%}
{%end%}

So we would need a way to determine the intention with the numbering for these cases. I will mark the bug as high priority for the next release, but it is not trivial, so it may take some time to resolve.

poweriton commented 2 years ago

I see the issue, having played around with a rendered template I have been able to manually reset the numbering which pointed to link between the lists.

Is there any way to detect if the previous item was not a list? That way you might be able to detect if to continue outputting form the previous number or generate a new numId to start a new set.

Thanks for the feedback

From: Janos Erdos @.> Sent: 17 August 2022 17:23 To: erdos/stencil @.> Cc: Alex Power @.>; Author @.> Subject: Re: [erdos/stencil] For loops cause issue with numbered bullet points (Issue #137)

It seems like the problem is that numbered paragraphs are reusing the same numIdhttps://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_numId_topic_ID0EP5QU.html so the numbering just continues.

In some cases this is desirable, for example for the following template, we want the numbering to be continuous:

{%for name in names%}

  1. {%=name%}

{%end%}

So we would need a way to determine the intention with the numbering for these cases. I will mark the bug as high priority for the next release, but it is not trivial, so it may take some time to resolve.

— Reply to this email directly, view it on GitHubhttps://github.com/erdos/stencil/issues/137#issuecomment-1218239003, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHXS766ANVGHFT72ZFDE4ADVZUGXNANCNFSM56LKU72A. You are receiving this because you authored the thread.Message ID: @.**@.>>

poweriton commented 2 years ago

Hi, Have you been able to make any progress with this?