From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32438 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: John MacFarlane Newsgroups: gmane.text.pandoc Subject: Re: latex template syntax vs Lua filters Date: Mon, 3 Apr 2023 17:48:08 -0700 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.14\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_45C0092E-9234-4582-9901-2884FFFBC33F" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39346"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-X-From: pandoc-discuss+bncBDW7ZIEHTIIBBTPHVWQQMGQEO6DZQDA-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Apr 04 02:48:18 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-pg1-f185.google.com ([209.85.215.185]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pjUqQ-000A1f-9x for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 04 Apr 2023 02:48:18 +0200 Original-Received: by mail-pg1-f185.google.com with SMTP id 20-20020a630514000000b0050bed8b0b61sf8981178pgf.11 for ; Mon, 03 Apr 2023 17:48:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680569297; cv=pass; d=google.com; s=arc-20160816; b=swtLGhffroQiiF+8QzQvJQ4CDshZcptLtQ9ZqRd+CMe+oCTc/gyRkJiKYJW74OYtK2 HdgkrH1pQcQEXfiGxemuq8BS4zC6DFapWUMfzAjeMDqGrbm5YDLPPl2AeQS9wq3rw6Eb kiL3d2Re/5ee1y8YqiDI6nyHVbwF0jBRZBWzmZ2Us0uxDpmJKuCODF8Tc1oB0JuvhQqU Uxks0hmGkuh27s0S0SD9wnvvrWv07tDi1wLrIwJT/f36UWM24wYSxeyxfxZUowKSmYfq 4VSiHjM9U+wqh4LqCDi44dGqqviJ6d+dQ6h/ZovaVHlio6TQcZQ1N1lGbB8+8t7ht3fe c4+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:message-id:in-reply-to:to :references:date:subject:mime-version:from:sender:dkim-signature :dkim-signature; bh=3dD91Thw84AxZRKqA0n1cUr3xezYNIyQo51bmmifr/E=; b=1F2PIwEC5be/maV230kbIJ9eiPcZJqtwHAWRSTmqDVsRBswsU3KYvGSx6c10R9IZXL M72D+Umd11IONq3nu3GP0Yxsshm999EV6UOq0lveAdTmRm4yuihwof10e3QWGjxJ/EIG 9KZ50y0dyN/qbqmQ5VgmbJPIvpsRtIYY/X2gTnu4QS/scROXZf/eT/vy44D6lADYQkkt MiECyXD6BxziuhGy9uGYSSv18ysTNQ/7o+L8B8pWPuepY4MgDK4q9T2mOA6fa+znclwc b1GQ+0V70KvwWhRfN+YGbhJuwA7VlIu/tICE+lDatA1vkhWEb3cYgAQ6G2XZR2Nh7V+X KscA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aTIkKpe8; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) smtp.mailfrom=fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1680569297; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:message-id :in-reply-to:to:references:date:subject:mime-version:from:sender :from:to:cc:subject:date:message-id:reply-to; bh=3dD91Thw84AxZRKqA0n1cUr3xezYNIyQo51bmmifr/E=; b=C1xJB2XjzleJVBVR1JFleVbgTgnMIJmbcDLU2LShanJ0GKVaGcFHPAeThoGFL2NpM8 8q5uVdWB8ZR7G+FF3HUQ/wjiy2ubLLPIOQ9pdQz6M8vyjWq2/a1f0PxVfH5xmxMUQlr/ HE0Ktf8LWREJU7I64GROihsnfC0gHE+83uxY4Er+GVTyKpw71bTruIY8MPATr5KFgyKe 7unAnc6/Q+LzqCeR5wcm68KH3ww4rrYC07iuok4JDDEjNVloUmwBkMja+FDUFjxrSb1b 00aKeNcijq8Ve5cpJvK8OcHvgqqnaIWPivj9TlOhU/qdfm3OQcYG3X21gspNEmFdh27O Sgmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680569297; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:message-id :in-reply-to:to:references:date:subject:mime-version:from:from:to:cc :subject:date:message-id:reply-to; bh=3dD91Thw84AxZRKqA0n1cUr3xezYNIyQo51bmmifr/E=; b=Cagkckc0knoAsWKPKJcONpYzBGgeiZ3mppsstdUnjjWq7OeCWLBRiuIUg+RxD+QySu sj4p1GG4UoT+DAkLI/n+StN/wY1Q2eaT4IXvuYqXQFapB0WVdox298ug/PIiSCBR9GvE BhYL+w05ZQ12fp9nwvkr1TEMRdk8yf+acg+bjl5SjfHmS2CSs09X4POy9r9dmTu4MeX1 wqauUybBlQPuSiLsMCXZq+Et4IT2gSQV/a3awzfgQjWQhvBclLQhuoYIX2MJh4Ecbvbm /O94w4XiYwd5zc+YRmyqu/0LHm4s7Kxodoa+ZUryT2ocRkR3d6pdhxzV8bP0pm2f3Fbx m8vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680569297; 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-authentication-results:x-original-sender:message-id :in-reply-to:to:references:date:subject:mime-version:from :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=3dD91Thw84AxZRKqA0n1cUr3xezYNIyQo51bmmifr/E=; b=klxGnPG6sqtcwOQ/gHGEc8RlZ17p2F1zjNF0iDgebN7Z9eRBztNgxgu4DH3qOnK+1V +/QWRqg2pki4H5zD9N5sQsV8NS6rBWqWq4Pp6Jg0UGB7dc8ToAZ/vuchEhUu6P/ZlQ3Q AtjMTbfp0riHXWzS2hrksVcO1hgNLRNAXh3/mz96gPMkvMbuzBfA7TOeeD4ZWtzbAVlB bRYGLY6ueHiH8dW/o9cun23XUXgMnM3xFHeZZy7VM7YX1ZyF76Er9Pmv1kch97elMKrz slPMI1/uF4oZbXJRzEOxK0p1+8RO1rlP Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AAQBX9dHcWxFS5l+/qKxZZl8goLLGaWJVAZji7wlekDQFXlXkWqfZ/tQ MTVIjMHfukMbWOSQvj8JpdM= X-Google-Smtp-Source: AKy350buF065Ktpb4U54+D5Dl77ECv/jfxmQJxn2jYQ1pJYoGP6/SZVKOex3dxOhVrWGIpC0T7lxzQ== X-Received: by 2002:a63:474f:0:b0:513:c7d:6ed3 with SMTP id w15-20020a63474f000000b005130c7d6ed3mr136590pgk.4.1680569296873; Mon, 03 Apr 2023 17:48:16 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a17:902:ac95:b0:199:50f5:6729 with SMTP id h21-20020a170902ac9500b0019950f56729ls11852074plr.11.-pod-prod-gmail; Mon, 03 Apr 2023 17:48:12 -0700 (PDT) X-Received: by 2002:a17:902:d4cd:b0:19e:6e29:2a8c with SMTP id o13-20020a170902d4cd00b0019e6e292a8cmr1039650plg.5.1680569292600; Mon, 03 Apr 2023 17:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680569292; cv=none; d=google.com; s=arc-20160816; b=sDXUxmoxiPUjP/JmvMSr2fPOpYB0u1d3hTGSUyUtlMNCsiv/dZIpJeeQIZ7Dd3/5Rv LvtcpV1ES0+226DfK4MKczQOC3pSH9lHjJS3/DCephxdSvXCNa9Kgk8dLl+d0ID0sCtM 02/0b+u84DAxhE0YGBTgRNA0K9WIkizF3tAFrRAB3uGTbcm96kjF/DA7BiphWBY2ZP+S lpZK15gHMLLBMk1gK5PIDJaad1c7sggfF1/RYKChEubQ6tskoTrCSP21TWPuujc2pFWO Uh+UbPxsUFNwzPUGsrOy5plhkRbQPOiOQ+1RNwJHXiEZGsij44PhwIOUWkjeFOXH+aev n6PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:in-reply-to:to:references:date:subject:mime-version:from :dkim-signature; bh=/30jkQH7xTh7lbkJoFO/tAAdpSSAs5dH/XiVdWkyfoM=; b=w2SXK0pRoRpROw34g2fMOaKOuNh6RXHX9XzKdQGXdwrp8hJRK7F/W8d6nI3XlGn7dz uzQNMCp6vKEGSC+iHcsYKBvxzAz1Y22ktdZCMCvFX+OuzjEn8msnHZAZ/xIZEgtUq74r dMoxEedjx/nLpZnH6ox0J8CKvkldv2QhwWfCNqzhSITzkaM/wVho1FosMsP0dX0xHdz7 ENnlyuH1Lu9L6/i0Q46Q2yvASQ1cePLn0LDlF8PacJgCoqtUW6qsPTmShEAasOScupGF vrMh32gyEwNner6YLsCeIZiWOe8TTgW6d8o61Rt+YMdSUpco+br+1wDtSfbRjdFH1XKu 1d/A== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aTIkKpe8; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) smtp.mailfrom=fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com. [2607:f8b0:4864:20::534]) by gmr-mx.google.com with ESMTPS id b4-20020a170902d88400b0018712ccd6e0si521635plz.2.2023.04.03.17.48.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Apr 2023 17:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) client-ip=2607:f8b0:4864:20::534; Original-Received: by mail-pg1-x534.google.com with SMTP id z18so18621502pgj.13 for ; Mon, 03 Apr 2023 17:48:12 -0700 (PDT) X-Received: by 2002:a62:1a04:0:b0:624:1ab3:da1a with SMTP id a4-20020a621a04000000b006241ab3da1amr359591pfa.29.1680569291635; Mon, 03 Apr 2023 17:48:11 -0700 (PDT) Original-Received: from smtpclient.apple (protagoras.phil.berkeley.edu. [128.32.252.45]) by smtp.gmail.com with ESMTPSA id i28-20020a63585c000000b0050bd9c8c53dsm6526902pgm.23.2023.04.03.17.48.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2023 17:48:11 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.14) X-Original-Sender: fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aTIkKpe8; spf=pass (google.com: domain of fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::534 as permitted sender) smtp.mailfrom=fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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:32438 Archived-At: --Apple-Mail=_45C0092E-9234-4582-9901-2884FFFBC33F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Partly we=E2=80=99ve been motivated by backwards compatibility =E2=80=94 ad= ding new features but not breaking the original template syntax, which goes= back 16 years or so. Why not Lua? In addition to backwards compatibility, you might have concer= ns about safety. Right now you can be confident that using a template won= =E2=80=99t launch the missiles, delete a file, or cause an infinite loop. > In fact, this can be done right now by adding a generic `$insert-author-a= ffiliation$` placeholder in the latex template, and using a Lua filter to g= enerate the corresponding data in the AST. That=E2=80=99s a good approach! Another approach would be to use a custom writer that calls the regular pan= doc writer but uses its own templating system, written in Lua or whatever y= ou like. > On Apr 3, 2023, at 2:49 PM, bapt a wrote: >=20 > Hi, >=20 > I'm curious to understand the status of / motivations for the "mini-langu= age" described in >=20 > https://pandoc.org/MANUAL.html#template-syntax >=20 > It has become quite complex, with partials, pipes, etc. presumably in res= ponse to ever-increasing needs to fine-tune the string processing and forma= tting in LaTeX templates. A rather intricate use-case I recently came acros= s is to process a list of author-affiliations from Metadata into the format= requested by a particular journal =E2=80=93 for instance: >=20 > https://github.com/quarto-journals/acs/blob/main/_extensions/acs/title.te= x#L1 >=20 > to follow instructions along those lines in the latex class: >=20 > % repeat the \author .. \affiliation etc. as needed > % \email, \thanks, \homepage, \altaffiliation all apply to the current > % author. Explanatory text should go in the []'s, actual e-mail > % address or url should go in the {}'s for \email and \homepage. > % Please use the appropriate macro foreach each type of information >=20 > % \affiliation command applies to all authors since the last > % \affiliation command. The \affiliation command should follow the > % other information > % \affiliation can be followed by \email, \homepage, \thanks as well. >=20 > I'm a bit puzzled by the design choice in pandoc templates =E2=80=93 woul= d it not be (much) easier to process variables in Lua, a fully fledged lang= uage with built-in support for string manipulation, loops, etc.? >=20 > I can imagine a partial "custom writer" of sorts that would be in charge = of producing, say, the formatted author-affiliation for a given format (lat= ex, html, etc.), by manipulating the AST in Lua. This function would be cal= led to insert the required content into the TeX file.=20 >=20 > In fact, this can be done right now by adding a generic `$insert-author-a= ffiliation$` placeholder in the latex template, and using a Lua filter to g= enerate the corresponding data in the AST. >=20 > Clearly I'm missing something =E2=80=93 there must be a good reason for t= he development of the mini-language for templates, beyond the simple scenar= ios (basic for/if constructs). I could see the value of performing simple t= asks directly in the target latex template, but when it gets as complex as = the example above I don't quite follow. >=20 > Many thanks, >=20 > baptiste >=20 >=20 >=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= email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > To view this discussion on the web visit https://groups.google.com/d/msgi= d/pandoc-discuss/d890f12c-84d1-4ab8-a836-0da8fb9c8caan%40googlegroups.com <= https://groups.google.com/d/msgid/pandoc-discuss/d890f12c-84d1-4ab8-a836-0d= a8fb9c8caan%40googlegroups.com?utm_medium=3Demail&utm_source=3Dfooter>. --=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/BCE2FA1F-296D-4C7E-9495-E4B6E1C5A885%40gmail.com. --Apple-Mail=_45C0092E-9234-4582-9901-2884FFFBC33F Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="UTF-8" Partly we=E2=80=99ve been = motivated by backwards compatibility =E2=80=94 adding new features but not = breaking the original template syntax, which goes back 16 years or so.

Why not Lua?  In addit= ion to backwards compatibility, you might have concerns about safety.  = ;Right now you can be confident that using a template won=E2=80=99t launch = the missiles, delete a file, or cause an infinite loop.

In fact, this can be done right now by adding a generic `$= insert-author-affiliation$` placeholder in the latex template, and using a = Lua filter to generate the corresponding data in the AST.

That=E2=80=99s a good approach!

Another approach would be to use a cu= stom writer that calls the regular pandoc writer but uses its own templatin= g system, written in Lua or whatever you like.


On Apr 3, = 2023, at 2:49 PM, bapt a <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Hi,

I'm curious to understand the status of / motiv= ations for the "mini-language" described in


It = has become quite complex, with partials, pipes, etc. presumably in response= to ever-increasing needs to fine-tune the string processing and formatting= in LaTeX templates. A rather intricate use-case I recently came across is = to process a list of author-affiliations from Metadata into the format requ= ested by a particular journal =E2=80=93 for instance:
=
=

to follow instructions= along those lines in the latex class:
=
% repeat the \author .. \affiliation etc. as needed
% \email, \thanks, \homepage, \altaffiliation all apply to the curre= nt
% author. Explanatory text should go in the []'s, actual e= -mail
% address or url should go in the {}'s for \email and \= homepage.
% Please use the appropriate macro foreach each typ= e of information

% \affiliation command applie= s to all authors since the last
% \affiliation command. The \= affiliation command should follow the
% other information
% \affiliation can be followed by \email, \homepage, \thanks as = well.

I'm a bit p= uzzled by the design choice in pandoc templates =E2=80=93 would it not be (= much) easier to process variables in Lua, a fully fledged language with bui= lt-in support for string manipulation, loops, etc.?
I can imagine a partial "custom writer" = of sorts that would be in charge of producing, say, the formatted author-af= filiation for a given format (latex, html, etc.), by manipulating the AST i= n Lua. This function would be called to insert the required content into th= e TeX file.

In fact, this can be done right now by adding a generic `$insert= -author-affiliation$` placeholder in the latex template, and using a Lua fi= lter to generate the corresponding data in the AST.
Clearly I'm missing something =E2=80=93 = there must be a good reason for the development of the mini-language for te= mplates, beyond the simple scenarios (basic for/if constructs). I could see= the value of performing simple tasks directly in the target latex template= , but when it gets as complex as the example above I don't quite follow.

Many= thanks,

baptiste=

<= br class=3D"">

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://grou= ps.google.com/d/msgid/pandoc-discuss/d890f12c-84d1-4ab8-a836-0da8fb9c8caan%= 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/p= andoc-discuss/BCE2FA1F-296D-4C7E-9495-E4B6E1C5A885%40gmail.com.
--Apple-Mail=_45C0092E-9234-4582-9901-2884FFFBC33F--