git.iko.soy/typeable/pandoc
on master help sign in
Changed Offline module to SelfContained, offline to makeSelfContained.
commit10b23e85b7131eb9a653296884d71a3d6b02841d authorJohn MacFarlane <jgm@berkeley.edu> dateMon 21 Nov 2011, 15:09 (15 years ago) parent1cd928b
2 files changed+13−6
pandoc.cabal+1−1 src/Text/Pandoc/Offline.hs → src/Text/Pandoc/SelfContained.hs+12−5
pandoc.cabal+1−1
@@ -268,7 +268,7 @@ Library
268268 Text.Pandoc.S5,
269269 Text.Pandoc.Templates,
270270 Text.Pandoc.Biblio,
271− Text.Pandoc.Offline
271+ Text.Pandoc.SelfContained
272272 Other-Modules: Text.Pandoc.XML,
273273 Text.Pandoc.UTF8,
274274 Text.Pandoc.MIME,
src/Text/Pandoc/Offline.hs → src/Text/Pandoc/SelfContained.hsrenamed+12−5
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818-}
1919
2020{- |
21− Module : Text.Pandoc.Offline
21+ Module : Text.Pandoc.SelfContained
2222 Copyright : Copyright (C) 2011 John MacFarlane
2323 License : GNU GPL, version 2 or above
2424
@@ -30,7 +30,7 @@ Functions for converting an HTML file into one that can be viewed
3030offline, by incorporating linked images, CSS, and scripts into
3131the HTML using data URIs.
3232-}
33−module Text.Pandoc.Offline ( offline ) where
33+module Text.Pandoc.SelfContained ( makeSelfContained ) where
3434import Text.HTML.TagSoup
3535import Network.URI (isAbsoluteURI, parseURI, escapeURIString)
3636import Network.HTTP
@@ -58,7 +58,7 @@ getItem userdata f =
5858 exists' <- doesFileExist res
5959 if exists'
6060 then B.readFile res
61− else B.readFile f -- will throw error
61+ else error $ "Could not find `" ++ f ++ "'"
6262
6363openURL :: String -> IO ByteString
6464openURL u = getResponseBody =<< simpleHTTP (getReq u)
@@ -263,8 +263,15 @@ getRaw userdata t src = do
263263 else return $ decomp raw
264264 return (result, mime)
265265
266−offline :: Maybe FilePath -> String -> IO String
267−offline userdata inp = do
266+-- | Convert HTML into self-contained HTML, incorporating images,
267+-- scripts, and CSS using data: URIs. Items specified using absolute
268+-- URLs will be downloaded; those specified using relative URLs will
269+-- be sought first relative to the working directory, then relative
270+-- to the user data directory (if the first parameter is 'Just'
271+-- a directory), and finally relative to pandoc's default data
272+-- directory.
273+makeSelfContained :: Maybe FilePath -> String -> IO String
274+makeSelfContained userdata inp = do
268275 let tags = parseTags inp
269276 out' <- mapM (convertTag userdata) tags
270277 return $ renderTagsOptions renderOptions{ optMinimize = (\t -> t == "br"