git.iko.soy/typeable/pandoc
on master help sign in
Allow wildcards in `--epub-embed-font` arguments.
e32227fJohn MacFarlane
README+6−3
@@ -608,9 +608,12 @@ Options affecting specific writers
608
608
609`--epub-embed-font=`*FILE*
609`--epub-embed-font=`*FILE*
610: Embed the specified font in the EPUB. This option can be repeated
610: Embed the specified font in the EPUB. This option can be repeated
611− to embed multiple fonts. To use embedded fonts, you
611+ to embed multiple fonts. Wildcards can also be used: for example,
612+ `DejaVuSans-*.ttf`. However, if you use wildcards on the command
613+ line, be sure to escape them or put the whole filename in single quotes,
614+ to prevent them from being interpreted by the shell. To use the
612− will need to add declarations like the following to your CSS (see
615+ embedded fonts, you will need to add declarations like the following
613− `--epub-stylesheet`):
616+ to your CSS (see `--epub-stylesheet`):
614
617
615 @font-face {
618 @font-face {
616 font-family: DejaVuSans;
619 font-family: DejaVuSans;
pandoc.cabal+2−1
@@ -253,7 +253,8 @@ Library
253 haddock-library >= 1.1 && < 1.3,
253 haddock-library >= 1.1 && < 1.3,
254 old-time,
254 old-time,
255 deepseq-generics >= 0.1 && < 0.2,
255 deepseq-generics >= 0.1 && < 0.2,
256− JuicyPixels >= 3.1.6.1 && < 3.3
256+ JuicyPixels >= 3.1.6.1 && < 3.3,
257+ filemanip >= 0.3 && < 0.4
257 if flag(old-locale)
258 if flag(old-locale)
258 Build-Depends: old-locale >= 1 && < 1.1,
259 Build-Depends: old-locale >= 1 && < 1.1,
259 time >= 1.2 && < 1.5
260 time >= 1.2 && < 1.5
src/Text/Pandoc/Writers/EPUB.hs+9−2
@@ -36,6 +36,7 @@ import Data.List ( isPrefixOf, isInfixOf, intercalate )
36import System.Environment ( getEnv )
36import System.Environment ( getEnv )
37import Text.Printf (printf)
37import Text.Printf (printf)
38import System.FilePath ( takeExtension, takeFileName )
38import System.FilePath ( takeExtension, takeFileName )
39+import System.FilePath.Glob ( namesMatching )
39import qualified Data.ByteString.Lazy as B
40import qualified Data.ByteString.Lazy as B
40import qualified Data.ByteString.Lazy.Char8 as B8
41import qualified Data.ByteString.Lazy.Char8 as B8
41import qualified Text.Pandoc.UTF8 as UTF8
42import qualified Text.Pandoc.UTF8 as UTF8
@@ -57,7 +58,7 @@ import Text.Pandoc.Options ( WriterOptions(..)
57import Text.Pandoc.Definition
58import Text.Pandoc.Definition
58import Text.Pandoc.Walk (walk, walkM)
59import Text.Pandoc.Walk (walk, walkM)
59import Control.Monad.State (modify, get, execState, State, put, evalState)
60import Control.Monad.State (modify, get, execState, State, put, evalState)
60−import Control.Monad (foldM, mplus, liftM)
61+import Control.Monad (foldM, mplus, liftM, when)
61import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
62import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
62 , strContent, lookupAttr, Node(..), QName(..), parseXML
63 , strContent, lookupAttr, Node(..), QName(..), parseXML
63 , onlyElems, node, ppElement)
64 , onlyElems, node, ppElement)
@@ -387,8 +388,14 @@ writeEPUB opts doc@(Pandoc meta _) = do
387 picEntries <- foldM readPicEntry [] pics
388 picEntries <- foldM readPicEntry [] pics
388
389
389 -- handle fonts
390 -- handle fonts
391+ let matchingGlob f = do
392+ xs <- namesMatching f
393+ when (null xs) $
394+ warn $ f ++ " did not match any font files."
395+ return xs
390 let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f
396 let mkFontEntry f = mkEntry (takeFileName f) `fmap` B.readFile f
391− fontEntries <- mapM mkFontEntry $ writerEpubFonts opts'
397+ fontFiles <- concat <$> mapM matchingGlob (writerEpubFonts opts')
398+ fontEntries <- mapM mkFontEntry fontFiles
392
399
393 -- set page progression direction attribution
400 -- set page progression direction attribution
394 let progressionDirection = case epubPageDirection metadata of
401 let progressionDirection = case epubPageDirection metadata of