public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
From: John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
To: bapt auguie <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: Re: filter to inject raw TeX command based on header attributes
Date: Wed, 29 Dec 2021 11:41:27 -0800	[thread overview]
Message-ID: <m2a6gjyza0.fsf@MacBook-Pro-2.hsd1.ca.comcast.net> (raw)
In-Reply-To: <CAGCXF28DUfNvU8cVDjydiqg+TUwzOhdrWL5w5xc8Ua-MXA6BBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

bapt auguie <auguieba-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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.


  parent reply	other threads:[~2021-12-29 19:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 15:14 bapt auguie
     [not found] ` <CAGCXF28DUfNvU8cVDjydiqg+TUwzOhdrWL5w5xc8Ua-MXA6BBA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-12-29 19:41   ` John MacFarlane [this message]
     [not found]     ` <m2a6gjyza0.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2021-12-29 20:45       ` bapt auguie
     [not found]         ` <CAGCXF2_r6G_sMQWmxyXKA5i29gRFLtOG5Z-WowKXkHASThsGqQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-12-31 11:52           ` BPJ

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=m2a6gjyza0.fsf@MacBook-Pro-2.hsd1.ca.comcast.net \
    --to=jgm-tvlzxgkolnx2fbvcvol8/a@public.gmane.org \
    --cc=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).