From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32441 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: bapt a Newsgroups: gmane.text.pandoc Subject: Re: latex template syntax vs Lua filters Date: Tue, 4 Apr 2023 13:41:54 -0700 (PDT) Message-ID: <1251527d-ba92-406f-a3e2-3009190253d3n@googlegroups.com> References: <87y1n7ab93.fsf@zeitkraut.de> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_854_236598113.1680640914946" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11553"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDG3FYUYQUCBBFEXWKQQMGQEERZPBZY-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Apr 04 22:42:00 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oa1-f64.google.com ([209.85.160.64]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pjnTb-0002kF-Dp for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 04 Apr 2023 22:41:59 +0200 Original-Received: by mail-oa1-f64.google.com with SMTP id 586e51a60fabf-17abfe9fd10sf17678201fac.0 for ; Tue, 04 Apr 2023 13:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; t=1680640918; 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=Yw4VKJfXXak+sRoaI/A9d5JOtsFG0xx9WO8Knlx6+oA=; b=A2qptZ12MiJJ0RSyhoNSL15vFevc6zNyAzkZgNsIFsyRHAa3r/9WDCLmyz3kiCZQu8 N+TXbUP1PLYH9LcHAG3Xi+gEtQLkUY7yNuv4S6xCG6HImRwA8hbWl2VJlQOq1oXGxUh4 Dw33rPqOtVI1arYfRKfRScWTH/fFP5mpAqimmEja8OQTc3obBEC73+l1v06Hak9qyeRZ wCobg109SxtQ9jiJWTl97Wud+GIsXaiNkeaxXGnyClL0ioHCfwoOqv4ebM5TlgOqGRG0 stHpSsuyj8Ri4K3ttmMP4Of7pbt32e5OAhek6ASwDkkxUihxQRRh0nu2izqKAt/rZM/7 XOQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680640918; 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=Yw4VKJfXXak+sRoaI/A9d5JOtsFG0xx9WO8Knlx6+oA=; b=MWNZvH2ou406zsyL9/Dn+eenM2coD9dDenvm8RZBGftw5c7a1HXcEae744yfTc/6/q OEQOJOgz7ek/Xp+PMMpJAKJZuVjBk4pkhHC3lo1qmOtbX9jc1sb6Lqr1thXclwDeOd8v gR2di2xE+cZznml3sWD1ZLnlkISlXD/DYI1Qrw7CzZTXFkDA64+e9kPZxnsgHdXJ2n9L hTvZBMsfcWLzbHqZqg+Jr2jo9M0Y8oO+ik7R7YN/rJmK7WOWsqp8e/7RVLNFfuWmB36V mp1IVpVa+S3bUaMVvnYbp6ZAhybbkGB8FVG9fIWcGssxzf16WvLZGYUpJ910+30unA2s gwMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680640918; 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-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=Yw4VKJfXXak+sRoaI/A9d5JOtsFG0xx9WO8Knlx6+oA=; b=owOAO0ET32IC5zzDYrVh5mswidyP4W19giG00jf2BgndqN/VRjwXC0hrOeJe+GpeQd ez10lP9+vwNfm9EjdeQF/xvAuaaizPDATWWNHBOvztdYN4julgc6bAWZHiFqbdoOX1HQ kipLS/pCCs9aPfi6ndjBMm91GB7c3uKDKsS/sX3NnqwmvgXoCgXEDOtpoYw5OS1dP6CR AUzlTmtDB/rsLQIm7gSlZRR49WexzFDCM9uokXfsLg74uVkn2KWgRqAQR5DbNLt21wyQ NaSYdm+7wRoY2ieSIboGW4bny0MIVDtFfNPmqYR4m8mVQqZ0HuM/iwcS14fgNQ8fB0H6 Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AAQBX9ekx0Gq0KsSme8HZ5fltKAA8Lv01WrwqV8GZxj2KN1U+L54+xpR KnKI2XVZqJ4eoyM2N190UGk= X-Google-Smtp-Source: AKy350aN5nMEVu3f6i8pMG3xxNE42DOsVcQ15JtOzkAO6Y6/ol5K07NHvMpofykVCUZujT+XBMkWXw== X-Received: by 2002:a05:6870:fb8b:b0:177:7c7a:fcdb with SMTP id kv11-20020a056870fb8b00b001777c7afcdbmr1942507oab.1.1680640918330; Tue, 04 Apr 2023 13:41:58 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6808:319a:b0:387:1bb5:8ef0 with SMTP id cd26-20020a056808319a00b003871bb58ef0ls4194619oib.4.-pod-prod-gmail; Tue, 04 Apr 2023 13:41:56 -0700 (PDT) X-Received: by 2002:aca:6506:0:b0:386:d50e:aa12 with SMTP id m6-20020aca6506000000b00386d50eaa12mr1273596oim.5.1680640915666; Tue, 04 Apr 2023 13:41:55 -0700 (PDT) In-Reply-To: <87y1n7ab93.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> X-Original-Sender: auguieba-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:32441 Archived-At: ------=_Part_854_236598113.1680640914946 Content-Type: multipart/alternative; boundary="----=_Part_855_233249366.1680640914946" ------=_Part_855_233249366.1680640914946 Content-Type: text/plain; charset="UTF-8" Thank you both for the additional perspective. I can see a trade-off in the relative merits of a general purpose language (e..g Lua) vs mini-DSL (templates), but for me the general language would win as soon as there's a non-trivial amount of manipulations to perform. Of course this will be a matter of personal taste more than anything (until something turns out to be impossible, and the DSL needs to be augmented). A key advantage of the programming language approach, in my view, is that any complexity can be captured inside a function. Specifically, I'm looking at the heavy pre-processing done in Quarto[^1] to thoroughly normalise the author-affiliation metadata, including tasks such as identifying unique affiliations (maybeAddAffiliation() is an example of wrapping non-trivial operations in a convenient function), grouping authors by unique affiliations with unique IDs, etc. Doing all this without the facilities afforded by Lua would seem unsurmountable to me. And then, if one has already gone 99% of the way in Lua by producing the right AST structure, it seems easiest to me to carry on with Lua and have a custom partial writer or filter insert the final \author{}...\affiliation{} strings in the output. Admittedly, this is a rather extreme situation, where a lot of manipulations need to happen between the relatively free-form metadata and the output. Best regards, baptiste [^1] https://github.com/quarto-dev/quarto-cli/blob/ad4281d71317c6a491434a080a408de2aff789a4/src/resources/filters/common/authors.lua#L346 On Wednesday, 5 April 2023 at 04:00:18 UTC+12 Albert Krewinkel wrote: > > BPJ writes: > > > A program doing the same job as a template will be full of string > > concatenations and format strings 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. > > My favorite example to reinforce this point is PHP: it's already really > easy to use PHP in HTML templates, and yet, people wrote extra template > languages in PHP (e.g., https://smarty.net) because those were more > pleasant to use. > > > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > -- 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/1251527d-ba92-406f-a3e2-3009190253d3n%40googlegroups.com. ------=_Part_855_233249366.1680640914946 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you both for the additional perspective.

<= div>I can see a trade-off in the relative merits of a general purpose langu= age (e..g Lua) vs mini-DSL (templates), but for me the general language wou= ld win as soon as there's a non-trivial amount of manipulations to perform.= Of course this will be a matter of personal taste more than anything (unti= l something turns out to be impossible, and the DSL needs to be augmented).= A key advantage of the programming language approach, in my view, is that = any complexity can be captured inside a function.

Specifically, I'm looking at the heavy pre-processing done in Quar= to[^1] to thoroughly normalise the author-affiliation metadata, including t= asks such as identifying unique affiliations (maybeAddAffiliation() is an e= xample of wrapping non-trivial operations in a convenient function), groupi= ng authors by unique affiliations with unique IDs, etc. Doing all this with= out the facilities afforded by Lua would seem unsurmountable to me. And the= n, if one has already gone 99% of the way in Lua by producing the right AST= structure, it seems easiest to me to carry on with Lua and have a custom p= artial writer or filter insert the final \author{}...\affiliation{} strings= in the output.
Admittedly, this is a rather extreme situa= tion, where a lot of manipulations need to happen between the relatively fr= ee-form metadata and the output.

Best rega= rds,

baptiste

<= br />
[^1] https://github.com/quarto-dev/quarto-cli/blob/ad4281d7= 1317c6a491434a080a408de2aff789a4/src/resources/filters/common/authors.lua#L= 346




On Wednesday, 5 Ap= ril 2023 at 04:00:18 UTC+12 Albert Krewinkel wrote:

BPJ <mel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org= > writes:

> A program doing the same job as a template will be full of string
> concatenations and format strings 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.

My favorite example to reinforce this point is PHP: it's already re= ally
easy to use PHP in HTML templates, and yet, people wrote extra template
languages in PHP (e.g., https://smarty.net) because= those were more
pleasant to use.


--=20
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124

--
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/1251527d-ba92-406f-a3e2-3009190253d3n%40googlegroups.= com.
------=_Part_855_233249366.1680640914946-- ------=_Part_854_236598113.1680640914946--