From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/32005 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: bapt a Newsgroups: gmane.text.pandoc Subject: latex macros expansion as a Lua filter? Date: Tue, 17 Jan 2023 11:17:38 -0800 (PST) Message-ID: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_14706_1787127611.1673983058117" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3100"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDG3FYUYQUCBBU7ITOPAMGQEP5E3ZWI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Tue Jan 17 20:17:42 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-ot1-f58.google.com ([209.85.210.58]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pHrSo-0000hE-IG for gtp-pandoc-discuss@m.gmane-mx.org; Tue, 17 Jan 2023 20:17:42 +0100 Original-Received: by mail-ot1-f58.google.com with SMTP id x26-20020a9d6d9a000000b00672c2f06716sf17037970otp.21 for ; Tue, 17 Jan 2023 11:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:sender:from:to:cc :subject:date:message-id:reply-to; bh=1uG4oapTMSXQgka/yQczawRdzFeGbPyz0+LSg6Nwy6o=; b=FpgoOyXI30ALZ+duDC+I1CvVG0I/iMhdyl+rl0PHtpCfeT1cYNK/EoQg8eV0BRPiae IxDdEqBlWywUB7JArgaSVmE//CBfoD+CujorHLSyaLxK29nwZYRQwUhVj8BtnWF/hFwJ mFP3JzRLRWppZFZnvaTv5nY0nvuwnU6wppn3YVm38bX5UGIvuId3NZrWzf+vRoH0p69k vPrySgWie9Qfdufs4tv1Wn4c/JIBb62MlQU56v7gg1A7cpiv3cI+9bUBzuY+uWxhFV/L cLHU78k35c5RoF8tjvmWzrwHZvf8bpHs7gvbGCLQvuhud6BowuHXRJgNepSRhe9kL5xd 9TcQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:message-id:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=1uG4oapTMSXQgka/yQczawRdzFeGbPyz0+LSg6Nwy6o=; b=pKVzaz+xr4WK7+624majSxEjdWJZ/xnfzKMe5CWkGe2qUht1BCHNCvmtNhNB3k+IMv kuwydusF1uyeamM37QlZaqUkxkwdTOFFDdVI/7hPzbUCWW6dVTko2EFzl/xZKwejF+jW 1rLstXwMkyIS3exYER8m7hACaQVIM8v6zEYQGLuE+toJIvwQlqabfge2d1K6Jgda6CnY teI58+4D5JJ3BWGMuR7p5RqMlbnoTZHe3sLuIl2IwtXJxDNW3Un3R53ECLEqHNByvmUT amDPbHSE3EC3x9vGWpekcTdzlc+HtckAUAQUdlyZLYu7UrR9rj9104P9g2xaBS7pFVpL E/Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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:message-id:to:from:date :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=1uG4oapTMSXQgka/yQczawRdzFeGbPyz0+LSg6Nwy6o=; b=bVforyUB5QV2f/wufa04OUDuZO8tU+l6SSlTn6vlHemDHnniJx2c1HwX1eN3oWRsAB wfSOfFwLtQdZxw3AXkPnPtyBlZt4HG0onmg9rtlI9wPhv3TnRI26oI6YWC3kiN+Vs0mA mqi0fQT8/m1IkFZnyPqkJmAjT0Yf3X5AC/+FA0GejbTi3zNqiqPZ/R60a4cQpxlNTdQ6 apfbQZNVo1XynLxeZigYnLGgcEdeuhiLmY8C6WNclEpX/uzRnHJfzWR/fAWDQFvtv0Ff F9GihJHPTwQNE5vyOjr5unyq5AC13R086hhGaTxUoHFzHmAActvFZXqLC/O+5bAjShE/ WAkA== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AFqh2koaSf9ITWiuVZktynOroD110g2+tf69VEE51R4UlWkTqapkLIWV uWdRGgTcHY1C8/vrtaXqNDo= X-Google-Smtp-Source: AMrXdXueMhvGxWiWfOVm/GBbZCoxdyxU4iPhUKDpx5D8EmWQCeDRXYNXJDCvDWhSPY4h9A3mCj2lhg== X-Received: by 2002:a05:6870:6693:b0:15b:b957:7a9f with SMTP id ge19-20020a056870669300b0015bb9577a9fmr284298oab.142.1673983061287; Tue, 17 Jan 2023 11:17:41 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6870:93d5:b0:14c:767d:db2e with SMTP id c21-20020a05687093d500b0014c767ddb2els6727809oal.4.-pod-prod-gmail; Tue, 17 Jan 2023 11:17:39 -0800 (PST) X-Received: by 2002:a05:6871:8506:b0:15f:178c:771f with SMTP id sx6-20020a056871850600b0015f178c771fmr314023oab.43.1673983058761; Tue, 17 Jan 2023 11:17:38 -0800 (PST) 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:32005 Archived-At: ------=_Part_14706_1787127611.1673983058117 Content-Type: multipart/alternative; boundary="----=_Part_14707_1399557922.1673983058117" ------=_Part_14707_1399557922.1673983058117 Content-Type: text/plain; charset="UTF-8" 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. ------=_Part_14707_1399557922.1673983058117 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I've found it useful in some situations= to expand all custom LaTeX macros (such as `\newcommand{\Curl}{\nabla\time= s}`, for example) in a document before rendering it.
For e= xample, with Quarto being used to produce a book in both pdf and html forma= ts, 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 th= at it renders; it doesn't work to provide it once for the whole book/websit= e).

An alternative that sounds quite robu= st would be to run something like de-macro (https://www.ctan.org/tex-archiv= e/support/de-macro) on the source document before it is rendered: the macro= s 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 ach= ieving the same thing would be easier with a Lua filter in pandoc? Presumab= ly, having already all the equations isolated in the AST makes life a bit e= asier, and I believe there is already a mechanism in pandoc to process and = expand `\newcommand` directives for non-latex output. Is this mechanism ava= ilable to a Lua filter that could be used in a Quarto workflow?
<= br />
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 pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@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.
------=_Part_14707_1399557922.1673983058117-- ------=_Part_14706_1787127611.1673983058117--