From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32089 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: more fun with pandoc lua Date: Wed, 25 Jan 2023 12:50:05 +0100 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002d983005f3153c9c" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37966"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRB5NOYSPAMGQEDGGE2AA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Jan 25 12:50:17 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-qv1-f55.google.com ([209.85.219.55]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKeID-0009gV-GI for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 25 Jan 2023 12:50:17 +0100 Original-Received: by mail-qv1-f55.google.com with SMTP id px22-20020a056214051600b00537657b0449sf2865459qvb.23 for ; Wed, 25 Jan 2023 03:50:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1674647416; cv=pass; d=google.com; s=arc-20160816; b=INyfhWkmt3wKgRuoqwkKz4LcvISH7zf/55iRwWIWmV5o2atBbu1xg8T2Bk/VnRDQe6 jz/e4aFwMi7s4K9T2divtzubedQ8+lyfXlF0W8F/m8uj+0klW89O6sTs0Hmh/jSvf0ML E1w9pxkaAv+1TALkk5LDRcXVkFEhi11V+oacJJDwDdozaTvePtJdwzHf+pOXSvtkbsbX krLj1qUlfuEgQCgx/Um74TwtEPu4XA54dL8LVoShq/SpviZmso3PLTSS3//2A5G+ZWLs fc41wZRZB72m9Zoc2IIU0kmcVo4A4m99Qhw0P7IMTXX/JZweqeM/Iv9R858JhwU3J87R O2Dg== 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:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=W2ubOj6m4TjWzQ8S7xkM6fgc8hrFX7hq4QCLnj6SOq4=; b=OFJVwH7cLGNYPktamFyUEhCNeR1JVpp1SudAYAx/6ENGtvBanDrGbODdYRz7lEyWhf lAu0OjYf/PUr3E9Vc87mQUmwkhkE4om2mJhOiK4Wg2FvUpvxpqCAgUPh2XtWsrmlaKV0 QqPtaqol7cT3jwyOR5dYSY/dH3pbzKN7XzjLV3oSm9mbU9cTFjtQW7oLDvBp+/HteDbI c54/tMvhx+cM9OdY6dVQqvDijRLjGSQbfU5ylBX1/6N+N4zn1jsyeriOOhW3ct7T4k5k kat567CoTthZHCpQTdPT8Nqb04L4t+pyBcmYoZDjPafecxkHMg6o7FyzlPgW8E8BOQjn kjOw== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iJiyoV+h; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1130 as permitted sender) smtp.mailfrom=melroch-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=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:sender :from:to:cc:subject:date:message-id:reply-to; bh=W2ubOj6m4TjWzQ8S7xkM6fgc8hrFX7hq4QCLnj6SOq4=; b=s7O59bh8vgdzIwMLpp54oXY+Ua+ZOjd+8AK25kWBlrwTB9bO4Q+ub7RVQHEvobYbyt nIW4XYqKXzHcNB3eCTywuceNrAUWT9mQTYIHVkotPjtkBtr/0Q8YiRjdguMIKSQZLlt6 MmNCBPyUGxh60Nd47Hr0soaAVg9+Ifbty/BYGdB1uDNujXx8zU4YHZZ+7wY6/33MULGn ouRnXsPYxp5y8NZkSsYN8Ft9hi990cRlEP/1a2/lH9YEw2V7KZJ2jA47/JYyPfGI4ytg 6J3Dj9gXaqCWNfGwEIHkxezvg+DDzafpLunCwxOZkh17dF8ADqXWmxBtPCYKUs4bRkpt oA9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=W2ubOj6m4TjWzQ8S7xkM6fgc8hrFX7hq4QCLnj6SOq4=; b=Fl9GuuYFnBBsRWsNpa+0fzMitWxOPyJNOb0JTnokWVmnD04pQyTeH1F2qxaKjUnWUS zvarnLZXEFLUjokWlN+GaFDyXQooIVpec4or73VXSbvzYZ344CpQBrxOE1y2u3LBKH4d CzMiuisWkUqrGjQMCA3bOKxDAfsKDq3rnWNN2Ctda3WQKocZN2qY2fPdhj1ZhI59JCO3 OVt7idqyc4a0yCqLQr9u48FprtcYYskMO5j1/NhqQO0d7D2aTtZJSb2nUF/0IcFHOS+M gMCEklqQR597n6/EXzjXUPT5b49NjbdwhYQN3OzZqdUCoSwdNMQ/ZrmujoqJY+A0WNV2 aJDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=W2ubOj6m4TjWzQ8S7xkM6fgc8hrFX7hq4QCLnj6SOq4=; b=4UvvA4IflzMCNKLNhhxooX24oOomYG0UmkTgcUx4QIViGsx/Ow1xRQETlMOdjmG2J/ 8CbxehhMgBqmsMiLGdYfU19Rcb6ky9NzEAk5p1oYaC+FwXWzUPi0Oz6aCQERWqskTj+F eHmIOKUOcveRMaSC1MfvWfQJKR+7T//VwOR9gT+cAR489X7fuLoDCrZJfgDTuvBtgHvK ow5f7dxBZKLfxRHzYQT19916RFxwCOAnqnz6CjCZXvAQhodoV8mpEfcQJEgasbtt++FR n6crIzsu+DhxFqtGBeWRCbdKV1XdLqCFGaB75KxLv/1jbo Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AFqh2kpm2j1ho2TKXVfSKc+jr0fVLfQoSiMJmiJSM6n2vJbDittsjq6v NgQLmz7EiGemoUQAF9iQEoA= X-Google-Smtp-Source: AMrXdXty3WEie72WRnG4HW42R5XPW8Cf8Xw8Ld6ICoB8lWRcvCdsglpe/rdILiD8+fkTlNB/kZCqrg== X-Received: by 2002:ac8:6892:0:b0:3b6:33ed:624d with SMTP id m18-20020ac86892000000b003b633ed624dmr1368935qtq.554.1674647416430; Wed, 25 Jan 2023 03:50:16 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:ac8:4991:0:b0:3a9:8ab2:1bab with SMTP id f17-20020ac84991000000b003a98ab21babls14390048qtq.5.-pod-prod-gmail; Wed, 25 Jan 2023 03:50:13 -0800 (PST) X-Received: by 2002:ac8:7f55:0:b0:3a5:fd39:ff90 with SMTP id g21-20020ac87f55000000b003a5fd39ff90mr3893045qtk.3.1674647413524; Wed, 25 Jan 2023 03:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674647413; cv=none; d=google.com; s=arc-20160816; b=oDE6ONNwDTgW+SCksnuKBEenYjWtEn6B+3nXGACh9CIH7x/mVoJv/Qqym/zgUrp5h5 kZpra7yBcoqnfArg5txCTqQPHSh8d6w+8OhRE7cCCGwoCJfmc6O8osSMowxIaunFCWw4 DWG7YAWK8Tp4DccGH/c1EGvg3nHkQGBlV9Vs8PlBLJ/qpPWTctEeehEzEccX6hkPRLc+ 7gzA+PQTmphZaADyqm2+SJwf3Dkp+PNeMULr9FyKKHbrh1c8zMjmxTdk0M7FhgVeLu1q nAhqMw9CTfOyWbr+EkpERtp5R7Wg4U2OE5U0u8ca1VF9yNyDMSra1GrAimj8vc/wT9B8 Uc2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+V5XhK6oyvc4spXFhQlpZzlbHf0n9nLLQKTbZTZFhgE=; b=XfgUFKjvMNixTlkcmp+DcOxJQanFxzetiHBJ7i84lZ95k34wSl9VAA/PBqpVGpJ/th 9NfBLBXEM9/4IfxKMZhO32Gb6DaFmJQjObjAZ1JfceZdEzMkKPHF9jIQyraKVMZXf+JC enea7aENF2oqEgeR+znRgt3JMDSHf/wO7+UD6GRA/+ANZeWUpOF0X0nZNTbks5DFlK3Z iy8VCr5sknpyra4RAsVD8zCDQb9APXAVQeipZLJz2JtsMJsRH+GhjwV70PRDYJAco8wz 3/AHE6nXGfKJ9+/YaaC/0XToQfi4NgS7QahlTCzW4HW7D8I2GoyTyzS3kaI6pylcbX5Z 9dtg== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iJiyoV+h; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1130 as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com. [2607:f8b0:4864:20::1130]) by gmr-mx.google.com with ESMTPS id f8-20020a05622a104800b003b63b24c87dsi554433qte.0.2023.01.25.03.50.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Jan 2023 03:50:13 -0800 (PST) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1130 as permitted sender) client-ip=2607:f8b0:4864:20::1130; Original-Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-4ff1fa82bbbso213010137b3.10 for ; Wed, 25 Jan 2023 03:50:13 -0800 (PST) X-Received: by 2002:a0d:ffc3:0:b0:501:7b63:f00f with SMTP id p186-20020a0dffc3000000b005017b63f00fmr2170638ywf.150.1674647413035; Wed, 25 Jan 2023 03:50:13 -0800 (PST) In-Reply-To: X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iJiyoV+h; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::1130 as permitted sender) smtp.mailfrom=melroch-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:32089 Archived-At: --0000000000002d983005f3153c9c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I wonder if my filters/custom writers for converting plain output into "email" =E2=80=94 something in between fully plain and fully markdown, conf= igurable in various ways (through metadata) =E2=80=94 and to Perl POD could profit f= rom being rewritten as standalone scripts to be used with pandoc-lua. Both basically replace some elements in the AST with "plain" raw inline or block elements containing markup for the actual target format around the content of the original element. As Lua scripts they could take configuaration on the command line, using a pure Lua command line argument processor like Penlight's lapp rather than having to programmatically convert Pandoc metadata into a plain data structure with string/number leaves. Den l=C3=B6r 21 jan. 2023 20:06John MacFarlane skr= ev: > -- This Lua script, when run using `pandoc lua`, will create an HTML > -- file rosetta.html that compares how the same content is represented > -- in all the text markup languages pandoc supports: > > local inp =3D [[ > # Heading > > ## level 2 > > ### level 3 > > #### level 4 with attributes {.blue #foobar} > > - Unordered > - list > > 1. ordered > 2. list > > a) Lettered list > > with continuation paragraph > > > Block quote > > ``` {.lua} > local formats =3D pandoc.writers > for format,_ in formats do > print(format) > end > ``` > > *emphasized text **with strong emphasis*** > > `verbatim text` and a [link with `verbatim`](http://example.com) > ]] > local doc =3D pandoc.read(inp, "markdown") > > local formats =3D pandoc.writers > -- remove binary formats: > formats.docx =3D nil > formats.pptx =3D nil > formats.odt =3D nil > formats.epub2 =3D nil > formats.epub3 =3D nil > formats.epub =3D nil > formats.chunkedhtml =3D nil > formats.biblatex =3D nil > formats.bibtex =3D nil > formats.csljson =3D nil > > local blocks =3D {} > > -- Table of code languages to use for highlighting, when it differs > -- from the format name: > local langs =3D { > icml =3D "xml", > jira =3D "xml", > fb2 =3D "xml", > docbook =3D "xml", > docbook4 =3D "xml", > docbook5 =3D "xml", > commonmark =3D "markdown", > commonmark_x =3D "markdown", > context =3D "latex", > dzslides =3D "html5", > slideous =3D "html", > slidy =3D "html", > man =3D "troff", > ms =3D "troff", > gfm =3D "markdown", > markdown_mmd =3D "multimarkdown", > markdown_github =3D "markdown", > revealjs =3D "html", > beamer =3D "latex", > ipynb =3D "json", > opendocument =3D "xml", > native =3D "haskell", > html5 =3D "html", > html4 =3D "html", > } > > local sorted_formats =3D {} > for format,_ in pairs(formats) do > table.insert(sorted_formats, format) > end > table.sort(sorted_formats) > > -- construct document part for each format > for _,format in ipairs(sorted_formats) do > table.insert(blocks, pandoc.Header(2, format)) > local lang =3D langs[format] or format > table.insert(blocks, > pandoc.CodeBlock(pandoc.write(doc, format), {class =3D lang})) > end > > local template =3D pandoc.template.compile(pandoc.template.default("html5= ")) > local html =3D pandoc.write(pandoc.Pandoc(blocks, > {title =3D "Markup Rosetta Stone"}), > "html5", > { template =3D template }) > > io.open("rosetta.html", "w"):write(html) > print("Created rosetta.html") > > -- > 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/CC299ED9-B166-4B45-AC42-= 9DA430CAA122%40gmail.com > . > --=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/CADAJKhCWYdonBf1%2BJrrv1wAWj9ktm50WA54CbFnuQm1R0K%2BzRA%40ma= il.gmail.com. --0000000000002d983005f3153c9c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I wonder if my filters/custom writers for converting plai= n output into "email" =E2=80=94 something in between fully plain = and fully markdown, configurable in various ways (through metadata) =E2=80= =94 and to Perl POD could profit from being rewritten as standalone scripts= to be used with pandoc-lua. Both basically replace some elements in the AS= T with "plain" raw inline or block elements containing markup for= the actual target format around the content of the original element. As Lu= a scripts they could take configuaration on the command line, using a pure = Lua command line argument processor like Penlight's lapp rather than ha= ving to programmatically convert Pandoc metadata into a plain data structur= e with string/number leaves.

Den l=C3=B6r 21 jan. 2023 20:06John MacFarlan= e <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org&= gt; skrev:
-- This Lua script, when= run using `pandoc lua`, will create an HTML
-- file rosetta.html that compares how the same content is represented
-- in all the text markup languages pandoc supports:

local inp =3D [[
# Heading

## level 2

### level 3

#### level 4 with attributes {.blue #foobar}

- Unordered
- list

1. ordered
2. list

a) Lettered list

=C2=A0 =C2=A0with continuation paragraph

> Block quote

``` {.lua}
local formats =3D pandoc.writers
for format,_ in formats do
=C2=A0 print(format)
end
```

*emphasized text **with strong emphasis***

`verbatim text` and a [link with `verbatim`](http://example.com) ]]
local doc =3D pandoc.read(inp, "markdown")

local formats =3D pandoc.writers
-- remove binary formats:
formats.docx =3D nil
formats.pptx =3D nil
formats.odt =3D nil
formats.epub2 =3D nil
formats.epub3 =3D nil
formats.epub =3D nil
formats.chunkedhtml =3D nil
formats.biblatex =3D nil
formats.bibtex =3D nil
formats.csljson =3D nil

local blocks =3D {}

-- Table of code languages to use for highlighting, when it differs
-- from the format name:
local langs =3D {
=C2=A0 icml =3D "xml",
=C2=A0 jira =3D "xml",
=C2=A0 fb2 =3D "xml",
=C2=A0 docbook =3D "xml",
=C2=A0 docbook4 =3D "xml",
=C2=A0 docbook5 =3D "xml",
=C2=A0 commonmark =3D "markdown",
=C2=A0 commonmark_x =3D "markdown",
=C2=A0 context =3D "latex",
=C2=A0 dzslides =3D "html5",
=C2=A0 slideous =3D "html",
=C2=A0 slidy =3D "html",
=C2=A0 man =3D "troff",
=C2=A0 ms =3D "troff",
=C2=A0 gfm =3D "markdown",
=C2=A0 markdown_mmd =3D "multimarkdown",
=C2=A0 markdown_github =3D "markdown",
=C2=A0 revealjs =3D "html",
=C2=A0 beamer =3D "latex",
=C2=A0 ipynb =3D "json",
=C2=A0 opendocument =3D "xml",
=C2=A0 native =3D "haskell",
=C2=A0 html5 =3D "html",
=C2=A0 html4 =3D "html",
}

local sorted_formats =3D {}
for format,_ in pairs(formats) do
=C2=A0 table.insert(sorted_formats, format)
end
table.sort(sorted_formats)

-- construct document part for each format
for _,format in ipairs(sorted_formats) do
=C2=A0 table.insert(blocks, pandoc.Header(2, format))
=C2=A0 local lang =3D langs[format] or format
=C2=A0 table.insert(blocks,
=C2=A0 =C2=A0 =C2=A0 pandoc.CodeBlock(pandoc.write(doc, format), {class =3D= lang}))
end

local template =3D pandoc.template.compile(pandoc.template.default("ht= ml5"))
local html =3D pandoc.write(pandoc.Pandoc(blocks,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 {title =3D "Markup Rosetta Stone"}),
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "html5",<= br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { template =3D temp= late })

io.open("rosetta.html", "w"):write(html)
print("Created rosetta.html")

--
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 pandoc-discuss+unsubscribe@googlegroups.= com.
To view this discussion on the web visit https://groups.google.com/= d/msgid/pandoc-discuss/CC299ED9-B166-4B45-AC42-9DA430CAA122%40gmail.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://gro= ups.google.com/d/msgid/pandoc-discuss/CADAJKhCWYdonBf1%2BJrrv1wAWj9ktm50WA5= 4CbFnuQm1R0K%2BzRA%40mail.gmail.com.
--0000000000002d983005f3153c9c--