Skip to content

Fix List Paragraph bullets and lone list bullets in DOCX import - #176

Merged
krperry merged 2 commits into
mainfrom
list-fix
Oct 18, 2026
Merged

krperry merged 2 commits into
mainfrom
list-fix

Conversation

@krperry

@krperry krperry commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Two fixes for DOCX list import, found while comparing APH Accessible
Statement Maker files with Duxbury. One commit each.

Stop adding bullets to unnumbered List Paragraphs

Word's "List Paragraph" style has no numbering, so these lines show no
bullet in Word. list-paragraph-style.lua turned every run of them into
a Pandoc BulletList, so each line got a UEB bullet (_4): about 50 per
LWS statement and 28 per ACBS statement.

Pandoc already reads paragraphs that Word really numbers as
BulletList/OrderedList, so the filter only ever saw unnumbered ones (no
numPr, numId 0, or an undefined numId). It was added so List
Paragraph imports as a list item instead of Body Text, and Div() in
bbx.lua now does that itself. The filter is removed.

Keep a list bullet and its text on one line

A paragraph that is numbered and in a "List" style (the "List 2"
bullets in the WC statements) arrives as a bullet item holding a
one-item nested list. FixNestedList moved that list out and left the
bullet alone on its line. It now merges the text back into the bullet
item when the item holds only its bullet or number, at the nested
level: the 3-5 layout Duxbury uses.

Testing

  • New tests in PandocDocxListStyleTest: unnumbered List Paragraph,
    numId 0, undefined numId, real bullet and number, and a numbered
    "List 2" bullet. A shared TestDocx builder makes the test files.
  • compare_brf.py: bullets added=0 and lone bullets=0 on all problem
    files; BR-83_acbs matches Duxbury. Remaining differences are known,
    separate issues (long URL continuation, LWS table headers, rule
    lines).
  • The 5 regression statements are unchanged.
  • mvnw package with tests passes.

Word's "List Paragraph" style has no numbering of its own, so a
paragraph in that style shows no bullet unless Word numbers it. The
list-paragraph-style.lua filter turned every run of these paragraphs
into a Pandoc BulletList, so BrailleBlaster put a UEB bullet (_4) at
the start of each line. Statements from the Accessible Statement
Maker gained about 50 bullets each (LWS) or about 28 (ACBS) that
Duxbury and the print do not have.

Pandoc already reads paragraphs Word really numbers as BulletList or
OrderedList, so the filter only ever saw unnumbered paragraphs: no
numPr, numId 0, or a numId not defined in numbering.xml. The filter
was added so List Paragraph imports as a list item rather than Body
Text. Div() in bbx.lua now does that itself, as a bullet-less 1-3
item like "List" and "List 2", so the filter is removed.

Tests build small DOCX files for an unnumbered List Paragraph,
numId 0, an undefined numId, and real bullet and decimal numbering.
The DOCX builder moves out of PandocDocxPageBreakTest so both tests
share it.
A Word paragraph that is numbered and also in a "List" style, such as
the "List 2" bullets in the WC statements, arrives from Pandoc as a
BulletList item that holds a custom-style Div. bbx.lua writes the
bullet into the item and turns the Div into its own one-item list, so
the item held a nested list. FixNestedList then moved that list out,
which left the bullet (_4) alone on a line and the text on the next
line. A bullet could even end a page with its text on the next one.

FixNestedList now merges a one-item nested list back into its parent
item when the parent holds only the bullet or number. The text
follows the bullet in one LIST_ITEM at the nested level, which is the
3-5 layout Duxbury uses for these items. Other nested lists still
flatten as before.

The test covers a numbered "List 2" paragraph and a bulleted and
numbered "List Paragraph".
@krperry
krperry merged commit 4b2191c into main Oct 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant