From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29763 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?S=C3=A9bastien_Boisg=C3=A9rault?= Newsgroups: gmane.text.pandoc Subject: Re: Two treatments of same input file Date: Sat, 11 Dec 2021 14:23:35 -0800 (PST) Message-ID: 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_1706_718626672.1639261415773" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33322"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCIOBSUCXMMRB2GJ2SGQMGQELGY6FBI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Sat Dec 11 23:23:40 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f56.google.com ([209.85.210.56]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mwAmJ-0008V3-KH for gtp-pandoc-discuss@m.gmane-mx.org; Sat, 11 Dec 2021 23:23:39 +0100 Original-Received: by mail-ot1-f56.google.com with SMTP id h15-20020a9d554f000000b0055c93007430sf4175146oti.2 for ; Sat, 11 Dec 2021 14:23:39 -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=gPnyF4Y+2DRT+8c0AcTPJrECJqFnv9rk/DrTFIuVOy4=; b=kuxCCnoXFvn4E/aWOq+95G/nJZ9Jwb1wgXaHm9oRUlZSi8J2d7zWvFmk+8MRmr68KX n3YWgLmXYBUfwZamlc7ET4bhF9zHY2vJpTTA4bbMp5/OMRAIiiP8rnuFsYfOUzsckIn2 i3OGAAISjBmtBtFd31zk7bCR02Fj0v8bJEUmL/6uhO/y7Au01tI7R2krBwq5wK1cpsXu Br94WDo5lDEIFpQNQqoTDfyaGGwvlTTyL8KDSZg1PumUq0FvBjifV2bxV6eXRfRuph9A eF2xI+X97yB226fE7f/8nlINplfQWHxcit7JAZLXIajjs+F/0o2OzJr+Hkk+yu8n4Chd mSsg== 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=gPnyF4Y+2DRT+8c0AcTPJrECJqFnv9rk/DrTFIuVOy4=; b=UVlYSb8+pBBQVYfMpZA5wsqPRq2LVSCApk+H0lahP97uLZMiDkmaxsFMTsxYkTcHdC +KeahENZ2Yv8TmJQmbf+6pxpJjpDWbKvH7hMyccbWVKcchx3YEwurRovuHYQi8FLSTd8 GP3jjxs8Amguztg0T/dlEMc4TD6m/ScSeodIcB+LNbAKgVoIdKSmfQPI41askMBtOySZ 0SSd0VZkWXoyGk0a1aBs+yHh8qZ5VoOCbXZthwWSgd3cywNBfWh+qYrWwUG8hAj03I3+ f5XjiLbueRdjLgon8TuI9fisx8KTQELrcvZe6bH6s5fKRCLg0WQFcPUOWS233fIsAFoU s7Ag== 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=gPnyF4Y+2DRT+8c0AcTPJrECJqFnv9rk/DrTFIuVOy4=; b=tkSeF/of9P/jLhaNCzrVLZ8ejCDBZtgLJVOayFyoH5+qTbeh0rlGU7Rgt/xsD8MVOV QUGjgCGe77wDeK5S0zfgCNyhJ7fTyWi3gKilCM5EHN5bDf14p+3V8xvTGQD6QsnygblI s0JXCVbrID+YUBLEuCxN9fJiW9clybSjYPX9saiR3/TO792zVvl1DKwek6443baxk9Nv 9+7RylBQEcrWez/nC4BvA/8ae8EAbDnNcE0xWm7tIPnyTBEAsDq2ewKWW0AIRTPgDEnP Zxo6TYFZ7Nu42hf/f+/28NJzHM4r/6yRGQ/jRwzP57UdOtDpSUQQIsJUxppd2zTAk/eQ xVTw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM530ZB3G8lgb6/XsgzjZQdj/9NYYjIP+60190Q1k6teL69x7XtxRm GBsh2JuY7iCsKwMy6VAmR9M= X-Google-Smtp-Source: ABdhPJzpIbis6bBnglVHpdyLXeT2WBgjakSrWZCbq0rKPYwRHQ1Y13NOvEcyK2NDruNCA/WQRbbngg== X-Received: by 2002:a4a:dec8:: with SMTP id w8mr13610853oou.24.1639261418003; Sat, 11 Dec 2021 14:23:38 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6830:3116:: with SMTP id b22ls3294990ots.3.gmail; Sat, 11 Dec 2021 14:23:36 -0800 (PST) X-Received: by 2002:a9d:2085:: with SMTP id x5mr17849978ota.228.1639261416455; Sat, 11 Dec 2021 14:23:36 -0800 (PST) In-Reply-To: X-Original-Sender: Sebastien.Boisgerault-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:29763 Archived-At: ------=_Part_1706_718626672.1639261415773 Content-Type: multipart/alternative; boundary="----=_Part_1707_419223630.1639261415773" ------=_Part_1707_419223630.1639261415773 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le samedi 11 d=C3=A9cembre 2021 =C3=A0 01:08:47 UTC+1, spotte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org = 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...-Re5JQEeQqe8@public.gmane.org= m 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) wit= h=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 tim= e=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 use= =20 > 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 > > https://groups.google.com/d/topic/pandoc-discuss/mfaEmeNEx7o/unsubscrib= e.=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/b7669818-66ed-4336-af6e-f41eec4cd6f5n%40googlegroups.com. ------=_Part_1707_419223630.1639261415773 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

L= e samedi 11 d=C3=A9cembre 2021 =C3=A0 01:08:47 UTC+1, spotte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a= =C3=A9crit :
This might work better for me since I am much more familiar with Pytho= n than
Lua. I didn't know there was a Pandoc library for Python!

There are actually 3 Pandoc librairies for Python (th= at I know of):

  - pandocfilters: https://pan= doc.org/filters.html#but-i-dont-want-to-learn-haskell

<= div>  - panflute: http://scorreia.com/software/panflute/
  - pandoc (Python): https://boisgera.github.io/pandoc/

Cheers,

SB
 
spotte...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a =C3=A9cri= t :
> > I'm work on creating a set of examples of HTML, JavaScript, a= nd 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 Python a= nd 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", opti= ons=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"But= ton"/>
> </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"><pre class=3D"s= ourceCode html"><code
> > class=3D"sourceCode html"><a class=3D"sourceLine" id=3D= "cb1-1" title=3D"1"><span
> > class=3D"kw">&lt;form&gt;</span></a>
> > <a class=3D"sourceLine" id=3D"cb1-2" title=3D"2"><sp= an
> > class=3D"kw">&lt;input</span><span class=3D"o= t"> id=3D</span><span
> > class=3D"st">&quot;b1&quot;</span><span c= lass=3D"ot"> type=3D</span><span
> > class=3D"st">&quot;button&quot;</span><sp= an class=3D"ot"> value=3D</span><span
> > class=3D"st">&quot;Apply&quot;</span><spa= n class=3D"ot"> title=3D</span><span
> > class=3D"st">&quot;Button&quot;</span><sp= an class=3D"kw">/&gt;</span></a>
> > <a class=3D"sourceLine" id=3D"cb1-3" title=3D"3"><sp= an
> > class=3D"kw">&lt;/form&gt;</span></a>&= lt;/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= ...@googlegroups.com.
> To view this discussion on the web visit=20
> https://groups.goog= le.com/d/msgid/pandoc-discuss/84047109-8502-490c-82fe-0104c3dfcfbdn%40googl= egroups.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/b7669818-66ed-4336-af6e-f41eec4cd6f5n%40googlegroups.= com.
------=_Part_1707_419223630.1639261415773-- ------=_Part_1706_718626672.1639261415773--