From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/14855 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?JDani_Jim=C3=A9nez?= Newsgroups: gmane.text.pandoc Subject: Re: Automating markdown to odt with fields Date: Wed, 27 Apr 2016 05:00:36 -0700 (PDT) Message-ID: <59292504-c115-4935-b7e2-004c0c875289@googlegroups.com> References: <7608243e-3f15-48de-9230-00b78127246e@googlegroups.com> <1a7138b7-aa6a-4873-b214-9644944c75c6@googlegroups.com> <20160426212236.GA35686@protagoras.berkeley.edu> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_367_635498443.1461758436737" X-Trace: ger.gmane.org 1461758458 4795 80.91.229.3 (27 Apr 2016 12:00:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Apr 2016 12:00:58 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDL6Z34U5MNRBZOTQK4QKGQEHWLWRAI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Apr 27 14:00:45 2016 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ig0-f188.google.com ([209.85.213.188]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1avO96-0002pG-CH for gtp-pandoc-discuss@m.gmane.org; Wed, 27 Apr 2016 14:00:44 +0200 Original-Received: by mail-ig0-f188.google.com with SMTP id yi10sf13810767igc.0 for ; Wed, 27 Apr 2016 05:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Cfbe8JiwPBenxeLId1aAnJNbd88wIvQpmoto6n5RV78=; b=Uwg22zTE0FgLrwUh7dlWbsImd3BksqvGfjNhXBvBdboPJGH556ytYntbM3JoCppVC6 PX41uU33U9wYWDJYnp98O7n8iYTMrNwOqQes5mfWX431QDfxzr1+vU7fHpjl/1WCHKLQ Jl8ObVuQr8XNVGgH2Pq5Yw5pDdu727p/zp7VWCNjz08OyTsc797EZVuG4R3TOhyWqdR7 dff0diMdIfePJ3OXhecnqk/z5CVxTsmwGyDArodkJc4p1XtXjBZMcPB//CB+Z6bW1dXu fcx76NVyjrXtTdYgAO0fi5vaShgtgI8vWShiADI4BBpQVd4yZeGO+c4WAv8ZDAAfuBaM tSJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Cfbe8JiwPBenxeLId1aAnJNbd88wIvQpmoto6n5RV78=; b=iMgfM5v1PqjznAOP10Pi3C9vlDvdK9Trpx2XYKJeV+R9X82Qk6/DKg+pLp4QZ1lR5r QBLWw3QEneXjsggJ+3WmS5lSvHRpWCvkIVz940SkQnxl2m5yJqv7Ad2Vobenrj64JAst JJ97ZSvQynwJLX1koWkuzKjTaNIUjAtqcbiFXuYvXZDUJ/jN5CR7+csQ/Do+b4G0CWZN 5Dd927J9AP5yvzN4AmvISYuuryORe4dabkTZxB4fWdWaT05pOAjvfVI6hLwz+VGexCn4 dpppPTm7xJAdFPPXuo+UtLwofUEHzHKj0QLo8buGLciWgmp72qkoNMVm5PXJYJN0lCLf mHrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=Cfbe8JiwPBenxeLId1aAnJNbd88wIvQpmoto6n5RV78=; b=Zh7m6UUeCXc9sEFLnGRjmKlz3HZfuiR09ysDiaeQOG3dFJhdX+I9Ea5KwLsQTNi44Y OuCYVnskz7vWvWEjGWX1BxY9Q72A+VlgnaBzdqtFv9EyJP0GD1C6nPCQy9sJD3NbPUTY BruCs/NwL99/gU1uwurHOYjFaJoU5ubukYYetqPhhygOCQ9fhGUmuPscgFpyx89WXMn4 RdTxBSqe+0+5FkdvQXPL6kbkXeunAgZQviVoCi5ZmpX+diVC/MtU/Xbnp1zioM4pdXGv oJEMQQHvlKbAKw8QjxnyY0a5jvmbhn4FdIXLIOxfjyN4DDwz/1zD4JKn+Nql8yurwCjO xlIg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOPr4FU/k33Dvx4hm0b86pa/UMkndTFYR9nDm/6XRrhatC2AjyH1WcB2epNM3rOXARqN7w== X-Received: by 10.157.47.135 with SMTP id r7mr99936otb.5.1461758438575; Wed, 27 Apr 2016 05:00:38 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.157.47.73 with SMTP id h67ls54338otb.65.gmail; Wed, 27 Apr 2016 05:00:37 -0700 (PDT) X-Received: by 10.182.184.73 with SMTP id es9mr43588obc.5.1461758437344; Wed, 27 Apr 2016 05:00:37 -0700 (PDT) In-Reply-To: <20160426212236.GA35686-nFAEphtLEs/fysO+viCLMa55KtNWUUjk@public.gmane.org> X-Original-Sender: jdjp83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:14855 Archived-At: ------=_Part_367_635498443.1461758436737 Content-Type: multipart/alternative; boundary="----=_Part_368_380795481.1461758436739" ------=_Part_368_380795481.1461758436739 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable This solution is not working... The -V $(pandoc...) commands output=20 contains characters that are control characters for bash, so the command=20 cannot be launched like that. Example: $ pandoc --template odt.template main.md -t opendocument -o my.odt -V s1=3D= $(=20 pandoc -t opendocument -f markdown sections/section1.md ) -V s2=3D$( pando= c -t=20 opendocument -f markdown sections/section2.md ) -V s3=3D$( pandoc -t=20 opendocument -f markdown sections/section3.md ) pandoc: text:style-name=3D"Heading_20_1": openFile: does not exist (No such= =20 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=3D= $(=20 pandoc -t opendocument -f markdown sections/section1.md ) -V s2=3D$( pando= c -t=20 opendocument -f markdown sections/section2.md ) -V s3=3D$( pandoc -t=20 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=20 's1=3DEncabezado' '1' 'Encabezado'=20 '2' 'Encabezado' '3' '' '' 'lista' item '1' ''=20 '' 'lista' item '2'=20 '' '' 'lista' item '3' ''=20 '' -V 's2=3DPrueba' = de=20 texto en 'Negrita' ,=20 'cursiva,' 'tachado' y 'mezcla'=20 'de' 'negrita'=20 'y' 'negrita' 'cursiva' -V 's3=3DPrueba' de link: 'I'\''m' an=20 inline-style link with 'title' Prueba de imagen: '' Prueba de 'c=C3=B3digo' 'Prueb= a' de=20 'c=C3=B3digo' pandoc: text:style-name=3D"Heading_20_1": openFile: does not exist (No such= =20 file or directory) I tryed these ways to get - Using quotes and scaping quotes in the output of pandoc variable=20 commands. Like this =20 pandoc \ --template odt.template \ main.md \ -o my.odt \ -V s1=3D"$( pandoc -t opendocument -f markdown sections/section1.md | sed= =20 's/"/\\"/g')" \ -V s2=3D"$( pandoc -t opendocument -f markdown sections/section2.md | sed= =20 's/"/\\"/g')" \ -V s3=3D"$( pandoc -t opendocument -f markdown sections/section3.md | sed= =20 '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 =20 $ pandoc \ --template odt.template \ main.md \ -t opendocument \ -o my.odt.xml \ -V s1=3D"$( pandoc -t opendocument -f markdown sections/section1.md | sed= =20 's/"/\\"/g')" \ -V s2=3D"$( pandoc -t opendocument -f markdown sections/section2.md | sed= =20 's/"/\\"/g')" \ -V s3=3D"$( pandoc -t opendocument -f markdown sections/section3.md | sed= =20 's/"/\\"/g')" $ sed -i -e 's/\\"/"/g' my.odt.xml $ pandoc --template my.odt.xml main.md -o my.odt=20 Result: Empty .odt file, but elements in content.xml seem ok??=C2=BF! - Generating a yaml file in order to make pandoc read vars from it,=20 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=20 file. El martes, 26 de abril de 2016, 23:22:51 (UTC+2), John MacFarlane escribi= =C3=B3: > > There are two things to fiddle with. The --reference-odt,=20 > which can help with style (spacing, margins, etc.), and=20 > the opendocument template, which is a place to put hooks=20 > for content.=20 > > You can create a custom opendocument template (use=20 > 'pandoc -D opendocument' to get the default one).=20 > > In place of $body$ you might have, for example,=20 > $s1$, $s2$, and $s3$, perhaps with some content=20 > intervening.=20 > > You can then use pandoc to fill these variables:=20 > > pandoc --template mycustom.opendocument main.md -o my.odt \=20 > -V s1=3D$(pandoc -f markdown -t opendocument s1.md=20 > )=20 > > -V s2=3D$(pandoc -f markdown -t opendocument s2.md)=20 > -V s3=3D$(pandoc -f markdown -t opendocument s3.md)=20 > --=20 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 e= mail 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/59292504-c115-4935-b7e2-004c0c875289%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_368_380795481.1461758436739 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This solution is not working... The -V $(pandoc...) comman= ds output contains characters that are control characters for bash, so the = command cannot be launched like that.
Example:
$ pandoc --te= mplate odt= .template main.md -t opendocument -o my.odt <= /span>-V s1=3D$( pandoc -t opendocument -f markdown sections/section1.= md =C2=A0)= -V s2=3D$( pandoc -t opendocument -f markdown sections/section2.= md = ) -V s3=3D$(= pandoc -<= /span>t opendocum= ent -f markdown sect= ions/section3= .md )
pandoc
: text:style-name= =3D= "Heading_20_= 1": openFile
: does not exist (No such file or directory)

The s= ame, but with the debug enabled:
$ set<= /span> -x
$ pandoc
--template odt.template main.md -t open= document -= o <= span style=3D"color: #008;" class=3D"styled-by-prettify">my.odt -V s1=3D$( pando= c -= t opendocument -f markdown sections/section1.md =C2=A0) -V s2=3D$( pandoc <= span style=3D"color: #660;" class=3D"styled-by-prettify">-t opendocument -f markdown sections/section2.md ) -V= s3=3D$( 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 <= span style=3D"color: #660;" class=3D"styled-by-prettify">-f markdown sections<= span style=3D"color: #660;" class=3D"styled-by-prettify">/section3.md
+ pandoc --template odt.t= emplate ma= in.= md -t opendocument -o my.odt -= V 's1= =3D<text:h' &= #39;text:style-name=3D"Heading_20_1"' 'text:outline-level=3D"1">= Encabezado' '= ;1</text:h>' '<text:h' 'text:style-name=3D"Heading_20_2"' 'text:outline-level=3D"2&quo= t;>Encabezado' '2</text:h>' '<text:h' 'text:style-name=3D"Heading_20_3"' 'text:outline-level=3D"= 3">Encabezado' '3</text:h>' '<text:list' 'text:style-name=3D"L1">'
'<text:list-item>&= #39; '<text:p= ' 'text:styl= e-name=3D"P1">lista' item '1</text:p>' '</text:list-item>' '<text:list-item>&= #39; '<text:p= ' 'text:styl= e-name=3D"P1">lista' item '2</text:p>' '</text:list-item>' '<text:list-item>&= #39; '<text:p= ' 'text:styl= e-name=3D"P1">lista' item '3</text:p>' '</text:list-item>' '</text:list>'= -V 's2=3D<text:p' 'text:style-name=3D"= ;Text_20_body">Prueba' de texto en '<text:span' 'text:style-name=3D"T1">Neg= rita</text:span>' , = '<t= ext:span' 't= ext:style-name=3D"T2">cursiva</text:span>,' '<text:span' 'text:style-name=3D&= quot;T3">tachado</text:span>' y '<text:span' 'text:style-name=3D"T4">= mezcla</text:span><text:span' 'text:style-name=3D"T5">' '</text:span>&= lt;text:span' &#= 39;text:style-name=3D"T6">de</text:span><text:span= 9; = 'text:style-n= ame=3D"T7">' '</text:span><text:span' 'text:style-name=3D"T8">ne= grita</text:span><text:span' 'text:style-name=3D"T9">' '</text:span>&= lt;text:span' &#= 39;text:style-name=3D"T10">y</text:span><text:span= 9; = 'text:style-n= ame=3D"T11">' '</text:span><text:span' 'text:style-name=3D"T12">= negrita</text:span><text:span' 'text:style-name=3D"T13">' '</text:span>= <text:span' &= #39;text:style-name=3D"T14">cursiva</text:span></text= :p>' -= V 's3=3D<text:p'= 'text:style-nam= e=3D"Text_20_body">Prueba' de link: '<text:a' 'xlink:type=3D"simple"' 'xlink:href=3D"https://www.g= oogle.com"' 'office:name=3D""><text:span' 'text:style-name=3D"Definition&= quot;>I'\'= ;'m' an inli= ne-style link with 'title</text:span></text:a><= span style=3D"color: #080;" class=3D"styled-by-prettify">' Prueba de im= agen: '<draw<= /span>:frame' 'draw:name=3D"img1"><draw:image' 'xlink:hre= f=3D
"deloitte.j= pg"' 'xlink:type<= /span>=3D<= span style=3D"color: #080;" class=3D"styled-by-prettify">"simple"= ' 'xlink:show=3D"embed"' = 9;xlink:actuate=3D"onLoad"' '/></draw:frame>' Prueba de 'c=C3=B3digo</text:p>' '<text:p' 'text:sty= le-name=3D"P1">Prueba' de 'c=C3=B3digo</text:p>'
pandoc: text:style-name=3D"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 va= riable commands. Like this
pan= doc \
=C2=A0--template odt.template \
=C2=A0main
.md \
= =C2=A0
-o my.odt \
=C2=A0
-V s1=3D"$( pandoc -t opendocument -f markdown sections/section1.md =C2=A0| = sed 's/"/\\= "/g')" \
=C2= =A0
-V s2=3D"$( pandoc -t opendocum= ent -f markdown sections/section2.md =C2=A0| sed 's/"/\\"/g')"<= span style=3D"color: #000;" class=3D"styled-by-prettify">
\
=C2=A0
-V s3=3D"$( pandoc -t opendocument -f markdown sections/secti= on3.md =C2=A0| sed 's/"/\\"/g')"

Result: Malformed odt. Quotes keep scaped in con= tet.xml


  • A three steps proce= dure
    • Compose an xml opendocument file, with quotes scaped
    • Remove backslashes, unscape quotes
    • Generate the odt
    $ pandoc \
    =C2=A0
    --template odt.template \=
    =C2=A0main.md
    \
    =C2=A0
    -t opendocument \
    =C2=A0
    -o my= .odt.xml \
    =C2=A0
    -V s1=3D"$( pandoc -t opendocument -f markdown sections/section1.= md =C2=A0| sed 's/"/\\"/g')" \
    =C2=A0
    -V s2=3D"$( pandoc -t = opendocument -f markdown sections/section2.md =C2=A0| sed 's/"/\\"/g')"<= /span> \
    =C2=A0
    -V s3=3D"$( pandoc -t opendocument -f markdown sectio= ns/section3.md =C2=A0| 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 cont= ent.xml seem ok??=C2=BF!

    • Generating a yaml file in order to ma= ke pandoc read vars from it, rather than from the command line and avoid.
    Result: In progress... I co= uldn'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=C3=B3:
    There are two things to fiddle with. =C2=A0The --refere= nce-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 ma= in.md -o my.odt \
    =C2=A0 -V s1=3D$(pandoc -f markdown -t opendocument s1.md)
    =C2=A0 -V s2=3D$(pandoc -f markdown -t opendocument pand= oc-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.co= m.
    For more options, visit http= s://groups.google.com/d/optout.
    ------=_Part_368_380795481.1461758436739-- ------=_Part_367_635498443.1461758436737--