-- pagebreak.lua -- Converts explicit page break markers into format-specific page breaks. local DOCX_PAGEBREAK = [[ ]] local HTML_PAGEBREAK = '
' local function is_pagebreak(el) return ( (el.t == "RawBlock" and el.format == "tex" and (el.text == "\\newpage" or el.text == "\\pagebreak")) or (el.t == "Para" and #el.content == 1 and el.content[1].t == "Str" and el.content[1].text == "\f") ) end function RawBlock(el) if el.format == "tex" and (el.text == "\\newpage" or el.text == "\\pagebreak") then if FORMAT == "docx" or FORMAT == "openxml" then return pandoc.RawBlock("openxml", DOCX_PAGEBREAK) elseif FORMAT == "epub" or FORMAT == "epub3" or FORMAT == "html" or FORMAT == "html5" then return pandoc.RawBlock("html", HTML_PAGEBREAK) end end end function Para(el) if is_pagebreak(el) then if FORMAT == "docx" or FORMAT == "openxml" then return pandoc.RawBlock("openxml", DOCX_PAGEBREAK) elseif FORMAT == "epub" or FORMAT == "epub3" or FORMAT == "html" or FORMAT == "html5" then return pandoc.RawBlock("html", HTML_PAGEBREAK) end end end