-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
SourceCode style and *.docx output #1872
Comments
Thanks Matthew. Yes, I can edit the reference test.docx so it only contains the Source Code style that I want (either by deleting the wrong Source Code style in Word or by editing styles.xml directly). However, any further conversions using that as a So, I end up with an unwanted "Select all source code blocks and change to the other Source Code style" step in my conversion process. |
This is added automatically by the docx writer. If it's in the template, we'll get two copies. See #1872.
The docx writer generates the SourceCode style based on the highlighting This addresses a bug in pandoc, but it may not solve your problem, If not, we might think about how to make this customizable. A good |
I found a different method for working around this. If you use the Maybe pandoc works as intended, you just need to use this option instead? (I am using pandoc version 1.13.1 under cygwin on Windows 7 x64) |
Pandoc does not work as expected. It doesn't replace existing token styles, it adds new ones without any regard for their prior existence. This leads to duplicate token styles in resulting docx, which is definitely not what I would expect. It boils down to Parsing stylesheet for existing styles and skipping those that already exist might be a solution, and we likely need to parse said styles anyway to solve #1607 and #1933 |
Yes, I think it makes sense to check for token styles, and not replace |
@jgm here's an idea:
I think to make distinction between |
Well, +++ Nikolay Yakimov [Feb 21 15 15:27 ]:
|
@jgm then again, while this will be ugly and I'm not advocating anything, it's not strictly necessary to change |
This should be fixed (somewhat) by #1968, which is merged. Token styles from reference.docx now take precedence. If |
Please reopen if you are still having problems. |
Hey sorry to resurrect such an old issue, but this is all the right context for the issue I'm having now. If the *Tok styles are already defined in the reference, they won't be added. This is good. However, this isn't true for the SourceCode style which is added in the same way under the same circumstances. I'm trying to style code blocks and get syntax highlighting in them. I saw that the compiled docx contains all the relevant styles injected at the end. I was able to stop the injection of all the *Tok styles by copying them into the source reference.docx, but the SourceCode style is always injected, overwriting my custom style. |
@shreve I'd have to look into why this is happening, but probably you shouldn't be manually injecting Tok styles. Have you considered defining a custom highlight style instead? Then the proper Tok styles would be auto-generated, and would work in other formats besides docx as well. See |
Thank you, especially for the fast reply. The custom style does get me closer because I can change the background color, but I'm concerned with the code wrapper style rather than the tokens. I'm trying to add padding and a border and that doesn't seem to me to be supported by the highlight style. |
Mmm, I've had no problems defining a SourceCode custom style with paragraph background color, border, etc. (not sure about padding, but using paragraph styling it should work). |
Since this is unexpected, I'll make a new issue with reproduction details rather than continue on here. |
I also can make it work with Source Code style for paragraph settings, except the font , which is coded as "consolas". |
The "Source Code" style in docx output does not work properly when edited and used as a reference style.
Input file
test.markdown
:Command:
Expected output:
The output file
test.docx
should contain a single "Source Code" style which can be edited, so that it can be used with--reference-docx
and applied to subsequent docx output.Actual output:
The output docx contains two copies of the "Source Code" style.
This seems to cause further problems using the output as a reference docx. I.e.:
Create test.docx as detailed above.
Open test.docx in MS Word and select the whole line of source code.
Alt-Ctrl-Shift-S to open the Styles box. You will notice two styles named "Source Code", one which is selected and one which isn't.
Right click on the selected "Source Code" style (i.e. the one applied to the selected line).
Make some modifications to the style. [Note: you will notice if you try to make changes to the other "Source Code" style, you will receive the message "This style name already exists or is reserved for a built-in style" after clicking Modify -> Format]
Save the document.
Run the following to use test.docx as a style reference for another conversion:
You will see that the changes made to the Source Code style in test.docx have not been applied in test2.docx
Versions:
pandoc 1.13.2 Windows 7
MS Word 2013
The text was updated successfully, but these errors were encountered: