Skip to content

Docx writer: Don't force table cells to be left-aligned #5662

Closed
@conklech

Description

@conklech

Pandoc's docx writer currently forces the alignment of every table cell with a w:jc tag, even when the column alignment is AlignDefault, in which case Pandoc emits <w:jc w:val="left" />. Left alignment is not necessarily correct, especially because the w:jc tag overrides the other user-controllable means to control alignment, i.e. table styles and paragraph styles. This produces a round-trip (Docx->Pandoc->Docx) failure for at least some tables. Worse, it is impossible to produce a column in which different cells have different alignments. (This is not as stupid as it sounds: center-aligned headers look good over a column that contains left-aligned paragraph text.)

Word itself generally does not emit any w:jc tag when a cell's alignment is controlled by either the table style or paragraph style. (Well, the one file I examined had no w:jc tags; I haven't thoroughly investigated Word's behavior.)

Proposal: Alter blockToOpenXML' to emit no w:jc tag when the corresponding column alignment is AlignDefault.

I haven't extensively considered how this might produce unexpected results or break existing workflows. I'm not aware of any workaround for this limitation.

See:

let alignmentFor al = mknode "w:jc" [("w:val",alignmentToString al)] ()

alignmentToString :: Alignment -> [Char]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions