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

Markdown to docx with custom styles in spans result in reference styles being overwritten #4843

Closed
kronicd opened this issue Aug 18, 2018 · 3 comments

Comments

@kronicd
Copy link

kronicd commented Aug 18, 2018

When using custom styles with the span syntax pandoc will create a new style in the output document, even where the style exists in the source document.

For instance in the following, example1 will appear rendered correctly, but example2 will have an additional default style defined with the same name, overriding the style when viewed in Word.

The following style (example1) will work as expected <div custom-style="example1">this works
 great</div> however when using span tags the style will be defined again, overriding the previous
 as you can see<span custom-style="example2">this doesn't work great</span>. This makes me sad :(

If we run the above through pandoc with a reference document that shows example1 highlighted yellow and example2 highlighted green, we get the following:

cat input.txt | pandoc -f markdown --reference-doc='custom-reference.docx' --output testabcd.docx

image

I have attached all files here, this issue should be trivial to replicate with the files and command provided.

custom-reference.docx
input.txt
testabcd.docx

@jgm
Copy link
Owner

jgm commented Aug 18, 2018

If I understand correctly, spans with custom styles should generate character styles, while divs generate paragraph styles. Isn't that the issue here? A paragraph style named example2 isn't the same as a character style named example2.

@kronicd
Copy link
Author

kronicd commented Aug 18, 2018

Thanks very much for the explanation, I've tried with a character style and can see that it works now.

I will modify the documentation slightly and submit a pull request. Cheers

@kronicd kronicd closed this as completed Aug 18, 2018
@vishalmudgalpw
Copy link

@kronicd Could you re-upload custom-reference.docx, input.txt, output.docx files after correction that you made, if possible.

@kronicd , @jgm Is there any possibility in conversion of html to docx file, i could add custom style for display:flex on any element
<div style="display:flex">content</div>

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

No branches or pull requests

3 participants