From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/26028 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Denis Maier Newsgroups: gmane.text.pandoc Subject: Re: Pandoc Lua script to filter specific markdown sub sections during PDF generation Date: Tue, 1 Sep 2020 10:28:57 +0200 Message-ID: <92ac8df6-b88a-b047-b9f0-1fe62873b710@mailbox.org> References: <4e07ae0a-dcb1-4f89-8b91-ba787b7bea1cn@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------2E6CBBB25B2FA63E7625E6CF" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1966"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDAN5ZVOUMHBBUUMXD5AKGQEUNX6ZMA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Sep 01 10:29:11 2020 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pj1-f57.google.com ([209.85.216.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kD1fC-0000Mb-5R for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 01 Sep 2020 10:29:10 +0200 Original-Received: by mail-pj1-f57.google.com with SMTP id t13sf177258pjd.0 for ; Tue, 01 Sep 2020 01:29:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1598948949; cv=pass; d=google.com; s=arc-20160816; b=o/8ZcYfR9GsEaiaHftgsLPzzadUTUh6HqbfAjT9OMs/NKbe2F4Xj0XAO5iNM6iGcV6 kvoc8/MfOtaY8NmNyoHh77oNZ6831bQ0zDzPx2M/YVrDyx/paGo2rhotRqpxRICI5JMg l9mRfe2ccQjNjlLOLjMGYS6uyeTB25Qy3IJ/MGCnz4GDAdCzqJ9f1T6ZxYlTLOYMhkLm ZiHYs/KrYfmeaMqmF5HDy+asAznatOCjvn3t1fCoRD6ElPV7YECudNixi6NAkyfYa5L4 q+pLkI1TorBx0dx4gRoKE5MTKAwZqku7f6dkBXnGkgv4CxvJ/DHMK9K96svrhjk4a/It hhEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:in-reply-to:mime-version :date:message-id:from:references:to:subject:sender:dkim-signature; bh=CCIwf8WIQU7mqtv5DH0oAO0u8LEuFiOHmAFA2ccO/sA=; b=HpLelMgA8iFqJDbBnYIvS9W2VXw7ucxZu4MDdteTeaDN88wdG0ABNAwqfzY3C/1OMA gjWxztYZiExQ1FvevR+WvV7n1GtxFA2UFO+aqfvGqFEvqCLJVNGNoHJosLqFKOrXAbPl sPdYGrf9MQcfDWXnz821txkgHF4sVzCs0wDcHDMnGF3zW5eVYmafqc2v0iaIs2SsWv2O lhU2FpFV9lqSnudLyTCo2PF3jyh4fYPn+DWB4Yk3PZH2oF+F2zIBUE5Tc3B2J/qd3H5U yvI0UaSms7c/BYPqOJlMjNxA6aFE9qp7Jesj/xDggsI1Rulgqcw8dG9njTldDVFc5ZuL wYEw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=R4Okywd6; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=gujoYzX8; spf=pass (google.com: domain of denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org designates 2001:67c:2050::465:201 as permitted sender) smtp.mailfrom=denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mailbox.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:subject:to:references:from:message-id:date:mime-version :in-reply-to:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=CCIwf8WIQU7mqtv5DH0oAO0u8LEuFiOHmAFA2ccO/sA=; b=de4CrI0G/T3qrir9DB3YTyTaYpWLQA6vxgpMtjfO1GdQ5YwEz+RyZxCSLfJwRAOhUR xLpb58eSldG7MxVnL/13yJZtGl64CmsxRzjBYtF96HQwz+wmul93XfncWyJwUybs0Us/ foRnICg6x+Q3N3wXICL9oKLqdGEDfnFVrGSwIUYON6QbS0z0Wa3X6THDCTZYpSbLObET lpzP+Nc3S7tkbjor/n5yD7FVI/YrxUqau4iqQl+co2fW2faYQDtPxstzTyrxVpNkW0QW +issZS66bEDcp8L6PMW9a15xhJpq42AGmbOA7n8Tx6gC01TmJl3ncxMHXRuyD8VENbXG XKgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:subject:to:references:from:message-id :date:mime-version:in-reply-to: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=CCIwf8WIQU7mqtv5DH0oAO0u8LEuFiOHmAFA2ccO/sA=; b=uYe/XC8ysm6+PPHxMrVZwLk4+KSPhjotAcdBdaCxdrgGmrUtHXkDqVRms6CAQ8sSjO IF2rNmxB+Q3JbIuUI/1vkbgOpj42KFG0grP7V9uuCqrX16o5P61jDm6x+EIK8xkpIkkv 9e2XMx14PoZja+LzFopW0FKqEyHPh3c4IZtwmY+bIyYhoPbbgjTR8rz0wVbTZuAd4ofb 1F7+wNWn0C+a3FpAH4+A+y6vqvaiXPHWl3dGJHT0tMjJqLAcRF4sEl47284K6NvpeCrV Y7P1Se3H/XEj7N/xtvDz9+qsvDW2HGzy9ysKhALB4wwDex1D7urWcj5zWVb+bQDZFHHp YMjg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM5335K7qBTErFfrnHgfO+FUvFQjKpkdWOkqKCLeIaNA2j+HoNP7wm YJ/GPqtsNqtWgdTWsuXpOCw= X-Google-Smtp-Source: ABdhPJxJF+3jPeQtsZnTFh5vzwOp6CSsKI3vBrnxznvWjYzxsb9xfxMmEdeG2hwLfpVAH0xtPPawqg== X-Received: by 2002:a17:90a:db97:: with SMTP id h23mr518474pjv.225.1598948948960; Tue, 01 Sep 2020 01:29:08 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a63:3205:: with SMTP id y5ls221429pgy.3.gmail; Tue, 01 Sep 2020 01:29:05 -0700 (PDT) X-Received: by 2002:aa7:80d3:: with SMTP id a19mr859046pfn.102.1598948945789; Tue, 01 Sep 2020 01:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598948945; cv=none; d=google.com; s=arc-20160816; b=n0ThMlUqiTZed4VJRPS5Y69Xa0FojouaQiMJe8+Tzonvq2gOxWXZPudVxQgzfrxTF0 wfvnlr8z6lkXKjLJIkI7W+XQRHu66xh2gE4jITrykgQCPYGnbh7IltA6xt5ssah9hnRH UPKNEn3n15FSOZCsnvyUT/2BTtGkIfDHOHkeRrh4tNV+N3Uj+sCq5HRlQvPRvm8mkLIH D+Ra5hPlgQuqJELYUo0S68SdkHMot2V7IPYv95Dy2H/kYVQOlEdIz8mRT9vjxCY7BnPl 4OVtPwtArNaZVwS1Mxc/h9o3P0+mGZoR7YbOqKzV/pJR4MgJ5nrWX89xBL7yxOmwvueO 8sLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:mime-version:date:message-id:from:references:to:subject :dkim-signature:dkim-signature; bh=X14JrlweE+KrsCAaTnbmK0fzdUtG6oEtGoTIZR0misY=; b=zUMD0qH+GDh7YGGorCoz9HSc2AERXZCEOMK1ZkgDk5PwPy6Yf3H2HHAyxMBw9W2fgd 3gE1cDXySfro8pna8pTZKvHWo8VknyElbrDYs980bWUnZq4xyTlEQYFXOqREvTqcxnWm wBi4AEi6qYmx+d7Ol2oShyAjDCdUSaOKUIF6ojGrAbKaGopjcd/PJQcUbjuHCyCoS2EO Lih7GInp3+Qbr8ntrzA4m0B+2CeynHGIvEdSw3gezkH5VI3JlvUwWchddkw+/cIbGMyb /RJopEH0MP9O4LzCgyqBQEczXC3Gj83TiNjIARQoDxHn1+VVQP131Ogi5EudmboK5p67 rcqQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=R4Okywd6; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=gujoYzX8; spf=pass (google.com: domain of denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org designates 2001:67c:2050::465:201 as permitted sender) smtp.mailfrom=denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mailbox.org Original-Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org. [2001:67c:2050::465:201]) by gmr-mx.google.com with ESMTPS id a24si27157pfk.6.2020.09.01.01.29.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 01:29:05 -0700 (PDT) Received-SPF: pass (google.com: domain of denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org designates 2001:67c:2050::465:201 as permitted sender) client-ip=2001:67c:2050::465:201; Original-Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4BggG73JPWzQlWV for ; Tue, 1 Sep 2020 10:29:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Original-Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id PDNDqNgUb3Ju for ; Tue, 1 Sep 2020 10:28:59 +0200 (CEST) In-Reply-To: <4e07ae0a-dcb1-4f89-8b91-ba787b7bea1cn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> X-Rspamd-Score: -3.74 / 15.00 / 15.00 X-Rspamd-Queue-Id: 2061F17A4 X-Rspamd-UID: 59a24a X-Original-Sender: denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=R4Okywd6; dkim=pass header.i=@mailbox.org header.s=mail20150812 header.b=gujoYzX8; spf=pass (google.com: domain of denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org designates 2001:67c:2050::465:201 as permitted sender) smtp.mailfrom=denis.maier.lists-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=mailbox.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.io gmane.text.pandoc:26028 Archived-At: This is a multi-part message in MIME format. --------------2E6CBBB25B2FA63E7625E6CF Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable You mean like removing the sub section header? Or the whole subsection=20 until the start of the next section? Both should be possible with a lua filter.=C2=A0 The first is trivial, the= =20 second more complex (at least for me ;-). But I doubt it wouldn't be=20 possible. The tricky part is possibly that pandoc's AST does not reveal the=20 hierarchy here: [Header 1 ("header-1",[],[]) [Str "Header",Space,Str "1"] ,Para [Str "Text"] ,Header 2 ("header-2",[],[]) [Str "Header",Space,Str "2"] ,Para [Str "Text"] ,Header 2 ("header-2-1",[],[]) [Str "Header",Space,Str "2"] ,Para [Str "Text"] ,Header 1 ("header-1-1",[],[]) [Str "Header",Space,Str "1"] ,Para [Str "Text"]] So, I imagine you have to walk over the AST and when you encounter a=20 "Header 2" element, you delete this and everything else until you find=20 the next "Head 1" element. You could also just include wrap the relevant parts in divs and then=20 remove them from the output. That's easier, but not so elegant. Am 01.09.2020 um 10:01 schrieb Henrik Klang: > > I have markdown source and want to generate PDF using Pandoc. > > I want to remove sub sections from a specific level, in the generated=20 > document. E.g. filter them from the source markdown. > > Would this be possible with Lua or would it be better to do=20 > prefiltering using some other tools? > > --=20 > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send=20 > an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org=20 > . > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/4e07ae0a-dcb1-4f89-8b91-= ba787b7bea1cn%40googlegroups.com=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 view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/92ac8df6-b88a-b047-b9f0-1fe62873b710%40mailbox.org. --------------2E6CBBB25B2FA63E7625E6CF Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable You mean like removing the sub section header? Or the whole subsection until the start of the next section?
Both should be possible with a lua filter.=C2=A0 The first is trivial, the second more complex (at least for me ;-). But I doubt it wouldn't be possible.
The tricky part is possibly that pandoc's AST does not reveal the hierarchy here:

[Header 1 ("header-1",[],[]) [Str "Header",Space,Str "1"]
,Para [Str "Text"]
,Header 2 ("header-2",[],[]) [Str "Header",Space,Str "2"]
,Para [Str "Text"]
,Header 2 ("header-2-1",[],[]) [Str "Header",Space,Str "2"]
,Para [Str "Text"]
,Header 1 ("header-1-1",[],[]) [Str "Header",Space,Str "1"]
,Para [Str "Text"]]

So, I imagine you have to walk over the AST and when you encounter a "Header 2" element, you delete this and everything else until you find the next "Head 1" element.

You could also just include wrap the relevant parts in divs and then remove them from the output. That's easier, but not so elegant.


Am 01.09.2020 um 10:01 schrieb Henrik Klang:

I have markdown source and want to generate PDF using Pandoc.

I want to remove sub sections from a specific level, in the generated document. E.g. filter them from the source markdown.

Would this be possible with Lua or would it be better to do prefiltering using some other tools?

--
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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-d= iscuss/4e07ae0a-dcb1-4f89-8b91-ba787b7bea1cn%40googlegroups.com.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid= /pandoc-discuss/92ac8df6-b88a-b047-b9f0-1fe62873b710%40mailbox.org.
--------------2E6CBBB25B2FA63E7625E6CF--