I'm trying to set up a simple custom writer going from pandoc
's markdown to latex. Here's what I have so far:
# A section
## A subsection
Heres a paragraph.
Heres another
function Header(lev, s, attr)
level_sequences = {
"section",
"subsection",
"subsubsection",
"subsubsubsection"
}
return string.format("\\%s{%s}", level_sequences[lev], s)
end
function Para(s)
return s.."\\parskip"
end
function Str(s)
return s
end
function Space()
return " "
end
As far as I understand from the docs
A writer using the classic style defines rendering functions for each element of the pandoc AST
I checked the resulting JSON from my markdown file and the only the following elements occur:
It seems to my that I've covered all the necessary elements in the AST, so I'm not sure why pandoc
complains with Error running lua: attempt to call a nil value
when I do the following:
pandoc test.md -t custom_writer.lua
Does anyone know what I'm missing in custom_writer.lua
?
I was missing a few things which are not documented:
function Header(lev, s, attr)
level_sequences = {
"section",
"subsection",
"subsubsection",
"subsubsubsection"
}
return string.format("\\%s{%s}", level_sequences[lev], s)
end
function Blocksep()
return "\\parskip"
end
function Para(s)
return s.."\\parskip"
end
function Str(s)
return s
end
function Space()
return " "
end
function Doc(body, metadata, variables)
return body
end