$ pandoc --template odt.template main.md -t opendocument -o my.odt -V s1=$( pandoc -t opendocument -f markdown sections/section1.md ) -V s2=$( pandoc -t opendocument -f markdown sections/section2.md ) -V s3=$( pandoc -t opendocument -f markdown sections/section3.md )
pandoc: text:style-name="Heading_20_1": openFile: does not exist (No such file or directory)
$ set -x
$ pandoc --template odt.template main.md -t opendocument -o my.odt -V s1=$( pandoc -t opendocument -f markdown sections/section1.md ) -V s2=$( pandoc -t opendocument -f markdown sections/section2.md ) -V s3=$( pandoc -t opendocument -f markdown sections/section3.md )
++ pandoc -t opendocument -f markdown sections/section1.md
++ pandoc -t opendocument -f markdown sections/section2.md
++ pandoc -t opendocument -f markdown sections/section3.md
+ pandoc --template odt.template main.md -t opendocument -o my.odt -V 's1=<text:h' 'text:style-name="Heading_20_1"' 'text:outline-level="1">Encabezado' '1</text:h>' '<text:h' 'text:style-name="Heading_20_2"' 'text:outline-level="2">Encabezado' '2</text:h>' '<text:h' 'text:style-name="Heading_20_3"' 'text:outline-level="3">Encabezado' '3</text:h>' '<text:list' 'text:style-name="L1">' '<text:list-item>' '<text:p' 'text:style-name="P1">lista' item '1</text:p>' '</text:list-item>' '<text:list-item>' '<text:p' 'text:style-name="P1">lista' item '2</text:p>' '</text:list-item>' '<text:list-item>' '<text:p' 'text:style-name="P1">lista' item '3</text:p>' '</text:list-item>' '</text:list>' -V 's2=<text:p' 'text:style-name="Text_20_body">Prueba' de texto en '<text:span' 'text:style-name="T1">Negrita</text:span>' , '<text:span' 'text:style-name="T2">cursiva</text:span>,' '<text:span' 'text:style-name="T3">tachado</text:span>' y '<text:span' 'text:style-name="T4">mezcla</text:span><text:span' 'text:style-name="T5">' '</text:span><text:span' 'text:style-name="T6">de</text:span><text:span' 'text:style-name="T7">' '</text:span><text:span' 'text:style-name="T8">negrita</text:span><text:span' 'text:style-name="T9">' '</text:span><text:span' 'text:style-name="T10">y</text:span><text:span' 'text:style-name="T11">' '</text:span><text:span' 'text:style-name="T12">negrita</text:span><text:span' 'text:style-name="T13">' '</text:span><text:span' 'text:style-name="T14">cursiva</text:span></text:p>' -V 's3=<text:p' 'text:style-name="Text_20_body">Prueba' de link: '<text:a' 'xlink:type="simple"' 'xlink:href="https://www.google.com"' 'office:name=""><text:span' 'text:style-name="Definition">I'\''m' an inline-style link with 'title</text:span></text:a>' Prueba de imagen: '<draw:frame' 'draw:name="img1"><draw:image' 'xlink:href="deloitte.jpg"' 'xlink:type="simple"' 'xlink:show="embed"' 'xlink:actuate="onLoad"' '/></draw:frame>' Prueba de 'código</text:p>' '<text:p' 'text:style-name="P1">Prueba' de 'código</text:p>'
pandoc: text:style-name="Heading_20_1": openFile: does not exist (No such file or directory)
pandoc \
--template odt.template \
main.md \
-o my.odt \
-V s1="$( pandoc -t opendocument -f markdown sections/section1.md | sed 's/"/\\"/g')" \
-V s2="$( pandoc -t opendocument -f markdown sections/section2.md | sed 's/"/\\"/g')" \
-V s3="$( pandoc -t opendocument -f markdown sections/section3.md | sed 's/"/\\"/g')"
$ pandoc \
--template odt.template \
main.md \
-t opendocument \
-o my.odt.xml \
-V s1="$( pandoc -t opendocument -f markdown sections/section1.md | sed 's/"/\\"/g')" \
-V s2="$( pandoc -t opendocument -f markdown sections/section2.md | sed 's/"/\\"/g')" \
-V s3="$( pandoc -t opendocument -f markdown sections/section3.md | sed 's/"/\\"/g')"
$ sed -i -e 's/\\"/"/g' my.odt.xml
$ pandoc --template my.odt.xml main.md -o my.odt
There are two things to fiddle with. The --reference-odt,
which can help with style (spacing, margins, etc.), and
the opendocument template, which is a place to put hooks
for content.
You can create a custom opendocument template (use
'pandoc -D opendocument' to get the default one).
In place of $body$ you might have, for example,
$s1$, $s2$, and $s3$, perhaps with some content
intervening.
You can then use pandoc to fill these variables:
pandoc --template mycustom.opendocument main.md -o my.odt \
-V s1=$(pandoc -f markdown -t opendocument s1.md)
-V s2=$(pandoc -f markdown -t opendocument s2.md)
-V s3=$(pandoc -f markdown -t opendocument s3.md)