-
I have some markdown (in Obsidian) that I'm trying to convert to Word (docx) format through pandoc. The markdown contains some html tags for AI suggested the following LUA script, which does not do anything:
Does anyone have a suggestion for how to handle these html tags within markdown? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It is always a good idea to include a sample Markdown snippet and the exact command you're running! Pandoc should parse the tags as RawInlines. Say <u>unarticulated</u> and <i>idiomatic</i> text , then this is parsed via
This Lua filter should do what you want: ---@param inlines Inlines
---@return Inlines | nil
function Inlines(inlines)
-- go back to front to avoid problems with changing indices
for i = #inlines, 1, -1 do
if inlines[i].tag == 'RawInline' and inlines[i].text == '<u>' then
for j = i + 1, #inlines, 1 do
if inlines[j].tag == 'RawInline' and inlines[j].text == '</u>' then
inlines[i] = pandoc.Underline({table.unpack(inlines, i+1, j-1)})
for _ = i+1, j, 1 do
inlines:remove(i+1)
end
return inlines
end
end
end
end
end Currently, it only handles the |
Beta Was this translation helpful? Give feedback.
It is always a good idea to include a sample Markdown snippet and the exact command you're running!
Pandoc should parse the tags as RawInlines. Say
test.md
contains, then this is parsed via
pandoc test.md -t native
into the following AST:This Lua filter should do what you want: