Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
conklech opened this issue Jul 25, 2019 · 1 comment
Closed

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

conklech opened this issue Jul 25, 2019 · 1 comment

Comments

@conklech
Copy link
Contributor

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]

@jgm
Copy link
Owner

jgm commented Jul 26, 2019

@conklech This sounds reasonable to me. We just need to test extensively to make sure it doesn't have any unexpected effects. Do you want to prepare a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants