public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: bapt a <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: latex template syntax vs Lua filters
Date: Mon, 3 Apr 2023 14:49:35 -0700 (PDT)	[thread overview]
Message-ID: <d890f12c-84d1-4ab8-a836-0da8fb9c8caan@googlegroups.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2699 bytes --]

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 came 
across is to process a list of author-affiliations from Metadata into the 
format requested by a particular journal – for instance:

https://github.com/quarto-journals/acs/blob/main/_extensions/acs/title.tex#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 – would it not 
be (much) easier to process variables in Lua, a fully fledged language with 
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 using 
a Lua filter to generate the corresponding data in the AST.

Clearly I'm missing something – there must be a good reason for the 
development of the mini-language for templates, 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



-- 
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.

[-- Attachment #1.2: Type: text/html, Size: 3348 bytes --]

             reply	other threads:[~2023-04-03 21:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 21:49 bapt a [this message]
     [not found] ` <d890f12c-84d1-4ab8-a836-0da8fb9c8caan-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-04-04  0:48   ` John MacFarlane
     [not found]     ` <BCE2FA1F-296D-4C7E-9495-E4B6E1C5A885-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-04-04 13:24       ` BPJ
     [not found]         ` <CADAJKhBkxMhLAeCTOymphguqG_uHwpUyAnYC4edi=SaBkmHS6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2023-04-04 13:49           ` Albert Krewinkel
     [not found]             ` <87y1n7ab93.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2023-04-04 20:41               ` bapt a

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d890f12c-84d1-4ab8-a836-0da8fb9c8caan@googlegroups.com \
    --to=auguieba-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).