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 it 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: > Le samedi 11 décembre 2021 à 01:08:47 UTC+1, spotte...-Re5JQEeQqe8@public.gmane.orgm a écrit : > >> This might work better for me since I am much more familiar with Python >> than >> Lua. I didn't know there was a Pandoc library for Python! > > > There are actually 3 Pandoc librairies for Python (that I know of): > > - pandocfilters: > 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 > > > >> Thanks very much. >> >> On Fri, 2021-12-10 at 07:39 -0800, Sébastien Boisgérault wrote: >> > >> > >> > Le jeudi 9 décembre 2021 à 03:52:34 UTC+1, spotte...@gmail.com a écrit >> : >> > > I'm work on creating a set of examples of HTML, JavaScript, and SVG >> code. >> > > Each comes from a single source file, from which I want to produce 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 (ideally) >> with >> > > syntax highlighting. >> > > >> > > 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 third >> time >> > > with a custom template. >> > > >> > > I'm wondering if there's any better way? >> > >> > IMHO, you only need one call to pandoc: if you're ok with Python and >> with the >> > pandoc python library (https://pypi.org/project/pandoc/), you could >> use the >> > following showcase.py script : >> > >> > # file: showcase.py >> > import sys >> > import pandoc >> > from pandoc.types import Pandoc, Meta, CodeBlock, RawBlock >> > >> > if __name__ == "__main__": >> > filename = sys.argv[1] >> > with open(filename) as html_file: >> > html = html_file.read() >> > html_block = RawBlock("html", html) >> > attr = ("", ["html"], []) >> > code_block = CodeBlock(attr, html) >> > doc = Pandoc(Meta({}), [html_block, code_block]) >> > with open("out.html", "bw") as output: >> > pandoc.write(doc, file=output, format="html", options=[" >> > --standalone"]) >> > >> > Then, if you call >> > >> > $ python -m showcase.py form.html >> > >> > where form.html is the HTML file >> > >> >
>> > >> >
>> > >> > you will end up with the desired output in the file "out.html". >> > >> > Cheers, >> > >> > SB >> > >> > > Here's a small example: >> > > >> > > (1) Original source file: >> > > >> > >
>> > > >> > >
>> > > >> > > >> > > (2) Intermediate file 1: >> > > >> > > ```{=html5} >> > >
>> > > >> > >
>> > > ``` >> > > >> > > (3) Intermediate file 2: >> > > >> > > ~~~~{.html} >> > >
>> > > >> > >
>> > > ~~~~ >> > > >> > > (4) Desired final output would be something like this: >> > > >> > > ... >> > > >> > >

A Form with a Button

>> > > >> > >
>> > > >> > >
>> > > >> > >

Code to Produce a Form with a Button

>> > > >> > >
> > > class="sourceCode html">> title="1">> > > class="kw"><form> 
>> > > > > > class="kw"><input id=> > > class="st">"b1" type=> > > class="st">"button" 
>> value=> > > class="st">"Apply" 
>> title=> > > class="st">"Button"/> 
>> > > > > > class="kw"></form>
>> > > >> > > ... >> > > >> > >> > -- >> > You received this message because you are subscribed to a topic in the >> Google >> > Groups "pandoc-discuss" group. >> > To unsubscribe from this topic, visit >> > >> https://groups.google.com/d/topic/pandoc-discuss/mfaEmeNEx7o/unsubscribe. >> >> > To unsubscribe from this group and all its topics, 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/84047109-8502-490c-82fe-0104c3dfcfbdn%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/7a7009c9-67b2-4cc4-81ac-6c5431d6259bn%40googlegroups.com.