Warp math block into div block using pandoc filter #9870
-
I am using pandoc to convert markdown files to docx files, but I need to apply a separate format to the math block in markdown.
the AST should like this
However, this seems to be a pain as I have hundreds of math blocks to add, is there any way to write a filter or other ways to add custom style div? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
you could try something like function Math(el)
if el.mathtype:match 'DisplayMath' then
local kv = {}
kv['custom-style'] = 'Equations'
return pandoc.Div(el, kv)
end
end (not tested) |
Beta Was this translation helpful? Give feedback.
-
Found this solution: function Para(para)
-- if para sub el is math, then create a div with custom-style = Equations and put the para in it
if para.content[1].t == 'Math' then
local kv = {}
kv['custom-style'] = 'Equations'
return pandoc.Div(para, kv)
end
end Before
After
Works well on my markdown, thanks! |
Beta Was this translation helpful? Give feedback.
Found this solution:
Before
After