From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33023 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: jcr Newsgroups: gmane.text.pandoc Subject: Re: Setting a template based on YAML metadata blocks Date: Thu, 3 Aug 2023 07:45:57 -0700 (PDT) Message-ID: <4a3a505c-cd43-4582-b098-ce27523a6ce8n@googlegroups.com> References: <6CAC3AED-3628-4F25-BBB9-D3CEA9CECA36@gmail.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_6372_1392737859.1691073957372" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27568"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDQLFNXWVILBBJX3V2TAMGQEEHPEQMI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Thu Aug 03 16:46:03 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 1qRZaU-0006zv-Oe for gtp-pandoc-discuss@m.gmane-mx.org; Thu, 03 Aug 2023 16:46:02 +0200 Original-Received: by mail-oa1-f57.google.com with SMTP id 586e51a60fabf-1bf00f8cf77sf1362842fac.0 for ; Thu, 03 Aug 2023 07:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1691073961; x=1691678761; 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 :sender:from:to:cc:subject:date:message-id:reply-to; bh=Lz/b6QFm97XNvzHvhiAOZWVLCdyAT5QnUBy6jeV6scc=; b=fFCn0kLr9Tscqin5+DO2/prYrm8u2ddVXcnMrhDtE5MSEjldoZpalGWzaYeN21Qca+ FnItXw/8nyIHJUq5w9lly9dw4wPdjyuzwpbw3X37v6qmc3tj+aDl1ADLEAKkWC25XDDR 9xwgKF/sFINip+EY3sLW6g2dSaqCkNVMXqiQh9CxOS5S3WySXKXIooCC4B7/+/hmDxCh JfvQhoOUf3UP97eeumKfltHoUsJt21Ug5nLFzUuAVYf5kDSksq5CfA+JSgypYxyYaE35 bWxstmKJO+qlnU9zY9114mb/Lgm69ehRoMAMlGzeKEhnN8LM26eI6BzunvgFJBuhjHm4 GX4w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691073961; x=1691678761; 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=Lz/b6QFm97XNvzHvhiAOZWVLCdyAT5QnUBy6jeV6scc=; b=Rg8MQhgAdkcrUtxxjAcLf+3LPsULbZZ3J55jSHPLc0bBkk8hx4tWe3j2d/Oyc3IUVi Xi7/o/F89ST+uKBWmdn19aMxdMR+TteWQLIH6bxWWw29rNok0lfocynWqwrqCPj7IJa0 tVMyRinSm1R4C9VS5EI1znt44BRzgH8iyL5xAN5Ki6bYd6zmG9EO5rrxxY6Q3A5mNWRh JpX9CSUTX68JY6c6q0C3SoU9ZY5IyYpf8pGeTE9t4LAF/Skaep/5qrYFLBpYRXm08AOn /jnPcrkx4C7D+f031EC2vZi5o9YMt0PTJghvL2JxUzhpnGhEWf9frg70wkal8i/e2dkh fdJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691073961; x=1691678761; 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-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=Lz/b6QFm97XNvzHvhiAOZWVLCdyAT5QnUBy6jeV6scc=; b=ItoAoWDBJPmhKvGZG7Jdl5qmM8+sLy0/uR7LMQH+rAzzyC8kvObBUWBM/PkeUo0cF1 PeKqzWIOYL3t6t48T87h5CmUbegwpl2/j/132VrwqptHhspSCUzAaLgDdznDgmWxUF1z flrZW8H/FnxCEB28R/a/SO51AeZ09Q7f81mOwPpN1ksi4D9oQnKye3gn/4o691NC06AA j4KvUWSLiVJmsntEmd+2D1FPRScTJjE4xrNEGPyHCRBXc+6P4Du+2KK+yj3kX97wZFMs ShWB1wxJdpNhp/Abu13kGz3rvY+2r5Dopvw2CgMoT7KDi+2HhH Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: ABy/qLb0Qt9ACO6qqGaNKbnhitrkSsQVYP5cF5O1NuxiumgW8wT2wGuX EzfV0eGz8kwQeSpYqg7W91o= X-Google-Smtp-Source: APBJJlHx+0VHPisyh8SZWWs2eRnyEXwaCvPbw6YZe7zgTsF7AJNL92ke+XyoThvokTJNM0pEHWfA5A== X-Received: by 2002:a05:6870:8a07:b0:1bf:43d2:526c with SMTP id p7-20020a0568708a0700b001bf43d2526cmr6346161oaq.15.1691073961629; Thu, 03 Aug 2023 07:46:01 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:6489:b0:1ba:cc9b:59e3 with SMTP id cz9-20020a056870648900b001bacc9b59e3ls458644oab.1.-pod-prod-03-us; Thu, 03 Aug 2023 07:45:58 -0700 (PDT) X-Received: by 2002:a05:6870:9572:b0:1b0:7c0b:7db7 with SMTP id v50-20020a056870957200b001b07c0b7db7mr19481099oal.8.1691073958172; Thu, 03 Aug 2023 07:45:58 -0700 (PDT) In-Reply-To: X-Original-Sender: ffi.appdev-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:33023 Archived-At: ------=_Part_6372_1392737859.1691073957372 Content-Type: multipart/alternative; boundary="----=_Part_6373_1024715303.1691073957372" ------=_Part_6373_1024715303.1691073957372 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable There's a pandoc plugin = =20 for Pelican, and with it you can choose a template with YAML metadata. When= =20 I set up a website with it earlier this year, I toyed with the idea of=20 writing my own SSG as a script to run with `pandoc lua`. Such a script=20 could read configuration files in YAML or JSON, find Markdown or files to= =20 process, use `pandoc.read` to parse them and `pandoc.write` to write them.= =20 The file's metadata is accessible to the script after `pandoc.read`, so it= =20 could be used to select a template. The advantage to writing an SSG this=20 way is that it would be much faster than invoking the pandoc executable=20 once for each file. However, existing SSGs have knowledge built into them= =20 about Web technologies and issues like SEO, and it would take time and=20 study to replicate those. So while I really liked the idea of a `pandoc=20 lua` SSG, I couldn't justify spending the time to build one. On Thursday, August 3, 2023 at 3:11:42=E2=80=AFAM UTC-4 JJ wrote: > > I'd need more information about what exactly you're trying to do. > > Oh, I've just been playing around with using pandoc as an SSG > ("including" my website's header across pages) to get a sense for how > it works. (yes i know, there are nice frameworks like hakyll - this is > very much just for learning!). A Lua filter seems nice. > > > html4 and html5 are separate output formats (but `html` defaults to=20 > `html5`). That's why. The templates are a bit different. > > Interesting, the behavior I'm seeing might be a bug then. Only > `default.html5` works as a default HTML template, placing > `default.html` in `data-dir/templates/` does not override anything. > Then also only files ending in `.html`, not `.html5`, seem to be > referenceable without the extension with the template flag (ex. --to > html --template "funky" only works if a `funky.html` exists, not > `funky.html5`). > > On Wed, Aug 2, 2023 at 9:23=E2=80=AFAM John MacFarlane =20 > wrote: > > > > > > > > > On Aug 1, 2023, at 11:16 PM, JJ wrote: > > > > > > Hello, I've been acquainting myself with pandoc for the past few days= . > > > It's quite neat. I particularly do like pandoc's markdown flavour: > > > it's everything I've ever wanted out of such an extension! I had some > > > questions that I've been unable to find answers to in the manpage or > > > elsewhere, however. > > > > > > Is it possible to specify a template that pandoc is to use in a YAML > > > metadata block? Presumably this would only work with --standalone. > > > I've attempted `template: ` after seeing it elsewhere and hoping it > > > may work, but no dice. This seems like a common enough use case that > > > I'd imagine there is an option I am missing: or perhaps people on thi= s > > > mailing list have external solutions. (though I was hoping to avoid > > > the use of sed: for no reason other than I've only had to use pandoc > > > in my script so far, which has been quite neat) > > > > No. You can use a defaults file for this. We try to separate metadata= =20 > from processing instructions. > > > > > Also, what is best practice for "including" HTML fragments in pandoc? > > > I've found nothing in pandoc for this purpose so far - which, well, > > > makes a lot of sense. I was planning on first trying to rework things > > > to rely entirely on templates, and then in the event of failure just > > > sed-ing it up. But I harbour some concerns about accidentally > > > replacing text strings or code blocks. > > > > I'd need more information about what exactly you're trying to do. In th= e=20 > template, you could include a variable and then populate it from a file= =20 > using --variable myvar=3D$(cat myfile.html). In the document itself, ther= e's=20 > no built-in way to do this, but you could use a small Lua filter to repla= ce=20 > some element of the text (say, a code block marked with the file name to = be=20 > included) with raw HTML from a file, which would be passed on unmolested = to=20 > the output. > > > > > Also also I am curious: what is the background behind *default* html > > > templates needing the .html5 extension, but regular html templates > > > using .html? This threw me for a bit of a loop for a bit. > > > > html4 and html5 are separate output formats (but `html` defaults to=20 > `html5`). That's why. The templates are a bit different. > > > > > > > -- JJ > > > > > > -- > > > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > > > To unsubscribe from this group and stop receiving emails from it, sen= d=20 > an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/CABHcm%3Dpt_xyOKPCvieJH-= QNvArZnCosb_h7xp4g_0RNJ0EECgQ%40mail.gmail.com > . > > > > -- > > You received this message because you are subscribed to the Google=20 > Groups "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send= =20 > an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit=20 > https://groups.google.com/d/msgid/pandoc-discuss/6CAC3AED-3628-4F25-BBB9-= D3CEA9CECA36%40gmail.com > . > --=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/4a3a505c-cd43-4582-b098-ce27523a6ce8n%40googlegroups.com. ------=_Part_6373_1024715303.1691073957372 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable There's a pand= oc plugin for Pelican, and with it you can choose a template with YAML = metadata. When I set up a website with it earlier this year, I toyed with t= he idea of writing my own SSG as a script to run with `pandoc lua`. Such a = script could read configuration files in YAML or JSON, find Markdown or fil= es to process, use `pandoc.read` to parse them and `pandoc.write` to write = them. The file's metadata is accessible to the script after `pandoc.read`, = so it could be used to select a template. The advantage to writing an SSG t= his way is that it would be much faster than invoking the pandoc executable= once for each file. However, existing SSGs have knowledge built into them = about Web technologies and issues like SEO, and it would take time and stud= y to replicate those. So while I really liked the idea of a `pandoc lua` SS= G, I couldn't justify spending the time to build one.

On Thursday, August= 3, 2023 at 3:11:42=E2=80=AFAM UTC-4 JJ wrote:
> I'd need more information about= what exactly you're trying to do.

Oh, I've just been playing around with using pandoc as an SSG
("including" my website's header across pages) to get a s= ense for how
it works. (yes i know, there are nice frameworks like hakyll - this is
very much just for learning!). A Lua filter seems nice.

> html4 and html5 are separate output formats (but `html` defaults t= o `html5`). That's why. The templates are a bit different.

Interesting, the behavior I'm seeing might be a bug then. Only
`default.html5` works as a default HTML template, placing
`default.html` in `data-dir/templates/` does not override anything.
Then also only files ending in `.html`, not `.html5`, seem to be
referenceable without the extension with the template flag (ex. --to
html --template "funky" only works if a `funky.html` exists, = not
`funky.html5`).

On Wed, Aug 2, 2023 at 9:23=E2=80=AFAM John MacFarlane <fiddlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
>
> > On Aug 1, 2023, at 11:16 PM, JJ <j...-pl4xscvadcE@public.gmane.org> wrote:
> >
> > Hello, I've been acquainting myself with pandoc for the p= ast few days.
> > It's quite neat. I particularly do like pandoc's mark= down flavour:
> > it's everything I've ever wanted out of such an exten= sion! I had some
> > questions that I've been unable to find answers to in the= manpage or
> > elsewhere, however.
> >
> > Is it possible to specify a template that pandoc is to use in= a YAML
> > metadata block? Presumably this would only work with --standa= lone.
> > I've attempted `template: ` after seeing it elsewhere and= hoping it
> > may work, but no dice. This seems like a common enough use ca= se that
> > I'd imagine there is an option I am missing: or perhaps p= eople on this
> > mailing list have external solutions. (though I was hoping to= avoid
> > the use of sed: for no reason other than I've only had to= use pandoc
> > in my script so far, which has been quite neat)
>
> No. You can use a defaults file for this. We try to separate met= adata from processing instructions.
>
> > Also, what is best practice for "including" HTML fr= agments in pandoc?
> > I've found nothing in pandoc for this purpose so far - wh= ich, well,
> > makes a lot of sense. I was planning on first trying to rewor= k things
> > to rely entirely on templates, and then in the event of failu= re just
> > sed-ing it up. But I harbour some concerns about accidentally
> > replacing text strings or code blocks.
>
> I'd need more information about what exactly you're trying= to do. In the template, you could include a variable and then populate it= from a file using --variable myvar=3D$(cat myfile.html). In the document i= tself, there's no built-in way to do this, but you could use a small Lu= a filter to replace some element of the text (say, a code block marked with= the file name to be included) with raw HTML from a file, which would be pa= ssed on unmolested to the output.
>
> > Also also I am curious: what is the background behind *defaul= t* html
> > templates needing the .html5 extension, but regular html temp= lates
> > using .html? This threw me for a bit of a loop for a bit.
>
> html4 and html5 are separate output formats (but `html` defaults t= o `html5`). That's why. The templates are a bit different.
>
>
> > -- JJ
> >
> > --
> > You received this message because you are subscribed to the G= oogle Groups "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails from= it, send an email to pandoc-dis= cus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
> > To view this discussion on the web visit https://groups.google.com/= d/msgid/pandoc-discuss/CABHcm%3Dpt_xyOKPCvieJH-QNvArZnCosb_h7xp4g_0RNJ0EECg= Q%40mail.gmail.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-discus..= .@googlegroups.com.
> To view this discussion on the web visit ht= tps://groups.google.com/d/msgid/pandoc-discuss/6CAC3AED-3628-4F25-BBB9-D3CE= A9CECA36%40gmail.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/4a3a505c-cd43-4582-b098-ce27523a6ce8n%40googlegroups.= com.
------=_Part_6373_1024715303.1691073957372-- ------=_Part_6372_1392737859.1691073957372--