I think I mentioned this recently but a useful trick when using a filter to convert most code spans/blocks into raws or something else is to use a dummy class `.code` on those which don't have any other class(es) and shouldn't be converted: ``````lua local function no_code_class (it) return it ~= 'code' end function Code (elem) -- Skip if it has any classes if 0 < #elem.classes then -- Remove the 'code' class elem.classes = elem.classes:filter(no_code_class) return elem else -- Do whatever you want with a "bare" Code e.g. return pandoc.RawInline(SOME_FORMAT, elem.text) end end `````` Den ons 29 dec. 2021 21:46bapt auguie skrev: > 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 > > . > -- 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/CADAJKhDE3NyVp%3DCDNczGtUkOd2mPjw6zdxRRdYd5xzgOKmLXNA%40mail.gmail.com.