From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32439 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: BPJ Newsgroups: gmane.text.pandoc Subject: Re: latex template syntax vs Lua filters Date: Tue, 4 Apr 2023 15:24:03 +0200 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000038ac2305f882973b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40366"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBCWMVYEK54FRB66JWCQQMGQEAMHOIQY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Apr 04 15:24:15 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-il1-f191.google.com ([209.85.166.191]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pjgdy-000AKA-MW for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 04 Apr 2023 15:24:14 +0200 Original-Received: by mail-il1-f191.google.com with SMTP id z7-20020a921a47000000b0032600db79f7sf17817269ill.18 for ; Tue, 04 Apr 2023 06:24:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680614653; cv=pass; d=google.com; s=arc-20160816; b=w943Qu/IQPyRNOkAp4ExQXitQU5+yng2PSQEZoKoslvoBssHsf1M+DKgpExCSvD7QL XPCkAT4oJBtRb4DRUldqeDvvAEjENb4mmknA/+cH5LEL5t5/03a2CDhm5ypT1zVwfx1c t4EANL9Mb2lA7J/wpwWbqPXmhlccc6aLzs8NZ1+prYS5RvIQPQ+l/jdm/cDHba8NFPWm VZNVTy8ATSqGiDFXxlrucJ4VuEE77uhtFQ7RhOQRPO0yGXKecIGoByEsWY6ZlIxY03co dhPNJjnhkq7aHJeKuatLLhq0FuPhkTC7lolC73iWsty9E3/SqpR5FTKF/9xG/I4uzSp4 wixA== 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:to:subject:message-id:date :from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=RAnUMp9F8fexrq450qG4hLd6cAMISlGW4+FCIjVWvGQ=; b=w8/+H+6ao/Tk0/WPDGaOi+7c9QOQfDlJShWFpvEWrWgDRJteG0OkJnDd/vykUumlvQ ufirBahXHfiKiVDUPDiO1dpUOSxVr7L0NLjVp9T7nVbAvStna2UlvJND09n66I+qbPw2 hhTuaZknG/cqPZHCJmCx7MS3WmkzrEibw/hif0ko9qwm9X3mEJhJIj+VhV8dIUKO632M 7n9pyLMSmo+j06aPG4R19Wp7l/+j5gbV+hsxUP5Q4aLmeyDJRen8wYSEiD2NLtGXekDj 3UuqTMZkhG5dxmhj7irYbYvrbf3iHe3Yb+RVRFJrphu22ZZ+x8kIEt/0EhSRU/pCus3N QCLg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jv4Jt80I; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b2f as permitted sender) smtp.mailfrom=melroch-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=1680614653; 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:to:subject :message-id:date:from:in-reply-to:references:mime-version:sender :from:to:cc:subject:date:message-id:reply-to; bh=RAnUMp9F8fexrq450qG4hLd6cAMISlGW4+FCIjVWvGQ=; b=edhYLCQUmy3AuTPfZ0lUrVy66SFVLvG68ofJJP2NFvKDJeXUZ67l0ShqlQBdn/q+El Xq9bP9yvHDSxriQOGVb761MqsynN/talCj++3c4JUj8df/jxD1Pry5ZFIOEuF1YMtBzW 6yqwZb/braIrM/zk1D+I+MVAeGL4vwdqLJAdinh8jrdeoTJZJkxCwOzkgzdn31Ecv9L0 +0Q7O4YvduOQMubdluvfa1JaPoMyTSi5dWS01FD9ESheM4pFQZa5pejOukwkVFCN0Q8M NDRsD7xNYJWUIXNJNjtrsv0Rejz+tSxQ8gxsE5svHOQ7h6Bc99IoYGPS8xZSGt94gPoO q3pw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680614653; 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:to:subject :message-id:date:from:in-reply-to:references:mime-version:from:to:cc :subject:date:message-id:reply-to; bh=RAnUMp9F8fexrq450qG4hLd6cAMISlGW4+FCIjVWvGQ=; b=lz1Pozb6RQvTo7iza/hcg+y1Th7hQDOcP+/4iaTIDuT6i0Hg1pja83oPpI6rwbFvQO 2PLXPPa54q3hDbVKIJdkJUTBV1uniOW5UeC/M/2JYJZieMfpocjxo6tuLGpKiKAZ3R9K ix2vQdilUKKk0klZUDMWKoqygZZY1uOwtAfRd0E0D0ik4WhufuL4+O2AJjp4/tSvOUHP Ob2jdtzIrD2CW1N6EjNnVUB3zYBJEkBPZ2tv5eBGUyCM7Z9kLrNDvLVBa/aqTWR52KvY yi23lxlHyX/175yWkXmvooKXfJYAXvr2NXIR6bS2/FJK/K7J6IbKn53NQOXAg0zyGW4F +jeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680614653; 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:to:subject :message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=RAnUMp9F8fexrq450qG4hLd6cAMISlGW4+FCIjVWvGQ=; b=ta5OkwlYiUB4qVSLdC3xH9gkGY6/rMT1CxtkBOpl7UHCpxESlRDECa8hO3ZhuxD0qk tNjCgFhgofQbdTPwZmPOHSF/98ZPFL8UVCSycXVVGFkG4dvHi2Hx7eJHVJNbfs4P+0bN F3qNNes9IgDg9aB9JJ2hWwbkOCf/WfVw8k42VllxAnupFCZmuH/HLuZXLKg5rRPo+PFi uK1a/pqZTDiMYcSyOWG7IlHSBCckrRlVc//pKCHaaO8vASdyP9xWRCNXLZwMcRh3rbv+ TfZhgGp+T+xppYHjR+jwopEbhcBtCPI/ Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AAQBX9cgWmeNVLT7vbof1zqbJ187CCij08EZLH0hZD+0L2LOp+YgWJSW 2oyH4oT4IACWM34lxZmoask= X-Google-Smtp-Source: AKy350ZWo00oFI9CpF75eRDOUEsbk2qwTt1XL3iso7VhjsJmPGgq1hkso/1liw3E//XzUoQfInH2BA== X-Received: by 2002:a05:6602:2147:b0:745:5e5c:f091 with SMTP id y7-20020a056602214700b007455e5cf091mr1600847ioy.0.1680614653638; Tue, 04 Apr 2023 06:24:13 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6602:15d1:b0:74c:8f72:2953 with SMTP id f17-20020a05660215d100b0074c8f722953ls2936570iow.8.-pod-prod-gmail; Tue, 04 Apr 2023 06:24:10 -0700 (PDT) X-Received: by 2002:a05:6602:152:b0:74c:a578:e3a0 with SMTP id v18-20020a056602015200b0074ca578e3a0mr2341244iot.5.1680614650684; Tue, 04 Apr 2023 06:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680614650; cv=none; d=google.com; s=arc-20160816; b=MsaCrrakaBIz9aQiZDTesIJje372NHSb7q7dBjCWrkjs0rVEMsZ2g+8ruZPgypXtwD 5BF6s/bWHHHXlMX3BhYkHNO8yXZ45HTcRPr7xLfJKw94GjWTk+XikpgXPot12q3FLWZc trbklv5LUnqLvytERr1gU5yTIyW+LvzV5gJKUgh6x6GvPXtRerfkbcGG6Ztu/Xn+Fc5F 2wlVTtWCLogh6uJey9nbEzssgb2sjdIm16Dr1sLY8CjsBBLr6l/b3Mh5cIKMZB98DLMQ mx5HRwuayZnrj6qRiDbUGZKPcqS+IrLVJGX1WQ2l0IkR5Hvk5fs7pftbHylXXg1Ue0FG cwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Zsg1d+zxhjAbgyh4v1lCz6iuIHDFOhV9dcqBaKJvrgs=; b=iIEouaXM9cL7NM6El5XRfhrt2wfoDrWSDQJg0IkqzuKfZNbgdOzrFUpCeYp0IHbJlA YK3ETCMIQ23P1KXEVUr0EjkvO6M81r1Puq+pKuCerkfsLPn5fRSeut0ciqv+8vxd0EBO KnkZ70RD135nRNM4xrip5z4WnYnMYEOqMUJWBUU/+CIVw3x9qPJbAzwDu+gdy2FfaIIe aPO7IaP0ULsBopPWJsUiUWoX1o0ezKHLq3Prxb5D/8Ua66CNKeWqTzwEa6Ff07U8tkVZ rGkdTnc56W8GvO5qmZ6JbpwctPlHB+a6tbaD6t3A0JoJMGGfD9j/egX/zLNIAMyAr1mD IvEA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jv4Jt80I; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b2f as permitted sender) smtp.mailfrom=melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com. [2607:f8b0:4864:20::b2f]) by gmr-mx.google.com with ESMTPS id cs21-20020a056638471500b0040906bb1e15si977281jab.6.2023.04.04.06.24.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Apr 2023 06:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b2f as permitted sender) client-ip=2607:f8b0:4864:20::b2f; Original-Received: by mail-yb1-xb2f.google.com with SMTP id r187so38626766ybr.6 for ; Tue, 04 Apr 2023 06:24:10 -0700 (PDT) X-Received: by 2002:a25:778a:0:b0:b82:410e:daae with SMTP id s132-20020a25778a000000b00b82410edaaemr1575307ybc.9.1680614650062; Tue, 04 Apr 2023 06:24:10 -0700 (PDT) In-Reply-To: X-Original-Sender: melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jv4Jt80I; spf=pass (google.com: domain of melroch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::b2f as permitted sender) smtp.mailfrom=melroch-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:32439 Archived-At: --00000000000038ac2305f882973b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Also remember that a Lua (or any other programming language) program is processing instructions with embedded data/variables/text (strings) while a template is a text with variables and possibly processing instructions (loops, logic) embedded, i.e. templates are text-centric in a way programs are not. A program doing the same job as a template will be full of string concatenations and format strings[^1] which will look disconnected in a way which template text will not. This was the original use case for templates before security and separation of functions were big concerns, and it is still valid. [^1]: A format string can of course be thought of as a (low-power) template= . Den tis 4 apr. 2023 02:49John MacFarlane skrev: > 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 1= 6 > years or so. > > Why not Lua? In addition 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 in= finite > loop. > > In fact, this can be done right now by adding a generic > `$insert-author-affiliation$` placeholder in the latex template, and usin= g > 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 custom writer that calls the regular > pandoc writer but uses its own templating system, written in Lua or > whatever you like. > > > > On Apr 3, 2023, at 2:49 PM, bapt a wrote: > > Hi, > > I'm curious to understand the status of / motivations for the > "mini-language" described in > > https://pandoc.org/MANUAL.html#template-syntax > > 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 cam= e > across is to process a list of author-affiliations from Metadata into the > format requested by a particular journal =E2=80=93 for instance: > > > https://github.com/quarto-journals/acs/blob/main/_extensions/acs/title.te= x#L1 > > 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 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 > > % \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. > > 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 language wi= th > built-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-affiliation for a given format > (latex, html, etc.), by manipulating the AST in Lua. This function would = be > called to insert the required content into the TeX file. > > In fact, this can be done right now by adding a generic > `$insert-author-affiliation$` placeholder in the latex template, and usin= g > a Lua filter to generate the corresponding data in the AST. > > 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 scenari= os > (basic for/if constructs). I could see the value of performing simple tas= ks > directly in the target latex template, but when it gets as complex as the > example above I don't quite follow. > > Many thanks, > > baptiste > > > > > -- > 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/d890f12c-84d1-4ab8-a836-= 0da8fb9c8caan%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/BCE2FA1F-296D-4C7E-9495-= E4B6E1C5A885%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/CADAJKhBkxMhLAeCTOymphguqG_uHwpUyAnYC4edi%3DSaBkmHS6g%40mail= .gmail.com. --00000000000038ac2305f882973b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Also remember that a Lua (or any other programming langua= ge) program is processing instructions with embedded data/variables/text (s= trings) while a template is a text with variables and possibly processing i= nstructions (loops, logic) embedded, i.e. templates are text-centric in a w= ay programs are not. A program doing the same job as a template will be ful= l of string concatenations and format strings[^1] which will look disconnec= ted in a way which template text will not. This was the original use case f= or templates before security and separation of functions were big concerns,= and it is still valid.

[^1]: = A format string can of course be thought of as a (low-power) template.

Den tis 4 apr. 2023 02:49John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> skrev:
Partly we=E2=80=99ve been motivated by backwards compatibility =E2=80= =94 adding new features but not breaking the original template syntax, whic= h goes back 16 years or so.

Why not Lua?=C2=A0 In additi= on to backwards compatibility, you might have concerns about safety.=C2=A0 = Right now you can be confident that using a template won=E2=80=99t launch t= he 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 tem= plate, and using a Lua filter to generate the corresponding data in the AST= .

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

Another approach would be to us= e a custom writer that calls the regular pandoc writer but uses its own tem= plating system, written in Lua or whatever you like.



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

= Hi,

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

It has become quite complex, with partia= ls, pipes, etc. presumably in response to ever-increasing needs to fine-tun= e the string processing and formatting in LaTeX templates. A rather intrica= te use-case I recently came across is to process a list of author-affiliati= ons from Metadata into the format requested by a particular journal =E2=80= =93 for instance:


to follow instructions = along those lines in the latex class:

% repeat the \autho= r .. \affiliation etc. as needed
% \email, \thanks, \homepage, \altaffi= liation 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 eac= h type of information

% \affiliation command applies to all authors = since the last
% \affiliation command. The \affiliation command should f= ollow the
% other information
% \affiliation can be followed by \emai= l, \homepage, \thanks as well.

I'm a bit puzzl= ed 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 built-i= n support for string manipulation, loops, etc.?

I = can imagine a partial "custom writer" of sorts that would be in c= harge of producing, say, the formatted author-affiliation for a given forma= t (latex, html, etc.), by manipulating the AST in Lua. This function would = be called to insert the required content into the TeX file.
=
In fact, this can be done right now by adding a generic `$in= sert-author-affiliation$` placeholder in the latex template, and using a Lu= a filter to generate the corresponding data in the AST.

Clearly I'm missing something =E2=80=93 there must be a good reas= on for the development of the mini-language for templates, beyond the simpl= e 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 com= plex as the example above I don't quite follow.

Many thanks,

baptiste




--
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 pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d890f12c-8= 4d1-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 pandoc-discuss+unsubscribe-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.org= m.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/BCE2FA1F-296D-4C7E-9= 495-E4B6E1C5A885%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://group= s.google.com/d/msgid/pandoc-discuss/CADAJKhBkxMhLAeCTOymphguqG_uHwpUyAnYC4e= di%3DSaBkmHS6g%40mail.gmail.com.
--00000000000038ac2305f882973b--