Hi,
I'd like to make use of pandoc's header attributes (
https://pandoc.org/MANUAL.html#extension-header_attributes) to inject a custom LaTeX \renewcommand{} definition in specific sections. My goal is to have a minimalist markdown file for my CV (no tables or raw LaTeX, just simple lists and #headers), and have a Lua filter identify which sections have specific formatting needs (e.g wrap inside a 3-column table), which will be taken care of by LaTeX.
Consider this input markdown,
# qualifications {#id1 .CV content=list}
## 2011 | can type, delete, copy and paste
## 2021 | can *format*, sometimes
# work in progress {#id2 .CV content=freetext}
## Beside lists, I am hoping to learn to format free text too, *someday*.
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}}
for sections with content=list and
\renewcommand\subsection[1]{\textit{#1}}
with content=freetext.
This is obviously a contrived example, the actual command I'm using is actually to split a sub-header and format it as a table (dates | job position | location) or various other tasks (e.g. changing emphasis colours for different sections etc.).
I'm not familiar enough with the pandoc AST or lua to figure this out; I looked at a related example (
noexport-subtrees.lua
) but here the situation is a bit different, as I need to create an additional element (raw tex string) and append it to the original header.
Many thanks,
baptiste