question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retain numbering id in list paragraphs

See original GitHub issue

Assume you have a document with 2 level 0 ordered lists:

1. one
2. two
Something else
3. three
Something else
1. one
2. two

the numbering information provided in the AST node does not contain the information about the numbering, so it’s not possible to continue the first list after the non-list paragraph.

document[8]
β”œβ”€0 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0"}
β”‚   └─0 run[1]
β”‚       └─0 text "One"
β”œβ”€1 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0"}
β”‚   └─0 run[1]
β”‚       └─0 text "Two"
β”œβ”€2 paragraph[1]
β”‚   β”‚ styleId: "Normal"
β”‚   └─0 run[1]
β”‚       └─0 text "Something else"
β”œβ”€3 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0"}
β”‚   └─0 run[1]
β”‚       └─0 text "Three"
β”œβ”€4 paragraph[1]
β”‚   └─0 run[1]
β”‚       └─0 text "Something else"
β”œβ”€5 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0"}
β”‚   └─0 run[1]
β”‚       └─0 text "One"
β”œβ”€6 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0"}
β”‚   └─0 run[1]
β”‚       └─0 text " Two"
└─7 paragraph[0]

If the numId would be added to the numbering information, it would be possible to detect the continuation.

document[8]
β”œβ”€0 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0","numId":"1"}
β”‚   └─0 run[1]
β”‚       └─0 text "One"
β”œβ”€1 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0","numId":"1"}
β”‚   └─0 run[1]
β”‚       └─0 text "Two"
β”œβ”€2 paragraph[1]
β”‚   β”‚ styleId: "Normal"
β”‚   └─0 run[1]
β”‚       └─0 text "Something else"
β”œβ”€3 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0","numId":"1"}
β”‚   └─0 run[1]
β”‚       └─0 text "Three"
β”œβ”€4 paragraph[1]
β”‚   └─0 run[1]
β”‚       └─0 text "Something else"
β”œβ”€5 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0","numId":"4"}      <<========
β”‚   └─0 run[1]
β”‚       └─0 text "One"
β”œβ”€6 paragraph[1]
β”‚   β”‚ styleId: "ListParagraph"
β”‚   β”‚ numbering: {"isOrdered":true,"level":"0","numId":"4"}
β”‚   └─0 run[1]
β”‚       └─0 text " Two"
└─7 paragraph[0]
diff --git a/lib/docx/numbering-xml.js b/lib/docx/numbering-xml.js
index 64c4210..a68fbf4 100644
--- a/lib/docx/numbering-xml.js
+++ b/lib/docx/numbering-xml.js
@@ -15,13 +15,16 @@ function Numbering(nums, abstractNums, styles) {
         }),
         "paragraphStyleId"
     );

     function findLevel(numId, level) {
         var num = nums[numId];
         if (num) {
             var abstractNum = abstractNums[num.abstractNumId];
             if (abstractNum.numStyleLink == null) {
-                return abstractNums[num.abstractNumId].levels[level];
+                var lvl = abstractNums[num.abstractNumId].levels[level];
+                return Object.assign({numId: numId}, lvl);
             } else {
                 var style = styles.findNumberingStyleById(abstractNum.numStyleLink);
                 return findLevel(style.numId, level);

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
tripodsancommented, Aug 8, 2021

hello @tripodsan I face this same issue. Can you please tell your solution for this ?

I have a fork: https://github.com/adobe-rnd/mammoth.js/tree/bleeding that uses my suggestion above: https://github.com/adobe-rnd/mammoth.js/commit/60a679eb0c0599c7b0f5d2ca83fbb1c55b84c73e

it’s released as: https://www.npmjs.com/package/@adobe/mammoth/v/1.4.15-bleeding.1

2reactions
tripodsancommented, Jan 18, 2022

@tripodsan Hey, thanks so much for your fix! Just curious if you still plan on making a PR?

sorry @hmnd , I was preoccupied with other things… I’ll take a look at it now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restart Numbering Issue with Paragraphs with Locked ...
I have found an issue where Word is losing its numbering in Paragraphs that have Locked Content Controls after updating styles in a...
Read more >
Create bulleted and numbered lists in InDesign
Click the Bulleted List button or the Numbered List button in the Control panel (in Paragraph mode). Hold down Alt (Windows) or Option...
Read more >
Getting Automatic Paragraph Numbering Back on Track
Fixing it is simple: Just right-click on one of the numbers and choose Adjust List Indents. Depending on whether you're using single-level or...
Read more >
InDesign Numbered List - How to create and use it best
Change the numbering style. Keep your selection on the numbered list. At the far left of the control bar at the top, inside...
Read more >
Setting up Numbered Lists that Jump Frames in CS3
On page 1 of your ID doc, hold down the Shift key when you Place that text file into the small text frame....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found