From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32086 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'rufus42' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: more fun with pandoc lua Date: Tue, 24 Jan 2023 13:17:26 -0800 (PST) Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_202_1097048206.1674595046516" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20618"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDDO7TNPVAKBBZ4VYGPAMGQEGVKNFDY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jan 24 22:17:31 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f63.google.com ([209.85.160.63]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKQfb-0005AQ-0u for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 24 Jan 2023 22:17:31 +0100 Original-Received: by mail-oa1-f63.google.com with SMTP id 586e51a60fabf-1632b78625csf302135fac.22 for ; Tue, 24 Jan 2023 13:17:30 -0800 (PST) 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-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=T0Go5B0Dz3JAwdVLAp5JDc0xzvwWd8yCmbYm8lT8n40=; b=s3YyGhgAYYJgAVx4SRdWNbmHiIIP1YzAANGT43ZtkgyVSm4QzQDAZGS/wVo2hehQSN 2UHM3hZw/Dly38BZiuaOmSUqDbU5O56e0tcKG493g6q/xr/jb3v3ZSg0A4o2iPdJAW6M dd3cqjJlMx+uV4EpSXE0tok2xEWMuvRkNrrawWRlW7Zu1aXymD2h+GzSiLmrsXKz56FT QpxC3DPVn066Or9Iod1RQJ8m3QScP/Lml4X3qkUnlVFVcld9FB+4gTrP/AERgz0Jbcvg SqNBAi/mxmIzo71EbLr6f9E2kDiwgiz+0OVtP2l4iDt9Ca3G2usXO5L6b2ERKfz8I9ll ah6w== 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-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=T0Go5B0Dz3JAwdVLAp5JDc0xzvwWd8yCmbYm8lT8n40=; b=lh6U7oN3gsDi+SCem1EZdmpbDnnG5gGj0xy/JYTsW+g80zuMThcIgJ8Lxrk1jGbqhQ 91oXHBXwnFP3PBQ+MUD/MNf5pRwoOnC79JDACbeld133RT9zQuXRNKmCtNYvZPGV88yq cgvgg6TxDqr+G5T0Ii+mf86vB8+Looco0tmdUHbO+b2X4SBD+dHRMcQqSuuFGjr9Was5 IFN//B3KNeqaZXjl6x+5Uwdx4f5c/lMSk3ZNW6brJvDNjhbWBxA4cxkZXAqoF9AYwZa0 p5goDcIQCSYzsSEWs8Rk3rQXknzEI9gpe50Y6ZCxd+cMgdN/Lcp/DnokU0FJo92XbO+m EyZA== X-Gm-Message-State: AFqh2koCK7zhawZ1FOsHA9HE+Po6VFItQnrI30NwV9mn6Vvs4ZHTaAoq /VIV4RV9oZZgBoZ2GwlH/gw= X-Google-Smtp-Source: AMrXdXsr+m3CMJwIxTBeCNrw8Yq+A/vR3yBTnCklKSA+PABwirkNS/C+y/js50VrgFqGFCiQE2FXzw== X-Received: by 2002:a05:6870:aa87:b0:15c:a5de:27da with SMTP id gr7-20020a056870aa8700b0015ca5de27damr2244489oab.4.1674595049880; Tue, 24 Jan 2023 13:17:29 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:8c01:b0:13d:173c:e583 with SMTP id ec1-20020a0568708c0100b0013d173ce583ls6466027oab.0.-pod-prod-gmail; Tue, 24 Jan 2023 13:17:27 -0800 (PST) X-Received: by 2002:a05:6870:d628:b0:15e:aba8:267a with SMTP id a40-20020a056870d62800b0015eaba8267amr2014470oaq.123.1674595047275; Tue, 24 Jan 2023 13:17:27 -0800 (PST) In-Reply-To: X-Original-Sender: rainer.beckmann-ZRomsLx7rX2mi9biYS2Iuw@public.gmane.org X-Original-From: rufus42 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:32086 Archived-At: ------=_Part_202_1097048206.1674595046516 Content-Type: multipart/alternative; boundary="----=_Part_203_1524684757.1674595046516" ------=_Part_203_1524684757.1674595046516 Content-Type: text/plain; charset="UTF-8" Hello fiddlosopher, Thank you very much for sharing your script. I would like to use it, but unfortunately I don't know how. Do I use the script like a Lua filter? Please be so kind and give me a hint how I can use your script. Thank you for your time and best regards fiddlosopher schrieb am Samstag, 21. Januar 2023 um 20:05:46 UTC+1: -- 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 = [[ # 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 = 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 = pandoc.read(inp, "markdown") local formats = pandoc.writers -- remove binary formats: formats.docx = nil formats.pptx = nil formats.odt = nil formats.epub2 = nil formats.epub3 = nil formats.epub = nil formats.chunkedhtml = nil formats.biblatex = nil formats.bibtex = nil formats.csljson = nil local blocks = {} -- Table of code languages to use for highlighting, when it differs -- from the format name: local langs = { icml = "xml", jira = "xml", fb2 = "xml", docbook = "xml", docbook4 = "xml", docbook5 = "xml", commonmark = "markdown", commonmark_x = "markdown", context = "latex", dzslides = "html5", slideous = "html", slidy = "html", man = "troff", ms = "troff", gfm = "markdown", markdown_mmd = "multimarkdown", markdown_github = "markdown", revealjs = "html", beamer = "latex", ipynb = "json", opendocument = "xml", native = "haskell", html5 = "html", html4 = "html", } local sorted_formats = {} 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 = langs[format] or format table.insert(blocks, pandoc.CodeBlock(pandoc.write(doc, format), {class = lang})) end local template = pandoc.template.compile(pandoc.template.default("html5")) local html = pandoc.write(pandoc.Pandoc(blocks, {title = "Markup Rosetta Stone"}), "html5", { template = 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/d9e014a6-2dfd-44e3-a856-2bf18959103dn%40googlegroups.com. ------=_Part_203_1524684757.1674595046516 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello fiddlosopher,

Thank you very much for sharing your script.=
I would like to use it, but unfortunately I don't know how.
Do I= use the script like a Lua filter?

Please be so kind and give me= a hint how I can use your script.

Thank you for your time and b= est regards

fiddlosopher schrieb am Samst= ag, 21. Januar 2023 um 20:05:46 UTC+1:
-- This Lua script,= when run using `pandoc lua`, will create an HTML
-- file rosetta.html that compares how the same content is represente= d
-- 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("h= tml5"))
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 &= 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/d9e014a6-2dfd-44e3-a856-2bf18959103dn%40googlegroups.= com.
------=_Part_203_1524684757.1674595046516-- ------=_Part_202_1097048206.1674595046516--