From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27469 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Peter Matulis Newsgroups: gmane.text.pandoc Subject: Re: Lua filter to convert Markdown comment Date: Thu, 14 Jan 2021 15:57:36 -0500 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000014e61805b8e282c0" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31453"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To: John MacFarlane Original-X-From: pandoc-discuss+bncBCUL3CX4YUARBTPAQKAAMGQEM4NRSXQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 14 21:57:54 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-lf1-f57.google.com ([209.85.167.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l09gl-00081W-EH for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 14 Jan 2021 21:57:51 +0100 Original-Received: by mail-lf1-f57.google.com with SMTP id j15sf2346497lfe.2 for ; Thu, 14 Jan 2021 12:57:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610657871; cv=pass; d=google.com; s=arc-20160816; b=yPpmmDRPRFVBWUeGtTW2SnBXfkYAAoX3FX6I5eqQcAuz3eWhRQRLLlw/+MhvxRkQ/X xhQZ/nZC1hhnxgfJJn3Ay9jYfSQ2QO/Os2Bma3/+OpQAiRDGphr04728F2LS8r//JuYu sKRp9NWo2s3VWlnTs+4IdGCN9IfoFUvmCVTU2ydZX31UGkf+b1msqLIBgDb5J+WMq47v UdHhugvGzgNgkYcZGZSBvRXadRQ7PpgMjPcVkMoZLEVXwGb3/OYAm2e0Pgt28303Sj0F nK1vjiRVuCVnWhQE8PkOJ89alBPIAizhUGU58ze0abfgyKcG7sRvTJ1b0ENRtcn2Zi5b VuuQ== 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:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=FRs8wo4EsBXSdoivDpGHCLA/QerqTDBp21ZlrWD29Tg=; b=Pqr8EhaEvZMUz2k3iSUIugFiYq3+QN4LzdBjmRWi0rWGvb6yuNHbkurWP2/femF5HK tGsZo/o/uB09j5cobUQL7iPnCPo61O4WQ2W6xSc3OHjmN6i3k1kvLrlXDFt0SBIaAcPD 5ngC4JvzgkVIf6h+v/A71b+mSAyKH7Ajb6pw81a0SuQ3nuV5TC/KmemN/BxvKYupdmwE FvHV4kcKA8KW6s/8+mF2hIccskoap1gI+DjFOFfPKZUZcpKnp+gDSrdReXRZP5ihSrQh g+KF57yPLD186k9ay3cVNLa0qyIQ97KObsDpa2Xx4YxbdImdgNKbzP+hSwKaSKdNOKlt aA/A== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V60xMqtW; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:cc: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=FRs8wo4EsBXSdoivDpGHCLA/QerqTDBp21ZlrWD29Tg=; b=po/IGbxjnk8BROUwB89Kyw6BvrvTr9b6UqxTuavTlu2QeqwEbOCI2G1Kr4Wn65SNjG Glo51unu2+A7WIejKLhJGq3Qre8LABx6d40QIDuTqX+4zAq3aXXmO8KwyrYWG3NHrwzv smGpKWa8mC9GzJS4ccszIysRzREQ49XvJBMFiCRaZjANZG6XT3peBUS+S9RsTvkFGntj M+2kAOSyUOLdMDYmRTEH9FF9qt81Hvu8vLtWNxN3R8ddlXdPxUqAJ1yzI2joNvA18bYy GEXjIAcpRDW/zfVRkuyQo7iqx+roh5yOZIxMCZt4SuhINr8kiSdxenNV+TUIzm8/uj9L vsBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc: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=FRs8wo4EsBXSdoivDpGHCLA/QerqTDBp21ZlrWD29Tg=; b=EA2Ycj6xrv7OqpVCbn/57CzWnjwDBSzPltFHcbDnvT23FSStN3ldPLLFZb5WKusT5T JnKSzMTYL1Kx9JXLipmt3+eBlvITunUN9TYvg9ks+DZKLwExzsQnPNCbiZbB5nejAopa 0CK9IC4QKnN91U581JRPuC+7Dptotv9xYweBXuwgQCCsmNvZV+ite9Xl4hKjqQ24DR6T 0eZ/JZmnJq9atw6JCxcWPrUrKCQxKIjtMtZ/xJ1hIF7dWy2RLArG1nC791wK3YC5+JA6 fuAbALAQIGlEsW/lwJGtwzWMDjCi5Zhf/mMzLDWYrRY3JsKNdQ55gbvK0KIIQnsI7gjM NeZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:cc: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=FRs8wo4EsBXSdoivDpGHCLA/QerqTDBp21ZlrWD29Tg=; b=MT7/A/vL5bzp69WuDYvd28vBufZ0nf7pRn6bxBHmWjcoqyjeG6lZAbQRHeUq2gdSTo IH4ksMKPPTKQ+Fb57cOp9BA4nrLep2Op1NAOD7/ojOlNxOBmQgPVLM9aRevCQsvTJo7t z3oSaGkG5jlW6GrA8JhZXTsVEtPjRrkKfAhlPPhfJ8hknkGj3/q47eM6EnMuR/oyefi6 I2ibaqEZaKaFkC2/xglTxYsAzHaPYuKmZMzzDXrVlli8qD5v8FL5GjB6HRTejuu+U2uJ dzp/PHhrOpEOGLkxNabrKVJVKeSVFxkXCA6iBMDyi6+oz+1KCYWdIOXryxKIbCHCVcRC BzpQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM531iopje+XpxRRJYIHkWrUOmSNgdM0QR7gyZem/EaxLNZ2sy8SIw +GntV7N7+TitT8J1PDnYaxk= X-Google-Smtp-Source: ABdhPJw60GKVvE9/PBHXrmal7bNCo7vS/dPK/YY+d88hglt9zvd2/KPRA2refH+WEpU6Im/+vwDasw== X-Received: by 2002:a2e:8156:: with SMTP id t22mr3733083ljg.263.1610657870949; Thu, 14 Jan 2021 12:57:50 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a19:6145:: with SMTP id m5ls968110lfk.2.gmail; Thu, 14 Jan 2021 12:57:48 -0800 (PST) X-Received: by 2002:a19:c70b:: with SMTP id x11mr4105833lff.258.1610657868320; Thu, 14 Jan 2021 12:57:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610657868; cv=none; d=google.com; s=arc-20160816; b=rYjFftPgjBl5eX507vCpOzHfXa4OTZ8EzpOD2xqa7AvWmElYHHtQgU6ZZP0JuZJaTu PIGhIeZiYoM/2W28zyFfUOfikvSdZrII9D5vOp9K0P0W8cXXkpYS3p4STUmqhxtXn+HA WAFwzvLKovqY3UU9NAWCuCzGQEL/Oh6Zxx9SVNKYdoQRlU9VTxw2gH5greryzJwsvASM kk6s96f+TzaaktIW/Ai8Zu0NlO8U4BUUSzOa3w6Dx7CE8DmCKBiZaEG9V5FGel5rC/Gx wGPYhzJY5ly48tgcoQKu85T/hwwke0/o+qWGlsoMp9JI0d1h+5ibm/f0VFA35WcFe9B1 B0WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=I8yZg1Jam6NtBdrQwsphb8M1AAJfqRGrzGSQFaWtvkc=; b=mfkN0Kr5OYDicARWsBWM5hvbdAxIS+dJEKD1BDeCTWH06+2SNUdHdmqrdeDRqfdpVy ViBYVcswi3vPt0Emh67+L+wMNqkHRO5v9G60K4HtYnLFkBIEJbfS9UEwPdLwDsDCuMwz Oma7btl5l1Yr/EV0BCXQAtV6eKeLPAHWrOTY3eubbz++VKCWWVZ5IGlOHQnQKkfFC4Yh SeZDG82UEb7+ziXrbmJdyfoFbj+ulGB4vrML5gd8WkZVupXudUZLIH4ZepxXw0kfx0dn XT0hSJadFQpbdYmkSsUkCDd96GR6AO0FsxyOwCRb6sxUXisgR3lITxkZa4Uj33ELsmnh TINA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V60xMqtW; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com. [2a00:1450:4864:20::62a]) by gmr-mx.google.com with ESMTPS id 207si232413lfm.0.2021.01.14.12.57.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jan 2021 12:57:48 -0800 (PST) Received-SPF: pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) client-ip=2a00:1450:4864:20::62a; Original-Received: by mail-ej1-x62a.google.com with SMTP id hs11so7910306ejc.1 for ; Thu, 14 Jan 2021 12:57:48 -0800 (PST) X-Received: by 2002:a17:906:a43:: with SMTP id x3mr6411194ejf.277.1610657868079; Thu, 14 Jan 2021 12:57:48 -0800 (PST) In-Reply-To: X-Original-Sender: pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V60xMqtW; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::62a as permitted sender) smtp.mailfrom=pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:27469 Archived-At: --00000000000014e61805b8e282c0 Content-Type: text/plain; charset="UTF-8" Gratitude. This got me going. On Thu, 14 Jan 2021 at 13:52, John MacFarlane wrote: > > What you want to do is match on a RawBlock element. > Something like > > function RawBlock(el) > if el.text:match(" > > > > I simply want to convert this into an actual (second-level) MD header: > > > > ## blah > > > > From what I've read, I would ideally specify an "element" that will be > > acted upon, but what is a comment considered? Anyway, I think I can > specify > > `Pandoc` to mean "check the entire document", and that's what I've done > > here (I will eventually be iterating through multiple MD files so I > should > > really not be doing it like this; please advise!): > > > > function Pandoc (value) > > comment = "" > > comment = comment:gsub("%<%!%-%- blah %-%-%>", "## blah") > > return value > > end > > > > I've run the main logic through Lua on the terminal and it works: > > > > $ lua > > Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio > >> comment = "" > >> comment = comment:gsub("%<%!%-%- blah %-%-%>", "## blah") > >> print (comment) > > ## blah > > > > But I'm failing to integrate it with Pandoc (no change is registered in > > file.html). It's probably due to my misunderstanding of functions (not a > > programmer!). > > > > TIA. > > > > /pm > > > > -- > > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/CAMxYqzEvRHcFQ1BYsFODC-Bd36%3DLfO-UKcVYPNzR8i8rDZorXw%40mail.gmail.com > . > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAMxYqzEn22Y4goKKW-D3Coqi5UTNR%2B6AgfcJAkJZPy8qtXjvjQ%40mail.gmail.com. --00000000000014e61805b8e282c0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Gratitude. This got me going.

On Thu, 14 Jan 2021 at 13:52= , John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org<= /a>> wrote:
<= br> What you want to do is match on a RawBlock element.
Something like

function RawBlock(el)
=C2=A0 if el.text:match("<!--") then
=C2=A0 =C2=A0 content =3D -- fill this in based on el.text
=C2=A0 =C2=A0 return pandoc.Header(2, content)
=C2=A0 end
end


Peter Matulis <
p= matulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hi. I'm new to Pandoc & Lua but my present issue is straightfo= rward. I am
> converting a Markdown file to HTML with pandoc like this:
>
> pandoc -L filter.lua -f gfm -t html -o file.html file.md
>
> Where file.md contains a line with this MD comment (the MD file was > obtained by converting from RST where I had to seed that file with an = RST
> comment to use as a placeholder for what I'm doing here):
>
> <!-- blah -->
>
> I simply want to convert this into an actual (second-level) MD header:=
>
> ## blah
>
> From what I've read, I would ideally specify an "element"= ; that will be
> acted upon, but what is a comment considered? Anyway, I think I can sp= ecify
> `Pandoc` to mean "check the entire document", and that's= what I've done
> here (I will eventually be iterating through multiple MD files so I sh= ould
> really not be doing it like this; please advise!):
>
> function Pandoc (value)
>=C2=A0 =C2=A0comment =3D "<!-- blah -->"
>=C2=A0 =C2=A0comment =3D comment:gsub("%<%!%-%- blah %-%-%>&= quot;, "## blah")
>=C2=A0 =C2=A0return value
> end
>
> I've run the main logic through Lua on the terminal and it works:<= br> >
> $ lua
> Lua 5.3.3=C2=A0 Copyright (C) 1994-2016 Lua.org, PUC-Rio
>> comment =3D "<!-- blah -->"
>> comment =3D comment:gsub("%<%!%-%- blah %-%-%>", &= quot;## blah")
>> print (comment)
> ## blah
>
> But I'm failing to integrate it with Pandoc (no change is register= ed in
> file.html). It's probably due to my misunderstanding of functions = (not a
> programmer!).
>
> TIA.
>
> /pm
>
> --
> You received this message because you are subscribed to the Google Gro= ups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send= an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> To view this discussion on the web visit https://gr= oups.google.com/d/msgid/pandoc-discuss/CAMxYqzEvRHcFQ1BYsFODC-Bd36%3DLfO-UK= cVYPNzR8i8rDZorXw%40mail.gmail.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://group= s.google.com/d/msgid/pandoc-discuss/CAMxYqzEn22Y4goKKW-D3Coqi5UTNR%2B6AgfcJ= AkJZPy8qtXjvjQ%40mail.gmail.com.
--00000000000014e61805b8e282c0--