Stéphane Laurent
Stéphane Laurent

Reputation: 84649

Colored horizontal lines in ODT template for Pandoc

I'm trying to draw a coloured horizontal line at the beginning of an ODT file (OpenDocumentText for LibreOffice/OpenOffice) obtained by conversion from a md (Markdown text) file by using pandoc.

First I get the default template:

pandoc -D odt > template_odt.xml

I am able to draw a black horizontal line by typing <text:p text:style-name="Horizontal_20_Line" />, for example at this location in template_odt.xml :

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

But how to attribute a color to this line? The style Horizontal_20_line is defined in the styles.xml file:

<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>

So :

  1. Can I add an attribute direclty in template_odt.xml, like :

    <text:p text:style-name="Horizontal_20_Line" line-color="red"?????/>
    
  2. Or should I modify the style Horizontal_20_line, and how? I don't know where is the default styles.xml file and I don't know how to define a style in template_odt.xml (all my naive attempts have failed).

Upvotes: 2

Views: 828

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84649

I have found how to modify the styles.xml file. First get the reference.odt file in the pandoc folder or on github. Then, unzip this file. The color of the horizontal line is #808080 in the default style:

<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>

Modify the color and go to How does Open Office compress its files? to zip back to myreference.odt. Then run pandoc as follows (assuming both template_odt.xml and myreference.odt are in the current directory):

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

Now I have a new problem : LibreOffice has to repair the output odt file, but this is another question...

Upvotes: 2

Related Questions