From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29795 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Weber Newsgroups: gmane.text.pandoc Subject: Re: Two treatments of same input file Date: Wed, 15 Dec 2021 17:16:40 -0800 (PST) Message-ID: <7a7009c9-67b2-4cc4-81ac-6c5431d6259bn@googlegroups.com> References: <736c254f-44fe-49f8-9556-2f4c83c4e5a0n@googlegroups.com> <84047109-8502-490c-82fe-0104c3dfcfbdn@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_15510_1741697835.1639617400445" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2347"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDVM5VNNVUEBB6NG5KGQMGQEN4PXDUI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Dec 16 02:16:49 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f62.google.com ([209.85.161.62]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxfO4-0000LC-Td for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 16 Dec 2021 02:16:49 +0100 Original-Received: by mail-oo1-f62.google.com with SMTP id y17-20020a4ade11000000b002c9cd91f98fsf15798066oot.13 for ; Wed, 15 Dec 2021 17:16:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:list-subscribe :list-unsubscribe; bh=NegLOt19FcJaLDCKYqklE/MtXnm1FkSJp75FNbkVM6U=; b=snYCh8/7+5BeJGWML0plImlnYia71XiipQWLpOqX4J90O77imJAxPelHHkR2IHzjxA Va+7V40U6dyvkPn2VQY6J8ZlUfnVWY7ufK7BB7KScwqJm8O+AHbnBQhBtLxpxwawvgMP 6+qzAGIv4Am7qgLBT4J44OfREjWKhxd1Hvr7ridUyIWi+sRQoooNZPB7FjBtFKEVv/jz EL8qPIK7MqUlmL/t2o1kzk9i0xZBpESRtnjHRrrIM2MmyfJWr9ehL4OJGIqX5jyzo+2x Qqj5g2JnXMFpu8qnyxSmjF1wfhwQkQz+b4CGHWJZ/en7GrZl9cm+UQzp2KaHhI8U1G80 HLfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=NegLOt19FcJaLDCKYqklE/MtXnm1FkSJp75FNbkVM6U=; b=GXENx8SohcPOnqMg/h91pKNBmzJlvJhOY8vIeQIY7UD2WopScxjRFQ6B7t39tY+1Vi Z2cU3K171TISI+Yy75qOkQ+SyD9majtSgFePP8JNJX6bAniJp90cams4R5tCNkT41k86 egTDELHGVzfyfJNAM646N9271S6ZeRLkDkRLf5w0AGHzeJtKdCaKXQpqvwrjvBa9gDyL B106mPvyPHsUxmEEF4y23j9r1auNcL2eBQepPvrF+XjjFhswmoOtVZHhBRdw9/4gVNvv s3CwEwFyWfRiL5Wny1b8XZg+WNh5IucK/XGDczZ8d7zdMNmj+SUFGmsTFnvbF7p5FkPF k6Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=NegLOt19FcJaLDCKYqklE/MtXnm1FkSJp75FNbkVM6U=; b=t18NTW/9+DHobMEwgjJPviuoZ7Ie1glANveaOblPuuG/Xp3gKawrNxAm9ldjcexz38 2iLoxbHCy/4KOM3+xz1kG0iD8ILg6KvtTp0ZEdUfw/CpVuMLz9Y6xH2hoibxTywdW8jc pJEtqa/90WIAS6rMhoRk+fHdpFwZP7NwFxB9rpyBbEuXKR7nlY8+Ph4sYda/+mA9TlFO ACs+3sZEfIfIOFvSCMeB+lBMxT+2JqlHnT8uMVaSZGMZXqL9cPoT91ywEckS51CFHzeL wWHYfo6kVOhtSCA0dQ/t87KCs/3/aTP9g5WMD68lJ+wcrWe/cJh+4Q+WASRlmfiBSvOH LLig== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM532xIuEGDjod4QU7Jn9ku2pfu8yGPWHZUAREokhP1S4iN4OBBjLT 65NFAaFgvR3XlJNQ9+WQZzU= X-Google-Smtp-Source: ABdhPJyzYy9SV1Rv1R4ocuGnYLx78vuEKZe8JqRbM5uUrqjXLFu4Ai8q+4u0NmXYy82gtIWOeVMd2A== X-Received: by 2002:a4a:bb90:: with SMTP id h16mr9346086oop.20.1639617402564; Wed, 15 Dec 2021 17:16:42 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6808:1921:: with SMTP id bf33ls969602oib.6.gmail; Wed, 15 Dec 2021 17:16:41 -0800 (PST) X-Received: by 2002:a05:6808:d4d:: with SMTP id w13mr2305132oik.85.1639617401001; Wed, 15 Dec 2021 17:16:41 -0800 (PST) In-Reply-To: X-Original-Sender: spottedMetal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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:29795 Archived-At: ------=_Part_15510_1741697835.1639617400445 Content-Type: multipart/alternative; boundary="----=_Part_15511_1964421609.1639617400445" ------=_Part_15511_1964421609.1639617400445 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Too many good options! I've decided to work with the Lua filters, since they are more efficient=20 and Lua is built into Pandoc, for now. And it is working pretty well for= =20 me so far. On Saturday, December 11, 2021 at 5:23:35 PM UTC-5 sebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org= =20 wrote: > Le samedi 11 d=C3=A9cembre 2021 =C3=A0 01:08:47 UTC+1, spotte...-Re5JQEeQqe8@public.gmane.org= m a =C3=A9crit : > >> This might work better for me since I am much more familiar with Python= =20 >> than=20 >> Lua. I didn't know there was a Pandoc library for Python!=20 > > > There are actually 3 Pandoc librairies for Python (that I know of): > > - pandocfilters:=20 > https://pandoc.org/filters.html#but-i-dont-want-to-learn-haskell > > - panflute: http://scorreia.com/software/panflute/ > > - pandoc (Python): https://boisgera.github.io/pandoc/ > > Cheers, > > SB > > =20 > >> Thanks very much.=20 >> >> On Fri, 2021-12-10 at 07:39 -0800, S=C3=A9bastien Boisg=C3=A9rault wrote= :=20 >> >=20 >> >=20 >> > Le jeudi 9 d=C3=A9cembre 2021 =C3=A0 03:52:34 UTC+1, spotte...@gmail.c= om a =C3=A9crit=20 >> :=20 >> > > I'm work on creating a set of examples of HTML, JavaScript, and SVG= =20 >> code.=20 >> > > Each comes from a single source file, from which I want to produce a= =20 >> > > web page showing=20 >> > > (a) the result of rendering the HTML or SVG or executing the=20 >> JavaScript;=20 >> > > (b) the code itself, viewed as if in a text editor, and (ideally)=20 >> with=20 >> > > syntax highlighting.=20 >> > >=20 >> > > The best way I can think of doing this involves making two=20 >> > > transformations of the source file, running pandoc on each of them,= =20 >> > > and the combining the outputs, probably by running pandoc a third=20 >> time=20 >> > > with a custom template.=20 >> > >=20 >> > > I'm wondering if there's any better way?=20 >> >=20 >> > IMHO, you only need one call to pandoc: if you're ok with Python and= =20 >> with the=20 >> > pandoc python library (https://pypi.org/project/pandoc/), you could=20 >> use the=20 >> > following showcase.py script :=20 >> >=20 >> > # file: showcase.py=20 >> > import sys=20 >> > import pandoc=20 >> > from pandoc.types import Pandoc, Meta, CodeBlock, RawBlock=20 >> >=20 >> > if __name__ =3D=3D "__main__":=20 >> > filename =3D sys.argv[1]=20 >> > with open(filename) as html_file:=20 >> > html =3D html_file.read()=20 >> > html_block =3D RawBlock("html", html)=20 >> > attr =3D ("", ["html"], [])=20 >> > code_block =3D CodeBlock(attr, html)=20 >> > doc =3D Pandoc(Meta({}), [html_block, code_block])=20 >> > with open("out.html", "bw") as output:=20 >> > pandoc.write(doc, file=3Doutput, format=3D"html", options=3D["=20 >> > --standalone"])=20 >> >=20 >> > Then, if you call=20 >> >=20 >> > $ python -m showcase.py form.html=20 >> >=20 >> > where form.html is the HTML file=20 >> >=20 >> >
=20 >> > =20 >> >
=20 >> >=20 >> > you will end up with the desired output in the file "out.html".=20 >> >=20 >> > Cheers,=20 >> >=20 >> > SB=20 >> >=20 >> > > Here's a small example:=20 >> > >=20 >> > > (1) Original source file:=20 >> > >=20 >> > >
=20 >> > > = =20 >> > >
=20 >> > >=20 >> > >=20 >> > > (2) Intermediate file 1:=20 >> > >=20 >> > > ```{=3Dhtml5}=20 >> > >
=20 >> > > = =20 >> > >
=20 >> > > ```=20 >> > >=20 >> > > (3) Intermediate file 2:=20 >> > >=20 >> > > ~~~~{.html}=20 >> > >
=20 >> > > = =20 >> > >
=20 >> > > ~~~~=20 >> > >=20 >> > > (4) Desired final output would be something like this:=20 >> > >=20 >> > > ...=20 >> > >=20 >> > >

A Form with a Button

=20 >> > >=20 >> > >
=20 >> > > = =20 >> > >
=20 >> > >=20 >> > >

Code to Produce a Form with a Button

=20 >> > >=20 >> > > =20 >> > >=20 >> > > ...=20 >> > >=20 >> >=20 >> > --=20 >> > You received this message because you are subscribed to a topic in the= =20 >> Google=20 >> > Groups "pandoc-discuss" group.=20 >> > To unsubscribe from this topic, visit=20 >> >=20 >> https://groups.google.com/d/topic/pandoc-discuss/mfaEmeNEx7o/unsubscribe= .=20 >> >> > To unsubscribe from this group and all its topics, send an email to=20 >> > pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org=20 >> > To view this discussion on the web visit=20 >> >=20 >> https://groups.google.com/d/msgid/pandoc-discuss/84047109-8502-490c-82fe= -0104c3dfcfbdn%40googlegroups.com=20 >> > .=20 >> >> --=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/7a7009c9-67b2-4cc4-81ac-6c5431d6259bn%40googlegroups.com. ------=_Part_15511_1964421609.1639617400445 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Too many good options!
I've decided to work with the Lua filters, since= they are more efficient and Lua is built into Pandoc, for now.  And i= t is working pretty well for me so far.

On Saturday, December 11, 2021 = at 5:23:35 PM UTC-5 sebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

<= /div>

=C2=A0 - pandoc (Python): https://boisgera.github.io/pandoc/

Che= ers,

SB
=

=C2=A0
Thanks very much.

On Fri, 2021-12-10 at 07:39 -0800, S=C3=A9bastien Boisg=C3=A9rault wrot= e:
>=20
>=20
> Le jeudi 9 d=C3=A9cembre 2021 =C3=A0 03:52:34 UTC+1, spotte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a =C3=A9crit :
> > I'm work on creating a set of examples of HTML, JavaScrip= t, and SVG code.
> > Each comes from a single source file, from which I want to pr= oduce a
> > web page showing
> > (a) the result of rendering the HTML or SVG or executing the = JavaScript;
> > (b) the code itself, viewed as if in a text editor, and (idea= lly) with
> > syntax highlighting.
> >=20
> > The best way I can think of doing this involves making two
> > transformations of the source file, running pandoc on each of= them,
> > and the combining the outputs, probably by running pandoc a t= hird time
> > with a custom template.
> >=20
> > I'm wondering if there's any better way?
>=20
> IMHO, you only need one call to pandoc: if you're ok with Pyth= on and with the
> pandoc python library (https://pypi.org/project/pandoc/), you could use the
> following showcase.py script :
>=20
> # file: showcase.py
> import sys
> import pandoc
> from pandoc.types import Pandoc, Meta, CodeBlock, RawBlock
>=20
> if __name__ =3D=3D "__main__":
> filename =3D sys.argv[1]
> with open(filename) as html_file:
> html =3D html_file.read()
> html_block =3D RawBlock("html", html)
> attr =3D ("", ["html"], [])
> code_block =3D CodeBlock(attr, html)
> doc =3D Pandoc(Meta({}), [html_block, code_block])
> with open("out.html", "bw") as output:
> pandoc.write(doc, file=3Doutput, format=3D"html&q= uot;, options=3D["
> --standalone"])
>=20
> Then, if you call
>=20
> $ python -m showcase.py form.html
>=20
> where form.html is the HTML file
>=20
> <form>
> <input id=3D"b1" type=3D"button" value=3D= "Apply" title=3D"Button"/>
> </form>
>=20
> you will end up with the desired output in the file "out.html= ".
>=20
> Cheers,
>=20
> SB
> =20
> > Here's a small example:
> >=20
> > (1) Original source file:
> >=20
> > <form>
> > <input id=3D"b1" type=3D"button" value= =3D"Apply" title=3D"Button"/>
> > </form>
> >=20
> >=20
> > (2) Intermediate file 1:
> >=20
> > ```{=3Dhtml5}
> > <form>
> > <input id=3D"b1" type=3D"button" value= =3D"Apply" title=3D"Button"/>
> > </form>
> > ```
> >=20
> > (3) Intermediate file 2:
> >=20
> > ~~~~{.html}
> > <form>
> > <input id=3D"b1" type=3D"button" value= =3D"Apply" title=3D"Button"/>
> > </form>
> > ~~~~
> >=20
> > (4) Desired final output would be something like this:
> >=20
> > ...
> >=20
> > <h2>A Form with a Button</h2>
> >=20
> > <form>
> > <input id=3D"b1" type=3D"button" value= =3D"Apply" title=3D"Button"/>
> > </form>
> >=20
> > <h2>Code to Produce a Form with a Button</h2>
> >=20
> > <div class=3D"sourceCode" id=3D"cb1"&g= t;<pre class=3D"sourceCode html"><code
> > class=3D"sourceCode html"><a class=3D"so= urceLine" id=3D"cb1-1" title=3D"1"><span
> > class=3D"kw">&lt;form&gt;</span>&l= t;/a>
> > <a class=3D"sourceLine" id=3D"cb1-2" t= itle=3D"2"><span
> > class=3D"kw">&lt;input</span><span = class=3D"ot"> id=3D</span><span
> > class=3D"st">&quot;b1&quot;</span>= <span class=3D"ot"> type=3D</span><span
> > class=3D"st">&quot;button&quot;</span= ><span class=3D"ot"> value=3D</span><span
> > class=3D"st">&quot;Apply&quot;</span&= gt;<span class=3D"ot"> title=3D</span><span
> > class=3D"st">&quot;Button&quot;</span= ><span class=3D"kw">/&gt;</span></a>
> > <a class=3D"sourceLine" id=3D"cb1-3" t= itle=3D"3"><span
> > class=3D"kw">&lt;/form&gt;</span>&= lt;/a></code></pre></div>
> >=20
> > ...
> >=20
>=20
> --=20
> You received this message because you are subscribed to a topic in= the Google
> Groups "pandoc-discuss" group.
> To unsubscribe from this topic, visit=20
> https://group= s.google.com/d/topic/pandoc-discuss/mfaEmeNEx7o/unsubscribe.
> To unsubscribe from this group and all its topics, send an email t= o=20
> pandoc-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> To view this discussion on the web visit=20
> https://groups.google= .com/d/msgid/pandoc-discuss/84047109-8502-490c-82fe-0104c3dfcfbdn%40googleg= roups.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/7a7009c9-67b2-4cc4-81ac-6c5431d6259bn%40googlegroups.= com.
------=_Part_15511_1964421609.1639617400445-- ------=_Part_15510_1741697835.1639617400445--