Open elliottslaughter opened 3 years ago
Pandoc does the splitting of the document into chapters before the rendering phase. In the rendering phase, no output will be produced by the raw latex block, but the splitting phase still sees a block there and produces a chapter for it. We should be able to make the splitting more intelligent, though.
You can work around this by using a lua filter that removes raw TeX blocks from the AST -- this will be done prior to splitting.
untested:
function RawBlock(el)
if el.format == "tex" then return {} end
end
That's basically what I did, except I wrote the filter in Haskell. In case it helps anyone else:
{-# LANGUAGE OverloadedStrings #-}
import Text.Pandoc.Definition
import Text.Pandoc.JSON
rawTeX :: Block -> [Block]
rawTeX (RawBlock (Format "tex") _) = []
rawTeX x = [x]
main :: IO ()
main = toJSONFilter rawTeX
I find it uninuitive that Pandoc's ePub output appears to respond to raw TeX commands.
Consider the following two files. I would expect these to render effectively identically, when ePub output is chosen.
File
test.md
:Chapter 1
Text.
% Title % Author
Chapter 1
Text.
pandoc test.md -o test.epub --toc pandoc test2.md -o test2.epub --toc
mkdir test_epub mkdir test2_epub cd test_epub/ unzip ../test.epub cd ../test2_epub/ unzip ../test2.epub cd .. diff -u test_epub/EPUB/toc.ncx test2_epub/EPUB/toc.ncx
Is it possible that Pandoc is somehow applying Latex's
\mainmatter
logic in ePub output? Is this intended? (I'm pretty sure it's not documented.)My normal expectation is that raw code for a given format is applied only in that format. So I'd normally expect that putting raw TeX code into a Markdown file wouldn't affect rendering to ePub at all.
This is on macOS 11.4 with Pandoc 2.14.0.3.