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 macros expansion as a Lua filter?
Date: Tue, 17 Jan 2023 11:17:38 -0800 (PST)	[thread overview]
Message-ID: <a5d780b9-2dcc-4cc4-bade-29bae4777811n@googlegroups.com> (raw)


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

Hi,

I've found it useful in some situations to expand all custom LaTeX macros 
(such as `\newcommand{\Curl}{\nabla\times}`, for example) in a document 
before rendering it. 
For example, with Quarto being used to produce a book in both pdf and html 
formats, the macros stored in a file `_macros.tex` are processed 
differently in the LaTeX path (simply including `_macros.tex` in the 
preamble) and in the Html version (where Mathjax needs to be given such 
macros for every page that it renders; it doesn't work to provide it once 
for the whole book/website). 

An alternative that sounds quite robust would be to run something like 
de-macro (https://www.ctan.org/tex-archive/support/de-macro) on the source 
document before it is rendered: the macros are still used for convenience 
of writing in the input file, but they get expanded explicitly before LaTeX 
or Mathjax is asked to render.

Unfortunately, de-macro is a Python script, and might be a little fragile 
as it processes whole documents with regex. I wonder if achieving the same 
thing would be easier with a Lua filter in pandoc? Presumably, having 
already all the equations isolated in the AST makes life a bit easier, and 
I believe there is already a mechanism in pandoc to process and expand 
`\newcommand` directives for non-latex output. Is this mechanism available 
to a Lua filter that could be used in a Quarto workflow?

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/a5d780b9-2dcc-4cc4-bade-29bae4777811n%40googlegroups.com.

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

             reply	other threads:[~2023-01-17 19:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-17 19:17 bapt a [this message]
     [not found] ` <a5d780b9-2dcc-4cc4-bade-29bae4777811n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-01-17 21:06   ` John MacFarlane
     [not found]     ` <2951DE27-E21B-4C3B-BFEA-BF370ECF50EA-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2023-01-18  0:50       ` bapt a
     [not found]         ` <b1e37c1b-8529-4374-b16c-bfc8f0e44213n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2023-01-18  3:54           ` John MacFarlane

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=a5d780b9-2dcc-4cc4-bade-29bae4777811n@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).