From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/29868 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: bapt auguie Newsgroups: gmane.text.pandoc Subject: Re: filter to inject raw TeX command based on header attributes Date: Wed, 29 Dec 2021 21:45:59 +0100 Message-ID: References: Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000017db9705d44f0755" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35130"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To: John MacFarlane Original-X-From: pandoc-discuss+bncBDG3FYUYQUCBBEUSWOHAMGQEUEBE5HI-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Wed Dec 29 21:46:13 2021 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-il1-f192.google.com ([209.85.166.192]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n2fps-0008wW-Gx for gtp-pandoc-discuss@m.gmane-mx.org; Wed, 29 Dec 2021 21:46:12 +0100 Original-Received: by mail-il1-f192.google.com with SMTP id k1-20020a92c9c1000000b002b43128af01sf13552508ilq.15 for ; Wed, 29 Dec 2021 12:46:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1640810771; cv=pass; d=google.com; s=arc-20160816; b=DgjzcYS3pyOGqJvndWyi9u2Q+uFXb/rfpD1WrImZau7RF7QLgMdotTGJojSCIAEnFw i84j9ztseWs6EFqFlt14DXGZC0rRHxaC889ztkGhboHxdXBvXGa/wOrlalwg5Sr2Wh3K T8rKGnV9rvnPeqnwDF5JE+CiWu65rEm/F5/jr7svycclUTGs4/CkAgq5k18k8o5vdu0P jOU9DKW67to/f/uYZlCNp6M5LT7GqviEObED/GffO4neG0P45iDAk3jiD0AdTNjyNevs DVkWd/3n/YwaDuEzNJiD71mpzy4qCT9D3A+yQ+6Y7XJ4/ikUw5cHYRH8Atbmmh5h4L4J WEqg== 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:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:sender:dkim-signature :dkim-signature; bh=oaXaWf8TdGOIp5T+ei8XNzsYCR5VezryW3KZebxdShA=; b=zyGJ4YNiDrEpIB7rZIFBGpWC3Miibu5g2m2AvBm34dJi56wA73ZNZwiCZoQh2d5STV Z+mTG3KZ4oMbNdpHma8rWa58RPmrJDMko5MbgJr7Wl+Oj4F8Z7QTLGy2UeX37lDP3V8e 76hKOyqZJ2YzIoscXvMzRXVjrkUj2vFb6cBNuVddXueGeNRPsBrbZpvlWgbWlD1IlY7A xN6V1trP8KFHedgrBq6jrfav4aApLwBXdoqJG76P9FhWCl+WLK0eL9OQ9BM0Ee+ixxtD UOnA75qK2oXoqmfNFJd20qmaqLCKAj4Qrb8hVsGybwYbwpR9uqdC3r901W7aBcR94dMr VVeA== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HBwTJePw; spf=pass (google.com: domain of auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::135 as permitted sender) smtp.mailfrom=auguieba-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; h=sender:mime-version:references:in-reply-to:from:date:message-id :subject:to:cc:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=oaXaWf8TdGOIp5T+ei8XNzsYCR5VezryW3KZebxdShA=; b=MFPlFUW2Uf+VVa1MjyV2+TBCZf+AnuSkfgcwBrwUyv8nU6lO+/Y05l0Wo/5jKR1fAZ kszFNx2fTr+GFdVrihyr2eonKqxjiR2/Bc3Qr7sc63hy7uKLJznKGuWFi1GMczgPHlTE iM9ctrrqFjkpOk4tBlrHp0Wmowq3mQwDVJ8/2Xr+gJfQfnQ1Y137SV4I28HXXM1QdFzT zbOKLBqq3fB8o0ETg57CJKJUR3nt2xOco4VHPVbfFrIPfI71aWy6E/FqDhmsq+yIYl1T LWaCP/ro8iGkyg4k5uclk8Z2wATTzqaJr+jx8ASTV1xky6pSKuvRi2nhm+J3JeoDo/qE Qsmw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=oaXaWf8TdGOIp5T+ei8XNzsYCR5VezryW3KZebxdShA=; b=Y6oItDAT6psQcziTD0X9wABDu3kFwP0A8R9ayZLE26365lshf+BK2kz31+AJaX50Fk Eq9Z6Z3Y/gef8XxlG7zPVTT58HUR/BEvQlAzeKBFjD+j3WLv2RvuBRGxPqqCpcS5+rym e+L4MkEsz7h2cUlJuppejj+wntZDhCFWYBx3sEGh8zyKhR0ajlKNi3+EHdFKGMkhgCga fHwGPTYFgjEmIF4gYbqQj2kdZ+gIoe8+tDaMw3DUtsoEL6yokwb9g7XAt5kUoNuU09Sb /QID0QaVjI7mynqpYcnQR0OOuTru3pgOX3Q8L2mrt2f86oWJvtwfK9G/3ExcjBsGU0mt movA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=sender:x-gm-message-state:mime-version:references:in-reply-to:from :date:message-id:subject:to:cc:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=oaXaWf8TdGOIp5T+ei8XNzsYCR5VezryW3KZebxdShA=; b=bXPH3mhXsQlz472K9rvkNEctHbkCFwvPrWVGXE5pag3tHKZ804GxQYKf7HkGtw0N/h yDKhMNbr8sK4HCG1RL1fFVzXDqRhuqqQuqTipYZI5VjgmnWxJaTEPftdN/wL56jjiXM9 5N+E+y55zmteBuOq3Jhp+cA6TccIMgUNa8I51jRBnc4DjKpPhZZ50NF6GCwwpxOwFXIx sXTIPk0o0o8N8a4eGONvs8PJIKmz9v/bomdxWiLjRjq1CKHfIBTIX33vbidl7mXIidOi o11bhwkmZok/cl1z8gBlIpkm62HzYYU4EITJlbfTB9Ziu5CXoRAYkE1cM2H+uD2weVR8 salw== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AOAM530pvCc95hE3cHpwiBIHN9HrRb9uxha29+apvo5IcbyepvHzI8L4 bYAOCrp0Cu9isjvcvH2jxSo= X-Google-Smtp-Source: ABdhPJwwA8EK/SHeD85Gx7f/HCGZoUV40UE3ywEqVouhoLeQb6pYxp/CRbB2F49khX/Jlm/hXHpMKQ== X-Received: by 2002:a05:6e02:152b:: with SMTP id i11mr7985375ilu.188.1640810771498; Wed, 29 Dec 2021 12:46:11 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6638:12d5:: with SMTP id v21ls2364537jas.11.gmail; Wed, 29 Dec 2021 12:46:10 -0800 (PST) X-Received: by 2002:a02:c6a5:: with SMTP id o5mr13104513jan.145.1640810770231; Wed, 29 Dec 2021 12:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640810770; cv=none; d=google.com; s=arc-20160816; b=KDP8kMMkB2sICu97JXX2fAgYSXD3H5x2Xe14C8WwPdMptsReksB+osuVu5ykdvN2im S7y8xLyNuLpdOrfnO1y6p64WuGE7FjCJWbEFhJP0HpMguAw3gJx3qxcOTksUlUgHv8TI vI2PjRLatC+HCR/cYy2BKMIF+bwkpM4knczIDxr+cBW6OFfwF1fb6ucqswGnoV6ueqLY aKSTMB0xCLnEUVD/KZPtBV2muAq/S8VNoYxtYzoMKz8ALQJ4+G8wIHciU1d3g2dA5Ag2 93nCF1TgZTPPxejMu56UjwkPbNDFIQqS1WFb4kQLogNPdygRUBRnVm7q3qWTZVQ/VREt fsvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=LxYfJZ3Wbyd5Ms8iVGzr1LWVdu90tmAKo+iY0S4uQTc=; b=I5q5oLUEwXo4VcQwmtczrupdE6jhDQVMuJEI769pA/M1x/TyLOYeyrlv/G/LhMXZaW +NbUNm4+PI6TzSNMSgI1wDiVIA3IuEGcevU2WO4j8JrmB0EN4zDnMO1xOCGcynPF1paW 3cqwtsoVRmsuOnbMZhOxwH7P6zEUjl8ZEI63AO8IWDv9QNX8pbD2y1jmNP93kv3TP8OW KPN3eyyHYXXhVpMDYyOts2My8/TlfwQc+KeNwNy9ZLR1NUGCdhH4cvUqlJxXbM2eN7U7 QnZvhCr7fEbiUmrzOpuviLmk3Gc2EJufwelR2+EO9zGaVBgqQR2jb1Hojvp6yrzdAUoZ XMlA== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HBwTJePw; spf=pass (google.com: domain of auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::135 as permitted sender) smtp.mailfrom=auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Original-Received: from mail-il1-x135.google.com (mail-il1-x135.google.com. [2607:f8b0:4864:20::135]) by gmr-mx.google.com with ESMTPS id 8926c6da1cb9f-2fbfb77cf3fsi1098992173.2.2021.12.29.12.46.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Dec 2021 12:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::135 as permitted sender) client-ip=2607:f8b0:4864:20::135; Original-Received: by mail-il1-x135.google.com with SMTP id y16so17439796ilq.8 for ; Wed, 29 Dec 2021 12:46:10 -0800 (PST) X-Received: by 2002:a05:6e02:1348:: with SMTP id k8mr9479796ilr.297.1640810770060; Wed, 29 Dec 2021 12:46:10 -0800 (PST) In-Reply-To: X-Original-Sender: auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HBwTJePw; spf=pass (google.com: domain of auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org designates 2607:f8b0:4864:20::135 as permitted sender) smtp.mailfrom=auguieba-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:29868 Archived-At: --00000000000017db9705d44f0755 Content-Type: text/plain; charset="UTF-8" Excellent, I managed to adapt it and it works a charm! Thanks, b. On Wed, 29 Dec 2021 at 20:42, John MacFarlane wrote: > bapt auguie writes: > > > I would like to walk the AST, and immediately after headers with a > specific > > attribute, inject a \renewcommand{} based on the header's attributes, > such > > as (dummy example), > > > > \renewcommand\subsection[1]{\textbf{#1}} > > This is pretty easy. You would have a function > > function Header(el) > local attr = el.attributes > -- you can do attr['foo'] to get the value of the 'foo' attribute > -- now create a string with the macro: > local macro = ... > return { el, pandoc.RawBlock("latex", macro) } > end > > You can fill in the blanks. > > -- 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/CAGCXF2_r6G_sMQWmxyXKA5i29gRFLtOG5Z-WowKXkHASThsGqQ%40mail.gmail.com. --00000000000017db9705d44f0755 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Excellent, I managed to adapt it and it works a charm!

Thanks,

b.

On = Wed, 29 Dec 2021 at 20:42, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
bapt auguie <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> I would like to walk the AST, and immediately after headers with a spe= cific
> attribute, inject a \renewcommand{} based on the header's attribut= es, such
> as (dummy example),
>
> \renewcommand\subsection[1]{\textbf{#1}}

This is pretty easy.=C2=A0 You would have a function

function Header(el)
=C2=A0 local attr =3D el.attributes
=C2=A0 -- you can do attr['foo'] to get the value of the 'foo&#= 39; attribute
=C2=A0 -- now create a string with the macro:
=C2=A0 local macro =3D ...
=C2=A0 return { el, pandoc.RawBlock("latex", macro) }
end

You can fill in the blanks.

--
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/CAGCXF2_r6G_sMQWmxyXKA5i29gRFLtOG5Z-WowKX= kHASThsGqQ%40mail.gmail.com.
--00000000000017db9705d44f0755--