Repository navigation
Import Word List styles as 1-3 lists, keep line breaks - #174
Merged
Merged
Conversation
DOCX paragraphs styled "List" (and "List 2".."List 9", "List Continue") were imported as ordinary paragraphs, so addresses on statements were formatted 3-1 instead of as 1-3 list items. bbx.lua already had a Div handler for custom list styles, but it never ran: Pandoc 3 passes classic-writer attributes as an AttributeList userdata, not a table, so getCustomStyle always returned nil. Read the attribute directly and treat Word's unnumbered list styles as bullet-less list items. FixNestedList merges the adjacent items into one list. Other paragraphs are unchanged and stay Body Text. Line breaks inside list items were also lost in two places: - bbx.lua stripped every utd tag, including utd:newLine, when building list items. Add listItemText, which keeps inner breaks and trims leading/trailing ones, and use it for styled, bullet and ordered list items. - FixNestedList called moveListItems on every child element of a list item, which removed any empty child such as utd:newLine. Only move actual nested lists. Add PandocDocxListStyleTest with a sample statement document to cover list styles, line breaks, nested list flattening and that plain paragraphs stay Body Text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DOCX files whose paragraphs use Word's "List" style (for example the
address block at the top of bank statements) were imported as normal
paragraphs and formatted 3-1, starting in cell 3. They should be list
items formatted 1-3. Line breaks inside list items were also dropped.
Changes
bbx.lua
getCustomStylenever worked under Pandoc 3: attributes arrive asan
AttributeListuserdata, not a table, so the existing Divhandler for custom list styles never ran. It now reads the
attribute directly.
List,List 2..List 9,List Continue,List Continue 2..9) become bullet-less listitems (L1-3). Adjacent items are merged into one list by
FixNestedList. Other paragraphs stay Body Text (3-1).
listItemTextkeepsutd:newLineline breaks inside listitems (trimming leading/trailing ones). Used for styled, bullet
and ordered list items; previously
removeTagsstripped them.FixNestedList.kt
moveListItemswas called for every child element of a list itemand removed any empty child, such as
utd:newLine. It now onlyruns for nested lists.
"List Paragraph" behaviour is unchanged (still a bulleted list via
list-paragraph-style.lua).Tests
New
PandocDocxListStyleTest, using a sample statement DOCX:into one list, no bullets added
PandocLuaDefinitionListTeststill passes. The full build alsoneeds #173 for two unrelated UI test failures already on main.