2

我试图在md通过使用pandoc.

首先我得到默认模板:

pandoc -D odt > template_odt.xml

我可以通过键入来绘制一条黑色水平线<text:p text:style-name="Horizontal_20_Line" />,例如在以下位置template_odt.xml

...
$endif$
<text:p text:style-name="Horizontal_20_Line" />
$for(include-before)$
...

但是如何将颜色归因于这条线?样式Horizontal_20_linestyles.xml文件中定义:

<style:style style:name="Horizontal_20_Line"
style:display-name="Horizontal Line" style:family="paragraph"
style:parent-style-name="Standard"
style:next-style-name="Text_20_body" style:class="html">
  <style:paragraph-properties fo:margin-top="0in"
  fo:margin-bottom="0.1965in" style:contextual-spacing="false"
  style:border-line-width-bottom="0.0008in 0.0138in 0.0008in"
  fo:padding="0in" fo:border-left="none" fo:border-right="none"
  fo:border-top="none" fo:border-bottom="1.11pt double #808080"
  text:number-lines="false" text:line-number="0"
  style:join-border="false" />
  <style:text-properties fo:font-size="6pt"
  style:font-size-asian="6pt" style:font-size-complex="6pt" />
</style:style>

所以 :

  1. 我可以在中添加一个属性template_odt.xml,例如:

    <text:p text:style-name="Horizontal_20_Line" line-color="red"?????/>
    
  2. 或者我应该修改样式Horizontal_20_line,如何修改?我不知道默认styles.xml文件在哪里,也不知道如何定义样式template_odt.xml(我所有的天真尝试都失败了)。

4

1 回答 1

2

我找到了如何修改styles.xml文件。首先reference.odt在 pandoc 文件夹或github上获取文件。然后,解压缩此文件。水平线的颜色为#808080默认样式:

<style:style style:name="Horizontal_20_Line"
style:display-name="Horizontal Line" style:family="paragraph"
style:parent-style-name="Standard"
style:next-style-name="Text_20_body" style:class="html">
  <style:paragraph-properties fo:margin-top="0in"
  fo:margin-bottom="0.1965in" style:contextual-spacing="false"
  style:border-line-width-bottom="0.0008in 0.0138in 0.0008in"
  fo:padding="0in" fo:border-left="none" fo:border-right="none"
  fo:border-top="none" fo:border-bottom="1.11pt double #808080"
  text:number-lines="false" text:line-number="0"
  style:join-border="false" />
  <style:text-properties fo:font-size="6pt"
  style:font-size-asian="6pt" style:font-size-complex="6pt" />
</style:style>

修改颜色并转到Open Office 如何压缩其文件?拉回myreference.odt. 然后按如下方式运行 pandoc(假设两者template_odt.xmlmyreference.odt在当前目录中):

pandoc -f markdown -t odt --template=template_odt.xml --reference-odt=myreference.odt myfile.md -o myfile.odt

现在我有一个新问题:LibreOffice 必须修复输出odt文件,但这是另一个问题......

于 2014-04-01T16:20:49.143 回答