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 - "different odd/even pages" is not selected even if template has it on #3901

Closed
agusmba opened this issue Sep 8, 2017 · 11 comments

Comments

@agusmba
Copy link
Contributor

agusmba commented Sep 8, 2017

First of all thank you for making this amazing tool.

I'm trying to set up a markdown -> docx pipeline, using pandoc 1.18 on windows 7.

I'm tweaking the docx template (reference-docx), but I just realized that odd/even pages selection (header/footer) on my template is not honored in the generated docx (thus the odd style is applied to the whole document).

WORKAROUND:
Thankfully the even/odd styles are not lost and I can manually go to the header of the generated docx and select "different odd/even pages" and I will get the expected result.

Ideally the generated docx should have this option selected if the reference-docx had it.

@jgm
Copy link
Owner

jgm commented Sep 9, 2017

Could you post a link to the reference docx that has this feature?

@agusmba
Copy link
Contributor Author

agusmba commented Sep 10, 2017

Certainly.

I created a mimimum (non)working example showing this problem, with a simple markdown file with steps to reproduce, the reference docx, and the resulting docx I get with pandoc.

pandoc-issue-3901.zip

Even though I said inside it was with version 1.18, actually for today's example I installed v1.19.2.1 (same problem)

@agusmba
Copy link
Contributor Author

agusmba commented Oct 9, 2017

At first glance it seems simply writing <w:evenAndOddHeaders/> to settings.xml would fix this.
It probably would make sense to check the existence of this tag in the reference doc first and include it in the output accordingly.

I've never coded in haskell, but reading the source comments, maybe adding , 'w:evenAndOddHeaders' somewhere around here could do the trick (sorry if there are more changes to take into account, I havent tested nor even compiled this change)

@mb21
Copy link
Collaborator

mb21 commented Oct 9, 2017

At first glance it seems simply writing <w:evenAndOddHeaders/> to settings.xml would fix this.

Can you modify the generated docx file and test this? The docx is just a zip which you can modify with the usual tools...

@jgm jgm added this to the pandoc 2.0 milestone Oct 9, 2017
@agusmba
Copy link
Contributor Author

agusmba commented Oct 9, 2017

Can you modify the generated docx file and test this? The docx is just a zip which you can modify with the usual tools...

Yes I tested it manually before posting, that's why I proposed including it in the docx. I should have mentioned it earlier, sorry.

I wasn't sure if on the pandoc side there was something else to consider.

@agusmba
Copy link
Contributor Author

agusmba commented Oct 9, 2017

This seems like a simple enough fix to try.
Knowing nothing about haskell I was reluctant about downloading the 3GB dev environment, but if you prefer I could try to send a PR...

@mb21
Copy link
Collaborator

mb21 commented Oct 9, 2017

@agusmba Pull requests are always welcome and hacking on pandoc is a great way to get your feet wet with real-world haskell! Personally, I recommend using stack to build the pandoc source code:

$ git clone ...
$ cd pandoc
$ stack setup
$ stack build

see also http://learnyouahaskell.com/chapters and maybe https://github.com/jgm/pandoc/blob/master/CONTRIBUTING.md

@agusmba
Copy link
Contributor Author

agusmba commented Oct 9, 2017

Ok, I got a working pandoc in my PC with this issue fixed.
I'll check if the current tests are still OK, and I should try to write an automatic test for this issue (this will probably take a lot longer than the fix itself...)

@jgm
Copy link
Owner

jgm commented Oct 9, 2017 via email

@agusmba
Copy link
Contributor Author

agusmba commented Oct 9, 2017

Mmmm I don't see an easy way of automating tests for this.

I have checked that all current tests run OK, and I have manually tested that the fix works for reference doc with and without the evenAndOddHeaders mark set.

It seems all tests (at least in the docx writer section) deal with native pandoc representation of the document. However this is not the case here, as the presence (or absence) of the evenAndOddHeaders mark is only dealt with at the docx writing stage, and as far as I can see is not reflected in the internal pandoc format.

How would you go about making an automated test for this case?

EDIT: @jgm I just saw your comment, I'll make the PR then with the simple fix.

agusmba added a commit to agusmba/pandoc that referenced this issue Oct 9, 2017
Fixes jgm#3901 by checking for the evenAndOddHeaders mark in the
reference doc, and copying it to the resulting docx if present.
@jgm
Copy link
Owner

jgm commented Oct 10, 2017 via email

@jgm jgm closed this as completed in #3963 Oct 10, 2017
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