diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-05 13:00:12 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-01-05 13:00:12 -0800 |
commit | 0cc9504796849e017d90ef05b8183bee94ea1972 (patch) | |
tree | 1ba05fdc4002a5f719eac26dfbe371a2daac81e6 /src/Text/Pandoc | |
parent | ea3eaaa55356d2f799c1ab5a96f9658e8ceaca97 (diff) | |
download | pandoc-0cc9504796849e017d90ef05b8183bee94ea1972.tar.gz |
EPUB changes.
* Epub writer now exports writeEPUB, not writeEPUB2 and writeEPUB3.
* Options now exports EPUBVersion
* WriterOptions now includes writerEpubVersion.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Options.hs | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/EPUB.hs | 16 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index d0801da3f..f4ab0d2b4 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -36,6 +36,7 @@ module Text.Pandoc.Options ( Extension(..) , CiteMethod (..) , ObfuscationMethod (..) , HTMLSlideVariant (..) + , EPUBVersion (..) , WriterOptions (..) , def , isEnabled @@ -173,6 +174,8 @@ instance Default ReaderOptions -- Writer options -- +data EPUBVersion = EPUB2 | EPUB3 deriving (Eq, Show, Read) + data HTMLMathMethod = PlainMath | LaTeXMathML (Maybe String) -- url of LaTeXMathML.js | JsMath (Maybe String) -- url of jsMath load script @@ -234,6 +237,7 @@ data WriterOptions = WriterOptions , writerHighlightStyle :: Style -- ^ Style to use for highlighting , writerSetextHeaders :: Bool -- ^ Use setext headers for levels 1-2 in markdown , writerTeXLigatures :: Bool -- ^ Use tex ligatures quotes, dashes in latex + , writerEpubVersion :: Maybe EPUBVersion -- ^ Nothing or EPUB version , writerEpubMetadata :: String -- ^ Metadata to include in EPUB , writerEpubStylesheet :: Maybe String -- ^ EPUB stylesheet specified at command line , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed @@ -274,6 +278,7 @@ instance Default WriterOptions where , writerHighlightStyle = pygments , writerSetextHeaders = True , writerTeXLigatures = True + , writerEpubVersion = Nothing , writerEpubMetadata = "" , writerEpubStylesheet = Nothing , writerEpubFonts = [] diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs index fc4df02b7..b8a4bf1c6 100644 --- a/src/Text/Pandoc/Writers/EPUB.hs +++ b/src/Text/Pandoc/Writers/EPUB.hs @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Conversion of 'Pandoc' documents to EPUB. -} -module Text.Pandoc.Writers.EPUB ( writeEPUB2, writeEPUB3 ) where +module Text.Pandoc.Writers.EPUB ( writeEPUB ) where import Data.IORef import Data.Maybe ( fromMaybe, isNothing ) import Data.List ( isInfixOf, intercalate ) @@ -58,20 +58,12 @@ import Prelude hiding (catch) import Control.Exception (catch, SomeException) import Text.Blaze.Html.Renderer.Utf8 (renderHtml) -data EPUBVersion = EPUB2 | EPUB3 deriving Eq - -writeEPUB2, writeEPUB3 :: WriterOptions -- ^ Writer options - -> Pandoc -- ^ Document to convert - -> IO B.ByteString -writeEPUB2 = writeEPUB EPUB2 -writeEPUB3 = writeEPUB EPUB3 - -- | Produce an EPUB file from a Pandoc document. -writeEPUB :: EPUBVersion - -> WriterOptions -- ^ Writer options +writeEPUB :: WriterOptions -- ^ Writer options -> Pandoc -- ^ Document to convert -> IO B.ByteString -writeEPUB version opts doc@(Pandoc meta _) = do +writeEPUB opts doc@(Pandoc meta _) = do + let version = maybe EPUB2 id (writerEpubVersion opts) let epub3 = version == EPUB3 epochtime <- floor `fmap` getPOSIXTime let mkEntry path content = toEntry path epochtime content |