docx style “Source Code” not in reference.docx, adding it changes verbatim style mapping #10803
-
I am using inline verbatim markup (`backticks`) in my Markdown sources, and when I create docx output, these verbatim spans are assigned the “Source Code” paragraph style. So far, so good. The Pandoc manual says in the --reference-doc section that the “Source Code” style is part of the default reference.docx we can access using (The default reference.docx does contain Abstract, Author, Block Text, Body Text, Date, Definition, DefinitionTerm, First Paragraph, Footnote, Heading 1 to Heading 9, Hyperlink, Image Caption, Subtitle, Table, Table caption, Title, Verbatim Char styles.) Now the “Source Code” style is present in the created docx files – however, with a font (Consolas) I don’t want. I need to create a lot of Word documents, so I added a “Source Code” style to my reference.docx, with the proper font. However, when using this modified reference.docx, Pandoc will use the “Verbatim Char” style for the verbatim spans instead of “Source Code”. I suppose I misunderstand something, so I’m not reporting this as a bug for now. Any ideas how to resolve this, i.e., have a customizable Source Code style in a reference.docx? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The Note that inline code elements ( This article may also contain some useful tips for generating DOCX files with pandoc (shameless plug). That article also contains some information on the different types of styles in DOCX. |
Beta Was this translation helpful? Give feedback.
-
Hi, Coming from the opposite side - in my situation, I have Word documents with some code snippets inside. I am trying to understand what is the best way to format them in Word so they could be more or less properly converted to MD. Fencing does not work with DOCX input, as far as I understand. So, it appears that the only way to get the code rendering more or less OK is to actually create the style called Source Code and replace the paragraph breaks with line breaks in the code snippet (otherwise each line becomes a paragraph). This ugly recipe does work, I have tested it. Are there any other, more convenient options? P.S. I also do not fully understand the point of the reference document. I though that it could be used for authoring Word documents in the way most suitable for Pandoc. if so, then it should include Source Code style too. |
Beta Was this translation helpful? Give feedback.
The
Source Code
style gets created dynamically by Pandoc depending on the selected syntax highlighting style when the output is created -- see #10646. TheSource Code
paragraph style will be based on theVerbatim Char
character style, so if you want to change the font used inSource Code
paragraphs, you need to modify theVerbatim Char
style and specify the desired font there.Note that inline code elements (
Code
in pandoc's AST) have to use a character style (Verbatim Char
) and cannot use a paragraph style, since a paragraph style always applies to a whole paragraph, as the name suggests.This article may also contain some useful tips for generating DOCX files with pandoc (shameless plug…