From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/27464 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Peter Matulis Newsgroups: gmane.text.pandoc Subject: Lua filter to convert Markdown comment Date: Thu, 14 Jan 2021 13:08:20 -0500 Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000aed4c005b8e02452" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25122"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBCUL3CX4YUARBIERQKAAMGQEGD7IACY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Jan 14 19:08:34 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-wr1-f58.google.com ([209.85.221.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l072w-0006CH-6B for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 14 Jan 2021 19:08:34 +0100 Original-Received: by mail-wr1-f58.google.com with SMTP id o12sf2921215wrq.13 for ; Thu, 14 Jan 2021 10:08:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610647713; cv=pass; d=google.com; s=arc-20160816; b=gRogWHFPp3VwxRfxPLV+AEPK29YEUBPCwV/l2b4j/3VC14rSbguFiMDje8RCLJhrU1 Pw11vf5wcZRP3piYhe9Vty6yRfzUZkLYxOXHSdaV34j3hmdemnSqMeGiXi5NH6/ueDYQ JBv4j2z1oQc0inN/15O3Vxjj7gry4ubGpTjhZGN25rqX38RnAlGacuf9xLDDVDVZc0YP okaDepX5V86fF3iHT0kGEYjPjudmqcqbflLhdOoFqALFs44f1cpfj8aSMRghuyuAEV0E YL767CCqJrcY/Bcs1pMOWkKOh1IE0rZO5nN1mgsEl9ouc/ltN2mkcoZfywxl8m0B4LJw Rz+g== 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:to:subject:message-id:date :from:mime-version:sender:dkim-signature:dkim-signature; bh=vqF6B9YQPtBIvRU/PGv5SsV/L62m/iWNNbBywrP9xiE=; b=hKwo76+YpSUfJYh9t168zvjHyXTvT9JDC4LXgydcVaqIi+ep5Y07A1mz3e18MEsKSK zktI9cjkJOk/1uZvJSEWOqgf7mv7qrv4jqwUsHvW4qzUfJpGw8GD3YHMmBLoMnwKRscu zGBcLHGkUHT33lnmY17G4hrD9ngfuzhQkciNSVbB2+kineXdMWo5HdhA7579YnUv27i8 NN/sXDZF2s3F6b4iv50EwVcJ+WbW/BH2wpS05xL2Oe8TJyGxgJysCcXsj4iuvF1RPviE ZBeXbixWMU2VyF7PAL5pA96ry/xn3++79PAnRgbNmKOdNkLANxeD7b6WlTkXMYrw4XO8 B2Tg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hIaXi1ph; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::533 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:from:date:message-id:subject: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=vqF6B9YQPtBIvRU/PGv5SsV/L62m/iWNNbBywrP9xiE=; b=ZKnFBbm0MaWswxbfe+gi/ogQNKTQY8Lo9HQZZW9b6XPdq5q8oMXDbSxUjGqEypUbiF GtTVTkHfgQ9869i67DNb4jrcj0RtnO0cpujB5QoUDGzLwCHpZwy/+qwl6CWty3gPmiNa cdZ7j5xTxMuaWk0yQTnbtdr48xRGh64yN8fGx8nJIm8kbZGr8f9l4x4LwiUEbrAvtq21 99HJkoqQ1S+i0FOU4LhQixOm6qNjiM3utDriHvYyaXx6E+HQjmWugcAHR4JDj710VsPe E9/EaRygPce7I+8L5BEU4S21PMqbbikQRt+6rOsIpU47QPtIIUvPCfu0NyZOQAdZJaV0 fxYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject: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=vqF6B9YQPtBIvRU/PGv5SsV/L62m/iWNNbBywrP9xiE=; b=g+MDqCDc6TV0wagx2xZBQyNKnSt85+xFr61h4px6LvctU/Jds8FSs+f36bvG16qZqR rYXqXVyEsbMq9FOzGsIq/EPuE8NPSqD6FIAytAsrrfZ+Gmke6lXC6ZL4VU1ENycQxMVT sl1wA4di+V6bh+3JK2YHTa6T9J5cZ0qTfy+x6PC3D77mn8oN3fPq1QTmtGKCFrYCbKtL ZGnOgLThquWAg2+ExxTCcCUvwmOYXvfXSHnz+lO6xOAUFAcZmJzqL4iVPw2+Fxtn2qrv 5nhgWcYDcWkaJ9urbTX3UHUs+vUTrUXT9zsdn7dEHGM4E5QtubCh8mwrWIivfnGg6Dn9 lEow== 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:from:date:message-id:subject :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=vqF6B9YQPtBIvRU/PGv5SsV/L62m/iWNNbBywrP9xiE=; b=PD4ZmhIfSJ7L03GxXBRR9f0uPu+BVOZh7umwKDWj20+A84no5DTws9bkT0+xPl1uFH R0bJWMH4LBV6iLZw65INtlXOuIm+6JuXqOqLm9YbjfaV3OXa0wXq7EpOqhYcBVjlf+xx acf6wMnlSiZuzY7Q+pPN0pS9Oj5iaBiuUpmimTRuhz2aB9MU+4hRZQRWSIv1Sc8D1LLx v/4KVU0xKByVp/BmZY4h+1aH0AxiKEZkLuIDu1L/rvezcedka0nnE5cw4viBHOjCKAMn X+Izy4crDi8gOMWH6JF/u8kHKVepAEOHyffy0dMJS7ymLx8W2SRfGiQb1O3JjoWLw2nF DutQ== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532P5xEiJhu5dt8e45zcntb7T6Zmf5wBDndc+lBNzU5ek/GrErio 4HTacx7IaZccNrL6Bhrxa9s= X-Google-Smtp-Source: ABdhPJxfczDXra9F+fs0A4TkeYGsZP7IkG+qDaA8K7TnfeRGu7a/CWIXpIMbIYlQo6W6fHlzgKPsXA== X-Received: by 2002:adf:c6c4:: with SMTP id c4mr9427911wrh.348.1610647713869; Thu, 14 Jan 2021 10:08:33 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a1c:1fc7:: with SMTP id f190ls3107047wmf.1.gmail; Thu, 14 Jan 2021 10:08:31 -0800 (PST) X-Received: by 2002:a1c:a957:: with SMTP id s84mr5050440wme.166.1610647711684; Thu, 14 Jan 2021 10:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610647711; cv=none; d=google.com; s=arc-20160816; b=qEp17lE8dEd0yFmkpcPm0bfguEC82RgwPLcV9gFHtxXNRWm+oCGmYRdlQu/0PofFng tJFVdjf8dARX4/ckLEox3eAQhw9NtrZgiU0CR585L64pmhjp9Oq7HcIbaNzNFRkcanqm uq5JYtzRzCC2m+WUfNt8YBuNm9af/MGmuFFQ29oIBJPnYJ+Ox0hYmF6xp7CrzjoBj2Yv Npwf9elowkYuVAXQUbTeOTKwAVQAYxEMY3dwtrsCsQQHVgzcZf7fSG86QbcEe+9g4PJw V9MbcYWTl9ixZePIXvzFq4ixCZlN58+z14HGmxelhVAQgNdrDZ929TO5Qc01FFRZIfEP sFOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=ytbJy4By2fiEStMGddOSXVfPTPGexxjxYyyVRm44SNY=; b=vxxOwe1S7L99yyaWD1SyUgn57rQlbofPYURk924KDOR9IT5oMHl4D2GH+9Q3YdZAoM EjHxtVhme/e5ss+jM1a4Qt14YzuKTrh56D0l7Fp+AFeKCjv6n4iFjpMJkr1iAsW36+we sivhEIbNwkK7/4qGWNC5uLznZj9GLuUy8rMW/4YxuPJ77ZnmOI3wLWltL0dZGZrzNhtO G+JOFdOH1AXAqvgAAl1fqfn65KvPwOiweIfhJ4E9ngF/Hrxnl/iITxZqgnZKsgd542l9 ngF71zurNzE2lmhjdEoklprlccLtXYjSkPex1SZ2/iDmXlmr6qAaMsrFy1764iHxnRRW FeLQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hIaXi1ph; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::533 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-ed1-x533.google.com (mail-ed1-x533.google.com. [2a00:1450:4864:20::533]) by gmr-mx.google.com with ESMTPS id d17si453109wma.4.2021.01.14.10.08.31 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jan 2021 10:08:31 -0800 (PST) Received-SPF: pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::533 as permitted sender) client-ip=2a00:1450:4864:20::533; Original-Received: by mail-ed1-x533.google.com with SMTP id g24so6684994edw.9 for ; Thu, 14 Jan 2021 10:08:31 -0800 (PST) X-Received: by 2002:a05:6402:1386:: with SMTP id b6mr6687244edv.42.1610647711174; Thu, 14 Jan 2021 10:08:31 -0800 (PST) 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=hIaXi1ph; spf=pass (google.com: domain of pmatulis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2a00:1450:4864:20::533 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:27464 Archived-At: --000000000000aed4c005b8e02452 Content-Type: text/plain; charset="UTF-8" Hi. I'm new to Pandoc & Lua but my present issue is straightforward. 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): 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. --000000000000aed4c005b8e02452 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi. I'm new to Pandoc & Lu= a but my present issue is straightforward. I am converting a Markdown file = to HTML with pandoc like this:

pan= doc -L filter.lua -f gfm -t html -o file.html file.md

Where=C2=A0file= .md=C2=A0contains a line with thi= s MD comment (the MD file was obtained by converting from RST where I had t= o seed that file with an RST comment to use as a placeholder for what I'= ;m doing here):

<!-- blah --><= /font>

I simply want to convert t= his 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 specif= y `Pandoc` to mean "check the entire document", and that's wh= at I've done here (I will eventually be iterating through multiple MD f= iles so I should really not be doing it like this; please advise!):<= br>
function Pandoc (value)
=C2=A0 comment = =3D "<!-- blah -->"
=C2=A0 comment =3D comment:gsub(&quo= t;%<%!%-%- blah %-%-%>", "## blah")
=C2=A0 return v= alue
end


I've run t= he main logic through Lua on the terminal and it works:

$ lua
Lua 5.3.3 =C2=A0Copyright (C) 1994-2016 Lua.or= g, PUC-Rio
> comment =3D "<!-- blah -->"
> comm= ent =3D comment:gsub("%<%!%-%- blah %-%-%>", "## blah&= quot;)
> print (comment)
## blah


But I'm failing to integrate it with Pandoc (no change = is registered in=C2=A0file.html). It's probably due to my misunderstandi= ng of functions (not a programmer!).

TIA.=
=
/pm

--
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/CAMxYqzEvRHcFQ1BYsFODC-Bd36%3DLfO-UKcVY= PNzR8i8rDZorXw%40mail.gmail.com.
--000000000000aed4c005b8e02452--