summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers/EPUB.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-01-25 21:51:26 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 21:51:26 +0100
commitfce0a60f0a85d6c3a9e7633074ecd781af08c75b (patch)
tree01480c37cc9b4c0197914266d18d54cdac997812 /src/Text/Pandoc/Writers/EPUB.hs
parent1105dd866c3d17c8be0f36b13c0fdb562ced1844 (diff)
Provide explicit separate functions for HTML 4 and 5.
* Text.Pandoc.Writers.HTML: removed writeHtml, writeHtmlString, added writeHtml4, writeHtml4String, writeHtml5, writeHtml5String. * Removed writerHtml5 from WriterOptions. * Renamed default.html template to default.html4. * "html" now aliases to "html5"; to get the old HTML4 behavior, you must now specify "-t html4".
Diffstat (limited to 'src/Text/Pandoc/Writers/EPUB.hs')
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index d6c3ff533..bd95c170e 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -59,7 +59,7 @@ import Control.Monad (mplus, when, zipWithM)
import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
, strContent, lookupAttr, Node(..), QName(..), parseXML
, onlyElems, node, ppElement)
-import Text.Pandoc.Writers.HTML ( writeHtml )
+import Text.Pandoc.Writers.HTML ( writeHtml4, writeHtml5 )
import Data.Char ( toLower, isDigit, isAlphaNum )
import Text.Pandoc.MIME (MimeType, getMimeType, extensionFromMimeType)
import Text.Blaze.Html.Renderer.Utf8 (renderHtml)
@@ -361,13 +361,15 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
: writerVariables opts
let opts' = opts{ writerEmailObfuscation = NoObfuscation
, writerSectionDivs = True
- , writerHtml5 = epub3
, writerVariables = vars
, writerHTMLMathMethod =
if epub3
then MathML Nothing
else writerHTMLMathMethod opts
, writerWrapText = WrapAuto }
+ let writeHtml = if epub3
+ then writeHtml5
+ else writeHtml4
metadata <- getEPUBMetadata opts' meta
-- cover page
@@ -376,7 +378,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
Nothing -> return ([],[])
Just img -> do
let coverImage = "media/" ++ takeFileName img
- cpContent <- renderHtml <$> (lift $ writeHtml
+ cpContent <- renderHtml <$> (lift $ writeHtml
opts'{ writerVariables = ("coverpage","true"):vars }
(Pandoc meta [RawBlock (Format "html") $ "<div id=\"cover-image\">\n<img src=\"" ++ coverImage ++ "\" alt=\"cover image\" />\n</div>"]))
imgContent <- lift $ P.readFileLazy img
@@ -484,8 +486,7 @@ pandocToEPUB opts doc@(Pandoc meta _) = do
Chapter mbnum $ walk fixInternalReferences bs)
chapters'
- let chapToEntry :: PandocMonad m => Int -> Chapter -> m Entry
- chapToEntry num (Chapter mbnum bs) =
+ let chapToEntry num (Chapter mbnum bs) =
(mkEntry (showChapter num) . renderHtml) <$>
(writeHtml opts'{ writerNumberOffset =
fromMaybe [] mbnum }