From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/14856 Path: news.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: Automating markdown to odt with fields Date: Wed, 27 Apr 2016 10:21:20 -0700 Message-ID: <20160427172120.GA40999@MacBook-Air-2.local> References: <7608243e-3f15-48de-9230-00b78127246e@googlegroups.com> <1a7138b7-aa6a-4873-b214-9644944c75c6@googlegroups.com> <20160426212236.GA35686@protagoras.berkeley.edu> <59292504-c115-4935-b7e2-004c0c875289@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1461777709 14314 80.91.229.3 (27 Apr 2016 17:21:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Apr 2016 17:21:49 +0000 (UTC) To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCJZJHG45QDBBHPKQO4QKGQEEJUEM5Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Apr 27 19:21:35 2016 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-yw0-f188.google.com ([209.85.161.188]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1avT9a-0003dc-WD for gtp-pandoc-discuss@m.gmane.org; Wed, 27 Apr 2016 19:21:35 +0200 Original-Received: by mail-yw0-f188.google.com with SMTP id v81sf18997575ywa.0 for ; Wed, 27 Apr 2016 10:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:from:date:to:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=AreznMb6HoOcZinxV6Zjc1JW+mHzcwTrxgS6oU7CJJY=; b=OsOLhN0vf+ERGMvlGnhNpnOZYgm3t4DYG066udjT0nW62Z6mTCxKusRivILL+L0wO6 wzv4cfJwuj5fDfnqb5wK4hkJUyb7u8NZM9HKihO2Rnv+miHFc7CsgW7oKO+t7b/X9Rls RRdAU7C9WTI/coQ3DkZszSAHJm5ewx/AJZXpfGHExFwjroTQWom8zAeDdJpP+1IzN6C6 GRpU6Dr2/KcmOYNXqrRo3K/DClmX1h2/JQoTcuqu6qXbK/vr8XV68Z1g/YWhbr7kJOqu PkHtC1csGesnBFQrGGD7O3k9S6h+pZSA+1cYnqQGj/PmKzFtpCD71/PRhDA+aZTG X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:from:date:to:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=AreznMb6HoOcZinxV6Zjc1JW+mHzcwTrxgS6oU7CJJY=; b=UOEkhV3y4ztdKHt9BZgPvU3AWqr/hzvDlXR8Rm2zQn5FoSccFUHpX0qlhKDdlpKbX1 a+uL0iZ8qjzsiRdJagBzP578sETLTGFXC0KFzjJs55qsuH20RgzYJ8SoDsEFJks9bRo1 40tz76e6XkvQoc3XlkI9r6AucFC4qL2/mGp1IlgfN48S7a2nj1Ronarg3PgBO+ldRNNk jRQspnrBLHziW3aYAulyexlNHjjnqTbM8qGMPRXoIqgHsfI2L6lmClvJ1+tVlpy63kVa C7B2MPMIU9+68r2NmnPzs/SgaEEdhDlzx Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOPr4FXU1Umr+kI7lrf6njVJO8Eyha7xxgm6Uipib95APNX0UvnvVYELhKFUke4sCuCUlg== X-Received: by 10.140.108.203 with SMTP id j69mr369304qgf.20.1461777694272; Wed, 27 Apr 2016 10:21:34 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.140.25.248 with SMTP id 111ls546203qgt.33.gmail; Wed, 27 Apr 2016 10:21:33 -0700 (PDT) X-Received: by 10.140.106.75 with SMTP id d69mr6462615qgf.4.1461777693793; Wed, 27 Apr 2016 10:21:33 -0700 (PDT) Original-Received: from mail-pa0-x229.google.com (mail-pa0-x229.google.com. [2607:f8b0:400e:c03::229]) by gmr-mx.google.com with ESMTPS id 17si893531pfw.0.2016.04.27.10.21.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Apr 2016 10:21:33 -0700 (PDT) Received-SPF: pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c03::229 as permitted sender) client-ip=2607:f8b0:400e:c03::229; Original-Received: by mail-pa0-x229.google.com with SMTP id zm5so24018897pac.0 for ; Wed, 27 Apr 2016 10:21:33 -0700 (PDT) X-Received: by 10.67.22.129 with SMTP id hs1mr13595024pad.105.1461777693476; Wed, 27 Apr 2016 10:21:33 -0700 (PDT) Original-Received: from johnmacfarlane.net (li55-134.members.linode.com. [74.82.3.134]) by smtp.gmail.com with ESMTPSA id q26sm8014602pfi.57.2016.04.27.10.21.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Apr 2016 10:21:32 -0700 (PDT) Original-Received: by johnmacfarlane.net (Postfix, from userid 1000) id 515E8A329; Wed, 27 Apr 2016 13:21:21 -0400 (EDT) Content-Disposition: inline In-Reply-To: <59292504-c115-4935-b7e2-004c0c875289-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-PGP-Key: http://johnmacfarlane.net/jgm.asc User-Agent: Mutt/1.5.23 (2014-03-12) X-Original-Sender: jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@berkeley-edu.20150623.gappssmtp.com; spf=pass (google.com: domain of jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org designates 2607:f8b0:400e:c03::229 as permitted sender) smtp.mailfrom=jgm-TVLZxgkOlNX2fBVCVOL8/A@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:14856 Archived-At: 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=C3=A9nez [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=3D$( pandoc -t opendocument -f markdown sections/section1.md ) -V > s2=3D$( pandoc -t opendocument -f markdown sections/section2.md ) -V > s3=3D$( pandoc -t opendocument -f markdown sections/section3.md ) > pandoc: text:style-name=3D"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=3D$( pandoc -t opendocument -f markdown sections/section1.md ) -V > s2=3D$( pandoc -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 -f markdown sections/section3.md > + pandoc --template odt.template main.md -t opendocument -o my.odt -V > 's1=3D 'text:outline-level=3D"1">Encabezado' '1' ' 'text:style-name=3D"Heading_20_2"' 'text:outline-level=3D"2">Encabezado= ' > '2' ' 'text:outline-level=3D"3">Encabezado' '3' ' 'text:style-name=3D"L1">' '' ' 'text:style-name=3D"P1">lista' item '1' '' > '' 'lista' item > '2' '' '' ' 'text:style-name=3D"P1">lista' item '3' '' > '' -V 's2=3DPrue= ba' > de texto en 'Negrita' , > 'cursiva,' ' 'text:style-name=3D"T3">tachado' y ' 'text:style-name=3D"T4">mezcla 'text:style-name=3D"T5">' ' 'text:style-name=3D"T6">de' > ' 'text:style-name=3D"T8">negrita 'text:style-name=3D"T9">' ' 'text:style-name=3D"T10">y 'text:style-name=3D"T11">' ' 'text:style-name=3D"T12">negrita 'text:style-name=3D"T13">' ' 'text:style-name=3D"T14">cursiva' -V 's3=3D 'text:style-name=3D"Text_20_body">Prueba' de link: ' 'xlink:type=3D"simple"' 'xlink:href=3D"https://www.google.com"' > 'office:name=3D"">I'\''m' a= n > inline-style link with 'title' Prueba de imagen: > ' 'xlink:href=3D"deloitte.jpg"' 'xlink:type=3D"simple"' 'xlink:show=3D"em= bed"' > 'xlink:actuate=3D"onLoad"' '/>' Prueba de 'c=C3=B3digo' > 'Prueba' de 'c=C3=B3digo' > 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 variable > commands. Like this > > pandoc \ > --template odt.template \ > main.md \ > -o my.odt \ > -V s1=3D"$( pandoc -t opendocument -f markdown sections/section1.md | > sed 's/"/\\"/g')" \ > -V s2=3D"$( pandoc -t opendocument -f markdown sections/section2.md | > sed 's/"/\\"/g')" \ > -V s3=3D"$( 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=3D"$( pandoc -t opendocument -f markdown sections/section1.md | > sed 's/"/\\"/g')" \ > -V s2=3D"$( pandoc -t opendocument -f markdown sections/section2.md | > sed 's/"/\\"/g')" \ > -V s3=3D"$( 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??=C2=BF! > * 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=C3=B3: > > 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=3D$(pandoc -f markdown -t opendocument [2]s1.md) > -V s2=3D$(pandoc -f markdown -t opendocument [3]s2.md) > -V s3=3D$(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=3Dhttp://s1.md&sa=3DD&sntz=3D1&usg=3DAFQ= jCNFfOk5lY6XBrSOLLvz5QcCpy_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=3Demail&utm_source=3Dfooter > 8. https://groups.google.com/d/optout --=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/20160427172120.GA40999%40MacBook-Air-2.local. For more options, visit https://groups.google.com/d/optout.