public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: Automating markdown to odt with fields
Date: Wed, 27 Apr 2016 10:21:20 -0700	[thread overview]
Message-ID: <20160427172120.GA40999@MacBook-Air-2.local> (raw)
In-Reply-To: <59292504-c115-4935-b7e2-004c0c875289-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>

Well, you could always use python or something instead of
bash; that would allow you to put arbitrary string values
in as command line arguments without worrying about escapes
and quoting.

+++ JDani Jiménez [Apr 27 16 05:00 ]:
>   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 [1]main.md -o my.odt \
>       -V s1=$(pandoc -f markdown -t opendocument [2]s1.md)
>       -V s2=$(pandoc -f markdown -t opendocument [3]s2.md)
>       -V s3=$(pandoc -f markdown -t opendocument [4]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 [5]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [6]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [7]https://groups.google.com/d/msgid/pandoc-discuss/59292504-c115-4935-
>   b7e2-004c0c875289%40googlegroups.com.
>   For more options, visit [8]https://groups.google.com/d/optout.
>
>References
>
>   1. http://main.md/
>   2. http://www.google.com/url?q=http://s1.md&sa=D&sntz=1&usg=AFQjCNFfOk5lY6XBrSOLLvz5QcCpy_EH-w
>   3. http://s2.md/
>   4. http://s3.md/
>   5. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   6. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   7. https://groups.google.com/d/msgid/pandoc-discuss/59292504-c115-4935-b7e2-004c0c875289-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   8. https://groups.google.com/d/optout

-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20160427172120.GA40999%40MacBook-Air-2.local.
For more options, visit https://groups.google.com/d/optout.


  parent reply	other threads:[~2016-04-27 17:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  6:43 JDani Jiménez
     [not found] ` <7608243e-3f15-48de-9230-00b78127246e-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-26 10:07   ` BP Jonsson
2016-04-26 10:36   ` kurt.pfeifle via pandoc-discuss
     [not found]     ` <9a664450-8fbb-4a6d-abd5-5a4c567b2e69-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-26 10:46       ` kurt.pfeifle via pandoc-discuss
2016-04-26 20:58   ` JDani Jiménez
     [not found]     ` <1a7138b7-aa6a-4873-b214-9644944c75c6-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-26 21:05       ` JDani Jiménez
2016-04-26 21:22       ` John MACFARLANE
     [not found]         ` <20160426212236.GA35686-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org>
2016-04-26 21:42           ` JDani Jiménez
2016-04-27 12:00           ` JDani Jiménez
     [not found]             ` <59292504-c115-4935-b7e2-004c0c875289-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2016-04-27 17:21               ` John MacFarlane [this message]
     [not found]                 ` <20160427172120.GA40999-jF64zX8BO091tJRe0FUodcM6rOWSkUom@public.gmane.org>
2016-04-29  8:59                   ` JDani Jiménez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160427172120.GA40999@MacBook-Air-2.local \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).