From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/23040 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Hans Kunkell Newsgroups: gmane.text.pandoc Subject: Re: Conditional compilation - How to? Date: Tue, 25 Jun 2019 17:56:58 -0700 (PDT) Message-ID: <1375b479-60d6-4514-8c72-db60f3355ab8@googlegroups.com> References: <61bdaf46-d88a-4ef1-b145-71ad5900fed8@googlegroups.com> <44645f9a-1670-4f4e-93cc-e24394fa10f4@googlegroups.com> <5fc2de0f-82db-4d02-9dc9-ff5db8a8b9b4@googlegroups.com> <5a4d26a3-b9b7-dda1-d437-6e7cdd519dba@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_2250_289140617.1561510618554" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="252469"; mail-complaints-to="usenet@blaine.gmane.org" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDXJP3V4SEPRBXEFZPUAKGQEB3NI34Q-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jun 26 02:57:04 2019 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-ot1-f58.google.com ([209.85.210.58]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1hfwFD-0013XM-0P for gtp-pandoc-discuss@m.gmane.org; Wed, 26 Jun 2019 02:57:03 +0200 Original-Received: by mail-ot1-f58.google.com with SMTP id d13sf230400oth.20 for ; Tue, 25 Jun 2019 17:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=doZnz9oG+/zCmxxjgmUFolaDN6yd4/4/ahwRDmYQunE=; b=BWBP+MYthBRMYj/SRIsn0HDHxs9TVaOanIpEaLODQyG9pv6ySqE+D95XllnVt27XW1 Ct8l23HBi0uyncqqTVCbBi5CpGpwKvEiPkxUYtl7/xLT/H/BIEWGXjLSv4e35wqy/RvC DabEzuEdI+9jmCv3iHXGbDsiozz8Ker9zm6XHa7n2X4zKjwqw1pvkonnlL/E46cpvuwT 9j1mJ02nFm2dD0QV7F1H0sdqo5cpIjae6fKFRzP8WyfXj/0D6NwMYhn1fJpG14ljt2XZ WSmCs1Gl2VD4mqpDux2ntyr/55fl8Einj1RNMVMpCsM+g/g0oP+IiiSedckGhPGa4xor 3lfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=doZnz9oG+/zCmxxjgmUFolaDN6yd4/4/ahwRDmYQunE=; b=bbqmSWlfLhKgxND1yVGPbgs0DpqTiTIEuSG7vYzsvwwKfBgOUhUnmXMJ+YO2cNHqui ifMA959WnXoKW48VH1VkqxggykOhOxs4P7sE/UrWVhr7E1oZURiqOCLUCxa7ValV7tbN GqgmbBeQNAz97OQxrmbbL8r9iC3MvgXFtnF8c55eGQvQAua/+Ygzfx69hTjTo5nKpOfx u/CRBxdEFfAS7soksFrC2jVhbCmZ8l0pIoOfGAXJuDtsOa2jR7ErnWpddwWUocG9GXCx nj9cWi6OP8kfGmCYzrq0mT1yN3HNPLM4yrmEEm7YTM4w+AUnWfjJvBDyMruSO+zl53qv wpkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=doZnz9oG+/zCmxxjgmUFolaDN6yd4/4/ahwRDmYQunE=; b=qnPetTio5Vkj4JE8GYdqtyAwHauI6g2tTtNui1Pxlm9702KaqmNu1ciwLVtuZsi2VR f3zBlTmOaXBjBIbw5tck+MvzUhpdzxnReyeInubkEzkfqkZEulxkLhjhrQ14jveH9m5P uAgJtzK7QTuhzyk6gtFY49zMZMytQFviNoOb4NX2c7hicEnlBTQGAzpRBZtLTdNETaqQ ICOk6sy7VneoTOCCTCMdBcm1CV6Mn1D4VattVeRwDT9GRY821Pk/f6O0o/Lzu+d4mqsF dHZrngz4W82/SwiqRvtWHo9TizlV/Dvr9RDAY07Li/HgUSoynqo/e6NzYQLhQd0bETNj VFzA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: APjAAAVSUBoGsTTdW2FpmeaoplCxxHoayd2r1M03vcW4uBJdQokMmBMi V5BRxKhVvjpJewDjH+yzRHg= X-Google-Smtp-Source: APXvYqxbkDKnVapOaNqmdhXmlgkN5OX8LbLMi+I9H4ckn+T1PUju4niDm+4jIenhyYsW7StGpngOog== X-Received: by 2002:a05:6830:8b:: with SMTP id a11mr1082599oto.346.1561510621628; Tue, 25 Jun 2019 17:57:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:aca:4ad3:: with SMTP id x202ls36408oia.0.gmail; Tue, 25 Jun 2019 17:57:00 -0700 (PDT) X-Received: by 2002:aca:210f:: with SMTP id 15mr88864oiz.24.1561510620664; Tue, 25 Jun 2019 17:57:00 -0700 (PDT) In-Reply-To: <5a4d26a3-b9b7-dda1-d437-6e7cdd519dba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> X-Original-Sender: hanzukun-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-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:23040 Archived-At: ------=_Part_2250_289140617.1561510618554 Content-Type: multipart/alternative; boundary="----=_Part_2251_37283461.1561510618555" ------=_Part_2251_37283461.1561510618555 Content-Type: text/plain; charset="UTF-8" Hi! Perhaps you are satisfied with the way discussed earlier. I have an alternative solution for those who are interested. I also had the need to make two versions of a document where most of the contents are the same. My solution was to have single file and where needed write like this: <<< internal Contents here will be in *internal* version. You may include any valid markdown here. <<< external ... For external version ... >>> The attached bash script will parse the file and depending on targeting internal or external version (or whatever identifiers you prefer) two different intermediate files will be created and then processed by pandoc. This is the way I solved it and if you find it useful for your needs, please use it! Regards Hans -- 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/1375b479-60d6-4514-8c72-db60f3355ab8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. ------=_Part_2251_37283461.1561510618555 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi!

Perhaps you are satisfie= d with the way discussed earlier. I have an alternative solution for those = who are interested.

I also had the need to mak= e two versions of a document where most of the contents are the same. My so= lution was to have single file and where needed write like this:
=
<<= < internal
Contents here will be in *internal* version. You may inclu= de any valid markdown here.
<<< external
... For external ve= rsion ...
>>>

The attached bas= h script will parse the file and depending on targeting internal or externa= l version (or whatever identifiers you prefer) two different intermediate f= iles will be created and then processed by pandoc.

This is the way I solved it and if you find it useful for your needs, plea= se use it!

Regards
Hans

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to 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/1375b479-60d6-4514-8c72-db60f3355ab8%40googlegroups.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_2251_37283461.1561510618555-- ------=_Part_2250_289140617.1561510618554 Content-Type: text/plain; charset=US-ASCII; name=multi.sh.txt Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=multi.sh.txt X-Attachment-Id: 9ec7558c-6563-4cfb-b928-46ba6f889afc Content-ID: <9ec7558c-6563-4cfb-b928-46ba6f889afc> #!/bin/bash SOURCESCRIPT="$0" SAVEINTERMEDIATE=true function prep() { OUTPUTFILE="$1" shift TARGET="$1" shift $SAVEINTERMEDIATE && INTERMEDIATEFILE="$OUTPUTFILE-intermediate.md" || INTERMEDIATEFILE="/dev/null" awk -f <(sed -e '/[B]EGIN_AWK1/,/[E]ND_AWK1/!d' "$SOURCESCRIPT") \ -v target="$TARGET" \ $@ | tee "$INTERMEDIATEFILE" | \ pandoc -f markdown \ --standalone \ --reference-doc=reference.odt \ -o "$OUTPUTFILE" return $? } prep "output-internal.odt" internal $@ prep "output-external.odt" external $@ exit #BEGIN_AWK1 /^<< "/dev/stderr" conditional = nextconditional next } /^>>>/ { conditional = "" next } // { if (conditional) { if (conditional != target) next } print } # From: https://stackoverflow.com/questions/9985528/how-can-i-trim-white-space-from-a-variable-in-awk function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s } function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s } function trim(s) { return rtrim(ltrim(s)); } #END_AWK1 ------=_Part_2250_289140617.1561510618554--