如何将自定义格式添加到Pandoc从 Markdown 生成的 docx 文件中?例如,我可以突出显示文本或将其居中吗?我可以重新设置链接样式吗?
我知道我可以通过使用--reference-doc(使用 生成)来更改默认元素(例如标题pandoc -o custom-reference.docx --print-default-data-file reference.docx)的样式,但我想引入其他样式。
cit*_*lao 33
在 Pandoc 中自定义 docx 输出基本上有 3 种方法:
Generate a reference doc (as mentioned in the question: pandoc -o custom-reference.docx --print-default-data-file reference.docx). It will have a bunch of content, representing common Pandoc components like headings and blockquotes (see picture at the end).
In the Styles menu at the top of Word, find the style you want to change and edit it to be what you'd like (I'm not sure if you can simply edit the text's style directly).
There are more styles than the ones that appear in the reference document text and in the "Style gallery." For example, you can customize hyperlinks (e.g. color).
Generate a reference doc (or use the one you have from above).
Click the expand button in the Styles section to show the Styles pane (see below).

Find the style you want, then edit it.
Also:
This is probably the most relevant to the question. If you want to introduce custom elements beyond the default ones Pandoc provides and Word provides, you can simply add custom styles to the reference document. For example, you can create a style for highlighted text or centered text, or a style for large code blocks.
Generate a reference doc (or use the one you have from above).
Add some text to the document using the base style you want---the style you want to base your new custom style on. For example, if you want "normal text but highlighted," write some new text that uses the "Normal" or "Body text" style.
Click the dropdown in the Styles gallery.
Click Create a Style
Name the style, whatever you'd like.
Click Modify... and customize the style however you'd like. You can always get to this menu later by right-clicking the style in the gallery and clicking "Modify..."
Save the document.
In the text you will convert to docx, add divs and spans with the appropriate custom-style attribute whenever you want to consume it. For example, if you have a paragraph style called Super big and a character style called Highlighted text:
<div custom-style="Super big">My super big text</div>
Normal text. <span custom-style="Highlighted text">This is highlighted</span>.
Run Code Online (Sandbox Code Playgroud)
Pandoc will apply those custom styles for you!
| 归档时间: |
|
| 查看次数: |
12401 次 |
| 最近记录: |