Skip to content

Keep Word page breaks when importing DOCX - #175

Merged
krperry merged 1 commit into
mainfrom
docx-page-break
Oct 18, 2026
Merged

krperry merged 1 commit into
mainfrom
docx-page-break

Conversation

@krperry

@krperry krperry commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator

Pandoc drops Word page breaks, so they were lost on DOCX import. Each
one now becomes a new page before the block that follows it.

  • DocxPageBreaks copies the docx before pandoc runs and replaces each
    <w:br w:type="page"/>, and each paragraph with "Page break before"
    turned on, with marker text.
  • docx-page-break.lua splits paragraphs at the marker and keeps the
    break outside Word's List-style blocks. A break inside formatting, a
    list or a table moves to just before that block.
  • bbx.lua writes the break as <bb:pageBreak />.
  • FixPageBreak turns it into bb:overrideOption-newPagesBefore on the
    next block, the option the Page Break tool sets. Tables get it on the
    table and its braille copy. Two breaks in a row give 2 pages.

Paragraph styles with "page break before" in the style definition are
not handled.

Testing

PandocDocxPageBreakTest (7 tests) covers the statement fixture,
breaks mid-paragraph, consecutive breaks, the "Page break before"
property, tables, a trailing break, and files with no breaks. It
passes, as do the existing list-style and definition-list pandoc tests.

Pandoc drops Word page breaks, so imported documents lost them.
Before pandoc runs, DocxPageBreaks replaces each manual page break and
each paragraph with "Page break before" turned on with marker text.
The new docx-page-break.lua filter splits paragraphs at the marker,
bbx.lua writes it as bb:pageBreak, and FixPageBreak turns it into
newPagesBefore on the next block, the same option the Page Break tool
sets. A table gets the option on the table and its braille copy.
@krperry
krperry merged commit d90a8af 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