From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32088 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:48:41 -0800 (PST) Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_60_1774002861.1674596921085" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18305"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDDO7TNPVAKBBOVEYGPAMGQEUL3FISY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jan 24 22:48:46 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f57.google.com ([209.85.160.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKR9p-0004VQ-D1 for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 24 Jan 2023 22:48:45 +0100 Original-Received: by mail-oa1-f57.google.com with SMTP id 586e51a60fabf-15fddea3ee9sf4633781fac.21 for ; Tue, 24 Jan 2023 13:48:45 -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=HD8HTsEyhYSQHUyU9wiY6t7IpTL3AgttK1ZZpgXS5/g=; b=Isj0ib2N0NfyCV8bnrAISmpLg3WVrxE5Lza2X8mvxAgfZT/SuDfH3DeThRzFpkB4Gt I6R0ImkJvd7a2Mx6NRtksoOM5G/f+iS2JDhhf607cExHWP5JNxwIubhApVWSIlEfbJ0E +FwHnhj5t1D+sMVEVsft1Ewg4zFO96p3U8ulxhMy0O2gAMGyjEAB3dyYrLWDDc+JPyqs b4dR8jWs4zuvz6Hm58KBpl6BbWhYw8EwLOchATxw+lzHCOEu9gH/SqWWfNnyBh3TpxmZ eio2P4Cp3QefyANvRgSkK1kcLxwfFPOf2fJ24xBWQgZShOkFohf/NHRZake1N4e4h/KJ sT5w== 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=HD8HTsEyhYSQHUyU9wiY6t7IpTL3AgttK1ZZpgXS5/g=; b=xHRKLFQtMOD8z+QzJWA52NlFQF/58wItcZfEixfa1gDLjSPA3Z9MjX6n8najlgxZ2M nCGpU/Z/67r96jK3MluERkXx4LWVfI3sPreBsLwyh9ZsnQRNivfUTs3DhVz361J7daoy KT3oxPoAVeF4SZ60w8mlj6gFWKQ4wMr1M/1CwBqFIj0NJJ8Z4LPP6Sh7qYCJXtS1DCt9 ScMxPFCvKf9AbHjViJabricoWkePkif3tFVO4DtwhWB9c+0JZhoowyZlihewOYpzs82Z Sspvhl/F3+qzWat39Jk/5TdfZzRS0SuwTTuvp0Fu7mD5H49fwCZTCHxdSlvj1wO10U1P qQuA== X-Gm-Message-State: AFqh2kpkhUAg6W8dF0r7NqB4AFoo+6I+gmU7LDSrhIeTLaBbZ7Pz3+J8 cH7HDustRi+tYC2yrl5BDb4= X-Google-Smtp-Source: AMrXdXvoNd6GpGicg34RN//tfvlxpqhOMMO9BfsjHO2VNvBYu9pwnxc2NDz5jfgTvjzdlmyaSht66g== X-Received: by 2002:aca:bf06:0:b0:35b:4508:3c80 with SMTP id p6-20020acabf06000000b0035b45083c80mr2374585oif.109.1674596924021; Tue, 24 Jan 2023 13:48:44 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6808:1915:b0:36e:34e7:5e2 with SMTP id bf21-20020a056808191500b0036e34e705e2ls5115531oib.2.-pod-prod-gmail; Tue, 24 Jan 2023 13:48:41 -0800 (PST) X-Received: by 2002:a05:6808:a8a:b0:36e:928b:5be5 with SMTP id q10-20020a0568080a8a00b0036e928b5be5mr1417345oij.189.1674596921746; Tue, 24 Jan 2023 13:48:41 -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:32088 Archived-At: ------=_Part_60_1774002861.1674596921085 Content-Type: multipart/alternative; boundary="----=_Part_61_53066604.1674596921085" ------=_Part_61_53066604.1674596921085 Content-Type: text/plain; charset="UTF-8" Hello fiddlosopher, thank you very much for your answer. Great, it works! (Must definitely look into the potential of Lua filters...). Thanks for your time and best regards fiddlosopher schrieb am Dienstag, 24. Januar 2023 um 22:28:10 UTC+1: > This is using the new pandoc 3.0 feature which allows pandoc to be used as > a Lua interpreter. So just save the file as rosetta.lua and then; > > pandoc lua rosetta.lua > > > On Jan 24, 2023, at 1:17 PM, 'rufus42' via pandoc-discuss < > pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote: > > 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-discus...-/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 > > . > > > -- 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/dbe5d1cc-a2c7-4fb0-b266-6ae99805e6e9n%40googlegroups.com. ------=_Part_61_53066604.1674596921085 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello fiddlosopher,

thank you very much for your answer.
Gr= eat, it works!
(Must definitely look into the potential of Lua filters= ...).

Thanks for your time and best regards

fiddlosopher schri= eb am Dienstag, 24. Januar 2023 um 22:28:10 UTC+1:
This is using the new pandoc 3.0 feature which = allows pandoc to be used as a Lua interpreter. =C2=A0So just save the file = as rosetta.lua and then;

pandoc lua rosetta.lua


On Jan 24, 2023, at 1:17 PM, &#= 39;rufus42' via pandoc-discuss <pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> wrote:

Hello fiddlosopher= ,

Thank you very much for sharing your script.
I would like to us= e 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 UT= C+1:
-- This Lua script, when run using `pandoc lua`, will c= reate 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://exam= ple.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(&quo= t;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 &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discus...@googleg= roups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d9e014a6-2= dfd-44e3-a856-2bf18959103dn%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/dbe5d1cc-a2c7-4fb0-b266-6ae99805e6e9n%40googlegroups.= com.
------=_Part_61_53066604.1674596921085-- ------=_Part_60_1774002861.1674596921085--