This solution is not working... The -V $(pandoc...) commands output contains characters that are control characters for bash, so the command cannot be launched like that.
Example:
$ 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)

The same, but with the debug enabled:
$ 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)


I tryed these ways to get
  • Using quotes and scaping quotes in the output of pandoc variable commands. Like this
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')"

Result: Malformed odt. Quotes keep scaped in contet.xml


  • A three steps procedure
    • Compose an xml opendocument file, with quotes scaped
    • Remove backslashes, unscape quotes
    • Generate the odt
$ 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

Result: Empty .odt file, but elements in content.xml seem ok??¿!

  • Generating a yaml file in order to make pandoc read vars from it, rather than from the command line and avoid.
Result: In progress... I couldn't make pandoc read markdown from yaml.


However, I'm in doubt about what main.md is... I'm using a just touched file.

El martes, 26 de abril de 2016, 23:22:51 (UTC+2), John MacFarlane escribió:
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)

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/59292504-c115-4935-b7e2-004c0c875289%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.