git.iko.soy/typeable/pandoc
on master help sign in
Removed writerSourceURL, add source URL to common state.

Removed `writerSourceURL` from `WriterOptions` (API change). Added `stSourceURL` to `CommonState`. It is set automatically by `setInputFiles`. Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`. The type of `getInputFiles` has changed; it now returns `[FilePath]` instead of `Maybe [FilePath]`. Functions in Class that formerly took the source URL as a parameter now have one fewer parameter (`fetchItem`, `downloadOrRead`, `setMediaResource`, `fillMediaBag`). Removed `WriterOptions` parameter from `makeSelfContained` in `SelfContained`.

commitf3a80034fff41a8b0c13519fa13bed794db1b8d2 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 30 Sep 2017, 16:07 (9 years ago) parent9b7d652
17 files changed+118−123
src/Text/Pandoc/App.hs+8−17 src/Text/Pandoc/Class.hs+37−17 src/Text/Pandoc/Lua/PandocModule.hs+2−4 src/Text/Pandoc/Options.hs−2 src/Text/Pandoc/PDF.hs+3−4 src/Text/Pandoc/Readers/RST.hs+1−1 src/Text/Pandoc/Readers/Txt2Tags.hs+2−8 src/Text/Pandoc/SelfContained.hs+54−56 src/Text/Pandoc/Writers/Docx.hs+1−1 src/Text/Pandoc/Writers/EPUB.hs+1−1 src/Text/Pandoc/Writers/FB2.hs+1−1 src/Text/Pandoc/Writers/ICML.hs+1−1 src/Text/Pandoc/Writers/ODT.hs+1−1 src/Text/Pandoc/Writers/RTF.hs+1−1 test/Tests/Readers/Muse.hs+2−4 test/Tests/Readers/Txt2Tags.hs+2−4 test/pandoc.tix+1
src/Text/Pandoc/App.hs+8−17
@@ -78,7 +78,8 @@ import Text.Pandoc.Builder (setMeta)
7878import Text.Pandoc.Class (PandocIO, extractMedia, fillMediaBag, getLog,
7979 setResourcePath, getMediaBag, setTrace, report,
8080 setUserDataDir, readFileStrict, readDataFile,
81− readDefaultDataFile, setTranslations)
81+ readDefaultDataFile, setTranslations,
82+ setInputFiles, setOutputFile)
8283import Text.Pandoc.Highlighting (highlightingStyles)
8384import Text.Pandoc.BCP47 (parseBCP47, Lang(..))
8485import Text.Pandoc.Lua (runLuaFilter, LuaException(..))
@@ -169,14 +170,13 @@ pdfWriterAndProg mWriter mEngine = do
169170
170171convertWithOpts :: Opt -> IO ()
171172convertWithOpts opts = do
172− let args = optInputFiles opts
173173 let outputFile = fromMaybe "-" (optOutputFile opts)
174174 let filters = optFilters opts
175175 let verbosity = optVerbosity opts
176176
177177 when (optDumpArgs opts) $
178178 do UTF8.hPutStrLn stdout outputFile
179− mapM_ (UTF8.hPutStrLn stdout) args
179+ mapM_ (UTF8.hPutStrLn stdout) (optInputFiles opts)
180180 exitSuccess
181181
182182 epubMetadata <- case optEpubMetadata opts of
@@ -197,7 +197,7 @@ convertWithOpts opts = do
197197 let filters' = if needsCiteproc then "pandoc-citeproc" : filters
198198 else filters
199199
200− let sources = case args of
200+ let sources = case optInputFiles opts of
201201 [] -> ["-"]
202202 xs | optIgnoreArgs opts -> ["-"]
203203 | otherwise -> xs
@@ -261,15 +261,6 @@ convertWithOpts opts = do
261261 _ -> e
262262
263263 let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput
264− let sourceURL = case sources of
265− [] -> Nothing
266− (x:_) -> case parseURI x of
267− Just u
268− | uriScheme u `elem` ["http:","https:"] ->
269− Just $ show u{ uriQuery = "",
270− uriFragment = "" }
271− _ -> Nothing
272−
273264 let addStringAsVariable varname s vars = return $ (varname, s) : vars
274265
275266 highlightStyle <- lookupHighlightStyle $ optHighlightStyle opts
@@ -347,6 +338,8 @@ convertWithOpts opts = do
347338
348339 runIO' $ do
349340 setUserDataDir datadir
341+ setInputFiles (optInputFiles opts)
342+ setOutputFile (optOutputFile opts)
350343
351344 variables <-
352345 withList (addStringAsVariable "sourcefile")
@@ -449,7 +442,6 @@ convertWithOpts opts = do
449442 , writerColumns = optColumns opts
450443 , writerEmailObfuscation = optEmailObfuscation opts
451444 , writerIdentifierPrefix = optIdentifierPrefix opts
452− , writerSourceURL = sourceURL
453445 , writerHtmlQTags = optHtmlQTags opts
454446 , writerTopLevelDivision = optTopLevelDivision opts
455447 , writerListings = optListings opts
@@ -509,7 +501,7 @@ convertWithOpts opts = do
509501 setResourcePath (optResourcePath opts)
510502 doc <- sourceToDoc sources >>=
511503 ( (if isJust (optExtractMedia opts)
512− then fillMediaBag (writerSourceURL writerOptions)
504+ then fillMediaBag
513505 else return)
514506 >=> return . flip (foldr addMetadata) metadata
515507 >=> applyLuaFilters datadir (optLuaFilters opts) format
@@ -545,8 +537,7 @@ convertWithOpts opts = do
545537 if optSelfContained opts && htmlFormat
546538 -- TODO not maximally efficient; change type
547539 -- of makeSelfContained so it works w/ Text
548− then T.pack <$> makeSelfContained writerOptions
549− (T.unpack output)
540+ then T.pack <$> makeSelfContained (T.unpack output)
550541 else return output
551542
552543type Transform = Pandoc -> Pandoc
src/Text/Pandoc/Class.hs+37−17
@@ -66,7 +66,9 @@ module Text.Pandoc.Class ( PandocMonad(..)
6666 , getUserDataDir
6767 , fetchItem
6868 , getInputFiles
69+ , setInputFiles
6970 , getOutputFile
71+ , setOutputFile
7072 , setResourcePath
7173 , getResourcePath
7274 , PandocIO(..)
@@ -251,12 +253,29 @@ insertMedia fp mime bs = do
251253 let mb' = MB.insertMedia fp mime bs mb
252254 setMediaBag mb'
253255
254−getInputFiles :: PandocMonad m => m (Maybe [FilePath])
256+getInputFiles :: PandocMonad m => m [FilePath]
255257getInputFiles = getsCommonState stInputFiles
256258
259+setInputFiles :: PandocMonad m => [FilePath] -> m ()
260+setInputFiles fs = do
261+ let sourceURL = case fs of
262+ [] -> Nothing
263+ (x:_) -> case parseURI x of
264+ Just u
265+ | uriScheme u `elem` ["http:","https:"] ->
266+ Just $ show u{ uriQuery = "",
267+ uriFragment = "" }
268+ _ -> Nothing
269+
270+ modifyCommonState $ \st -> st{ stInputFiles = fs
271+ , stSourceURL = sourceURL }
272+
257273getOutputFile :: PandocMonad m => m (Maybe FilePath)
258274getOutputFile = getsCommonState stOutputFile
259275
276+setOutputFile :: PandocMonad m => Maybe FilePath -> m ()
277+setOutputFile mbf = modifyCommonState $ \st -> st{ stOutputFile = mbf }
278+
260279setResourcePath :: PandocMonad m => [FilePath] -> m ()
261280setResourcePath ps = modifyCommonState $ \st -> st{stResourcePath = ps}
262281
@@ -289,12 +308,14 @@ data CommonState = CommonState { stLog :: [LogMessage]
289308 -- ^ A list of log messages in reverse order
290309 , stUserDataDir :: Maybe FilePath
291310 -- ^ Directory to search for data files
311+ , stSourceURL :: Maybe String
312+ -- ^ Absolute URL + dir of 1st source file
292313 , stMediaBag :: MediaBag
293314 -- ^ Media parsed from binary containers
294315 , stTranslations :: Maybe
295316 (Lang, Maybe Translations)
296317 -- ^ Translations for localization
297− , stInputFiles :: Maybe [FilePath]
318+ , stInputFiles :: [FilePath]
298319 -- ^ List of input files from command line
299320 , stOutputFile :: Maybe FilePath
300321 -- ^ Output file from command line
@@ -311,9 +332,10 @@ data CommonState = CommonState { stLog :: [LogMessage]
311332instance Default CommonState where
312333 def = CommonState { stLog = []
313334 , stUserDataDir = Nothing
335+ , stSourceURL = Nothing
314336 , stMediaBag = mempty
315337 , stTranslations = Nothing
316− , stInputFiles = Nothing
338+ , stInputFiles = []
317339 , stOutputFile = Nothing
318340 , stResourcePath = ["."]
319341 , stVerbosity = WARNING
@@ -473,20 +495,19 @@ getUserDataDir = getsCommonState stUserDataDir
473495-- | Fetch an image or other item from the local filesystem or the net.
474496-- Returns raw content and maybe mime type.
475497fetchItem :: PandocMonad m
476− => Maybe String
477− -> String
498+ => String
478499 -> m (B.ByteString, Maybe MimeType)
479−fetchItem sourceURL s = do
500+fetchItem s = do
480501 mediabag <- getMediaBag
481502 case lookupMedia s mediabag of
482503 Just (mime, bs) -> return (BL.toStrict bs, Just mime)
483− Nothing -> downloadOrRead sourceURL s
504+ Nothing -> downloadOrRead s
484505
485506downloadOrRead :: PandocMonad m
486− => Maybe String
487− -> String
507+ => String
488508 -> m (B.ByteString, Maybe MimeType)
489−downloadOrRead sourceURL s =
509+downloadOrRead s = do
510+ sourceURL <- getsCommonState stSourceURL
490511 case (sourceURL >>= parseURIReference' .
491512 ensureEscaped, ensureEscaped s) of
492513 (Just u, s') -> -- try fetching from relative path at source
@@ -637,10 +658,9 @@ withPaths (p:ps) action fp =
637658-- | Fetch local or remote resource (like an image) and provide data suitable
638659-- for adding it to the MediaBag.
639660fetchMediaResource :: PandocMonad m
640− => Maybe String -> String
641− -> m (FilePath, Maybe MimeType, BL.ByteString)
642−fetchMediaResource sourceUrl src = do
643− (bs, mt) <- downloadOrRead sourceUrl src
661+ => String -> m (FilePath, Maybe MimeType, BL.ByteString)
662+fetchMediaResource src = do
663+ (bs, mt) <- downloadOrRead src
644664 let ext = fromMaybe (takeExtension src)
645665 (mt >>= extensionFromMimeType)
646666 let bs' = BL.fromChunks [bs]
@@ -650,15 +670,15 @@ fetchMediaResource sourceUrl src = do
650670
651671-- | Traverse tree, filling media bag for any images that
652672-- aren't already in the media bag.
653−fillMediaBag :: PandocMonad m => Maybe String -> Pandoc -> m Pandoc
654−fillMediaBag sourceURL d = walkM handleImage d
673+fillMediaBag :: PandocMonad m => Pandoc -> m Pandoc
674+fillMediaBag d = walkM handleImage d
655675 where handleImage :: PandocMonad m => Inline -> m Inline
656676 handleImage (Image attr lab (src, tit)) = catchError
657677 (do mediabag <- getMediaBag
658678 case lookupMedia src mediabag of
659679 Just (_, _) -> return $ Image attr lab (src, tit)
660680 Nothing -> do
661− (fname, mt, bs) <- fetchMediaResource sourceURL src
681+ (fname, mt, bs) <- fetchMediaResource src
662682 insertMedia fname mt bs
663683 return $ Image attr lab (fname, tit))
664684 (\e ->
src/Text/Pandoc/Lua/PandocModule.hs+2−4
@@ -136,11 +136,9 @@ mediaDirectoryFn mbRef = do
136136
137137insertResource :: IORef MB.MediaBag
138138 -> String
139− -> OrNil String
140139 -> Lua NumResults
141−insertResource mbRef src sourceUrlOrNil = do
142− (fp, mimeType, bs) <- liftIO . runIOorExplode $
143− fetchMediaResource (toMaybe sourceUrlOrNil) src
140+insertResource mbRef src = do
141+ (fp, mimeType, bs) <- liftIO . runIOorExplode $ fetchMediaResource src
144142 liftIO $ print (fp, mimeType)
145143 insertMediaFn mbRef fp (OrNil mimeType) bs
146144
src/Text/Pandoc/Options.hs−2
@@ -207,7 +207,6 @@ data WriterOptions = WriterOptions
207207 , writerEmailObfuscation :: ObfuscationMethod -- ^ How to obfuscate emails
208208 , writerIdentifierPrefix :: String -- ^ Prefix for section & note ids in HTML
209209 -- and for footnote marks in markdown
210− , writerSourceURL :: Maybe String -- ^ Absolute URL + directory of 1st source file
211210 , writerCiteMethod :: CiteMethod -- ^ How to print cites
212211 , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML
213212 , writerSlideLevel :: Maybe Int -- ^ Force header level of slides
@@ -244,7 +243,6 @@ instance Default WriterOptions where
244243 , writerColumns = 72
245244 , writerEmailObfuscation = NoObfuscation
246245 , writerIdentifierPrefix = ""
247− , writerSourceURL = Nothing
248246 , writerCiteMethod = Citeproc
249247 , writerHtmlQTags = False
250248 , writerSlideLevel = Nothing
src/Text/Pandoc/PDF.hs+3−4
@@ -129,7 +129,7 @@ makePDF program writer opts verbosity mediabag doc = do
129129 else withTempDir
130130 resourcePath <- getResourcePath
131131 liftIO $ withTemp "tex2pdf." $ \tmpdir -> do
132− doc' <- handleImages verbosity opts resourcePath mediabag tmpdir doc
132+ doc' <- handleImages verbosity resourcePath mediabag tmpdir doc
133133 source <- runIOorExplode $ do
134134 setVerbosity verbosity
135135 writer opts doc'
@@ -141,18 +141,17 @@ makePDF program writer opts verbosity mediabag doc = do
141141 _ -> return $ Left $ UTF8.fromStringLazy $ "Unknown program " ++ program
142142
143143handleImages :: Verbosity
144− -> WriterOptions
145144 -> [FilePath]
146145 -> MediaBag
147146 -> FilePath -- ^ temp dir to store images
148147 -> Pandoc -- ^ document
149148 -> IO Pandoc
150−handleImages verbosity opts resourcePath mediabag tmpdir doc = do
149+handleImages verbosity resourcePath mediabag tmpdir doc = do
151150 doc' <- runIOorExplode $ do
152151 setVerbosity verbosity
153152 setResourcePath resourcePath
154153 setMediaBag mediabag
155− fillMediaBag (writerSourceURL opts) doc >>=
154+ fillMediaBag doc >>=
156155 extractMedia tmpdir
157156 walkM (convertImages verbosity tmpdir) doc'
158157
src/Text/Pandoc/Readers/RST.hs+1−1
@@ -850,7 +850,7 @@ csvTableDirective top fields rawcsv = do
850850 rawcsv' <- case trim <$>
851851 lookup "file" fields `mplus` lookup "url" fields of
852852 Just u -> do
853− (bs, _) <- fetchItem Nothing u
853+ (bs, _) <- fetchItem u
854854 return $ UTF8.toString bs
855855 Nothing -> return rawcsv
856856 let res = parseCSV opts (T.pack $ case explicitHeader of
src/Text/Pandoc/Readers/Txt2Tags.hs+2−8
@@ -70,14 +70,8 @@ instance Default T2TMeta where
7070-- | Get the meta information required by Txt2Tags macros
7171getT2TMeta :: PandocMonad m => m T2TMeta
7272getT2TMeta = do
73− mbInps <- P.getInputFiles
74− let inps = case mbInps of
75− Just x -> x
76− Nothing -> []
77− mbOutp <- P.getOutputFile
78− let outp = case mbOutp of
79− Just x -> x
80− Nothing -> ""
73+ inps <- P.getInputFiles
74+ outp <- fromMaybe "" <$> P.getOutputFile
8175 curDate <- formatTime defaultTimeLocale "%F" <$> P.getZonedTime
8276 let getModTime = fmap (formatTime defaultTimeLocale "%T") .
8377 P.getModificationTime
src/Text/Pandoc/SelfContained.hs+54−56
@@ -42,10 +42,11 @@ import qualified Data.ByteString.Char8 as B
4242import qualified Data.ByteString.Lazy as L
4343import Data.Char (isAlphaNum, isAscii, toLower)
4444import Data.List (isPrefixOf)
45−import Network.URI (URI (..), escapeURIString, parseURI)
45+import Network.URI (escapeURIString)
4646import System.FilePath (takeDirectory, takeExtension, (</>))
4747import Text.HTML.TagSoup
48−import Text.Pandoc.Class (PandocMonad (..), fetchItem, report)
48+import Text.Pandoc.Class (PandocMonad (..), fetchItem, report,
49+ getInputFiles, setInputFiles)
4950import Text.Pandoc.Error
5051import Text.Pandoc.Logging
5152import Text.Pandoc.MIME (MimeType)
@@ -68,29 +69,29 @@ makeDataURI (mime, raw) =
6869 then mime ++ ";charset=utf-8"
6970 else mime -- mime type already has charset
7071
71−convertTags :: PandocMonad m => Maybe String -> [Tag String] -> m [Tag String]
72−convertTags _ [] = return []
73−convertTags sourceURL (t@TagOpen{}:ts)
74− | fromAttrib "data-external" t == "1" = (t:) <$> convertTags sourceURL ts
75−convertTags sourceURL (t@(TagOpen tagname as):ts)
72+convertTags :: PandocMonad m => [Tag String] -> m [Tag String]
73+convertTags [] = return []
74+convertTags (t@TagOpen{}:ts)
75+ | fromAttrib "data-external" t == "1" = (t:) <$> convertTags ts
76+convertTags (t@(TagOpen tagname as):ts)
7677 | tagname `elem`
7778 ["img", "embed", "video", "input", "audio", "source", "track"] = do
7879 as' <- mapM processAttribute as
79− rest <- convertTags sourceURL ts
80+ rest <- convertTags ts
8081 return $ TagOpen tagname as' : rest
8182 where processAttribute (x,y) =
8283 if x == "src" || x == "data-src" || x == "href" || x == "poster"
8384 then do
84− enc <- getDataURI sourceURL (fromAttrib "type" t) y
85+ enc <- getDataURI (fromAttrib "type" t) y
8586 return (x, enc)
8687 else return (x,y)
87−convertTags sourceURL (t@(TagOpen "script" as):TagClose "script":ts) =
88+convertTags (t@(TagOpen "script" as):TagClose "script":ts) =
8889 case fromAttrib "src" t of
89− [] -> (t:) <$> convertTags sourceURL ts
90+ [] -> (t:) <$> convertTags ts
9091 src -> do
9192 let typeAttr = fromAttrib "type" t
92− res <- getData sourceURL typeAttr src
93− rest <- convertTags sourceURL ts
93+ res <- getData typeAttr src
94+ rest <- convertTags ts
9495 case res of
9596 Left dataUri -> return $ TagOpen "script"
9697 (("src",dataUri) : [(x,y) | (x,y) <- as, x /= "src"]) :
@@ -110,21 +111,21 @@ convertTags sourceURL (t@(TagOpen "script" as):TagClose "script":ts) =
110111 (("src",makeDataURI (mime, bs)) :
111112 [(x,y) | (x,y) <- as, x /= "src"]) :
112113 TagClose "script" : rest
113−convertTags sourceURL (t@(TagOpen "link" as):ts) =
114+convertTags (t@(TagOpen "link" as):ts) =
114115 case fromAttrib "href" t of
115− [] -> (t:) <$> convertTags sourceURL ts
116+ [] -> (t:) <$> convertTags ts
116117 src -> do
117− res <- getData sourceURL (fromAttrib "type" t) src
118+ res <- getData (fromAttrib "type" t) src
118119 case res of
119120 Left dataUri -> do
120− rest <- convertTags sourceURL ts
121+ rest <- convertTags ts
121122 return $ TagOpen "link"
122123 (("href",dataUri) : [(x,y) | (x,y) <- as, x /= "href"]) :
123124 rest
124125 Right (mime, bs)
125126 | "text/css" `isPrefixOf` mime
126127 && not ("</" `B.isInfixOf` bs) -> do
127− rest <- convertTags sourceURL $
128+ rest <- convertTags $
128129 dropWhile (==TagClose "link") ts
129130 return $
130131 TagOpen "style" [("type", mime)]
@@ -132,16 +133,16 @@ convertTags sourceURL (t@(TagOpen "link" as):ts) =
132133 : TagClose "style"
133134 : rest
134135 | otherwise -> do
135− rest <- convertTags sourceURL ts
136+ rest <- convertTags ts
136137 return $ TagOpen "link"
137138 (("href",makeDataURI (mime, bs)) :
138139 [(x,y) | (x,y) <- as, x /= "href"]) : rest
139−convertTags sourceURL (t:ts) = (t:) <$> convertTags sourceURL ts
140+convertTags (t:ts) = (t:) <$> convertTags ts
140141
141142cssURLs :: PandocMonad m
142− => Maybe String -> FilePath -> ByteString -> m ByteString
143−cssURLs sourceURL d orig = do
144− res <- runParserT (parseCSSUrls sourceURL d) () "css" orig
143+ => FilePath -> ByteString -> m ByteString
144+cssURLs d orig = do
145+ res <- runParserT (parseCSSUrls d) () "css" orig
145146 case res of
146147 Left e -> do
147148 report $ CouldNotParseCSS (show e)
@@ -149,17 +150,16 @@ cssURLs sourceURL d orig = do
149150 Right bs -> return bs
150151
151152parseCSSUrls :: PandocMonad m
152− => Maybe String -> FilePath -> ParsecT ByteString () m ByteString
153−parseCSSUrls sourceURL d = B.concat <$> P.many
154− (pCSSWhite <|> pCSSComment <|> pCSSImport sourceURL d <|>
155− pCSSUrl sourceURL d <|> pCSSOther)
153+ => FilePath -> ParsecT ByteString () m ByteString
154+parseCSSUrls d = B.concat <$> P.many
155+ (pCSSWhite <|> pCSSComment <|> pCSSImport d <|> pCSSUrl d <|> pCSSOther)
156156
157−pCSSImport :: PandocMonad m => Maybe String -> FilePath
158− -> ParsecT ByteString () m ByteString
159−pCSSImport sourceURL d = P.try $ do
157+pCSSImport :: PandocMonad m
158+ => FilePath -> ParsecT ByteString () m ByteString
159+pCSSImport d = P.try $ do
160160 P.string "@import"
161161 P.spaces
162− res <- (pQuoted <|> pUrl) >>= handleCSSUrl sourceURL d
162+ res <- (pQuoted <|> pUrl) >>= handleCSSUrl d
163163 P.spaces
164164 P.char ';'
165165 P.spaces
@@ -184,9 +184,9 @@ pCSSOther = do
184184 (B.singleton <$> P.char '/')
185185
186186pCSSUrl :: PandocMonad m
187− => Maybe String -> FilePath -> ParsecT ByteString () m ByteString
188−pCSSUrl sourceURL d = P.try $ do
189− res <- pUrl >>= handleCSSUrl sourceURL d
187+ => FilePath -> ParsecT ByteString () m ByteString
188+pCSSUrl d = P.try $ do
189+ res <- pUrl >>= handleCSSUrl d
190190 case res of
191191 Left b -> return b
192192 Right (mt,b) -> do
@@ -215,41 +215,41 @@ pUrl = P.try $ do
215215 return (url, fallback)
216216
217217handleCSSUrl :: PandocMonad m
218− => Maybe String -> FilePath -> (String, ByteString)
218+ => FilePath -> (String, ByteString)
219219 -> ParsecT ByteString () m
220220 (Either ByteString (MimeType, ByteString))
221−handleCSSUrl sourceURL d (url, fallback) = do
221+handleCSSUrl d (url, fallback) = do
222222 -- pipes are used in URLs provided by Google Code fonts
223223 -- but parseURI doesn't like them, so we escape them:
224224 case escapeURIString (/='|') (trim url) of
225225 '#':_ -> return $ Left fallback
226226 'd':'a':'t':'a':':':_ -> return $ Left fallback
227227 u -> do let url' = if isURI u then u else d </> u
228− res <- lift $ getData sourceURL "" url'
228+ res <- lift $ getData "" url'
229229 case res of
230230 Left uri -> return $ Left (B.pack $ "url(" ++ uri ++ ")")
231231 Right (mt, raw) -> do
232232 -- note that the downloaded CSS may
233233 -- itself contain url(...).
234234 b <- if "text/css" `isPrefixOf` mt
235− then cssURLs sourceURL d raw
235+ then cssURLs d raw
236236 else return raw
237237 return $ Right (mt, b)
238238
239−getDataURI :: PandocMonad m => Maybe String -> MimeType -> String -> m String
240−getDataURI sourceURL mimetype src = do
241− res <- getData sourceURL mimetype src
239+getDataURI :: PandocMonad m => MimeType -> String -> m String
240+getDataURI mimetype src = do
241+ res <- getData mimetype src
242242 case res of
243243 Left uri -> return uri
244244 Right x -> return $ makeDataURI x
245245
246246getData :: PandocMonad m
247− => Maybe String -> MimeType -> String
247+ => MimeType -> String
248248 -> m (Either String (MimeType, ByteString))
249−getData _ _ src@('d':'a':'t':'a':':':_) = return $ Left src-- already data: uri
250−getData sourceURL mimetype src = do
249+getData _ src@('d':'a':'t':'a':':':_) = return $ Left src-- already data: uri
250+getData mimetype src = do
251251 let ext = map toLower $ takeExtension src
252− (raw, respMime) <- fetchItem sourceURL src
252+ (raw, respMime) <- fetchItem src
253253 let raw' = if ext == ".gz"
254254 then B.concat $ L.toChunks $ Gzip.decompress $ L.fromChunks
255255 $ [raw]
@@ -259,15 +259,13 @@ getData sourceURL mimetype src = do
259259 $ "Could not determine mime type for `" ++ src ++ "'"
260260 (x, Nothing) -> return x
261261 (_, Just x ) -> return x
262− let cssSourceURL = case parseURI src of
263− Just u
264− | uriScheme u `elem` ["http:","https:"] ->
265− Just $ show u{ uriPath = "",
266− uriQuery = "",
267− uriFragment = "" }
268− _ -> Nothing
269262 result <- if "text/css" `isPrefixOf` mime
270− then cssURLs cssSourceURL (takeDirectory src) raw'
263+ then do
264+ oldInputs <- getInputFiles
265+ setInputFiles [src]
266+ res <- cssURLs (takeDirectory src) raw'
267+ setInputFiles oldInputs
268+ return res
271269 else return raw'
272270 return $ Right (mime, result)
273271
@@ -275,8 +273,8 @@ getData sourceURL mimetype src = do
275273
276274-- | Convert HTML into self-contained HTML, incorporating images,
277275-- scripts, and CSS using data: URIs.
278−makeSelfContained :: PandocMonad m => WriterOptions -> String -> m String
279−makeSelfContained opts inp = do
276+makeSelfContained :: PandocMonad m => String -> m String
277+makeSelfContained inp = do
280278 let tags = parseTags inp
281− out' <- convertTags (writerSourceURL opts) tags
279+ out' <- convertTags tags
282280 return $ renderTags' out'
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -1295,7 +1295,7 @@ inlineToOpenXML' opts (Image attr alt (src, title)) = do
12951295 Just (_,_,_,elt,_) -> return [elt]
12961296 Nothing -> do
12971297 catchError
1298− (do (img, mt) <- P.fetchItem (writerSourceURL opts) src
1298+ (do (img, mt) <- P.fetchItem src
12991299 ident <- ("rId"++) `fmap` ((lift . lift) getUniqueId)
13001300 let (xpt,ypt) = desiredSizeInPoints opts attr
13011301 (either (const def) id (imageSize opts img))
src/Text/Pandoc/Writers/EPUB.hs+1−1
@@ -918,7 +918,7 @@ modifyMediaRef opts oldsrc = do
918918 case lookup oldsrc media of
919919 Just (n,_) -> return n
920920 Nothing -> catchError
921− (do (img, mbMime) <- P.fetchItem (writerSourceURL opts) oldsrc
921+ (do (img, mbMime) <- P.fetchItem oldsrc
922922 let new = "media/file" ++ show (length media) ++
923923 fromMaybe (takeExtension (takeWhile (/='?') oldsrc))
924924 (('.':) <$> (mbMime >>= extensionFromMimeType))
src/Text/Pandoc/Writers/FB2.hs+1−1
@@ -255,7 +255,7 @@ fetchImage href link = do
255255 else return Nothing
256256 (True, Just _) -> return Nothing -- not base64-encoded
257257 _ -> do
258− catchError (do (bs, mbmime) <- P.fetchItem Nothing link
258+ catchError (do (bs, mbmime) <- P.fetchItem link
259259 case mbmime of
260260 Nothing -> do
261261 report $ CouldNotDetermineMimeType link
src/Text/Pandoc/Writers/ICML.hs+1−1
@@ -543,7 +543,7 @@ styleToStrAttr style =
543543imageICML :: PandocMonad m => WriterOptions -> Style -> Attr -> Target -> WS m Doc
544544imageICML opts style attr (src, _) = do
545545 imgS <- catchError
546− (do (img, _) <- P.fetchItem (writerSourceURL opts) src
546+ (do (img, _) <- P.fetchItem src
547547 case imageSize opts img of
548548 Right size -> return size
549549 Left msg -> do
src/Text/Pandoc/Writers/ODT.hs+1−1
@@ -180,7 +180,7 @@ addLang lang = everywhere' (mkT updateLangAttr)
180180-- | transform both Image and Math elements
181181transformPicMath :: PandocMonad m => WriterOptions ->Inline -> O m Inline
182182transformPicMath opts (Image attr@(id', cls, _) lab (src,t)) = catchError
183− (do (img, mbMimeType) <- P.fetchItem (writerSourceURL opts) src
183+ (do (img, mbMimeType) <- P.fetchItem src
184184 (ptX, ptY) <- case imageSize opts img of
185185 Right s -> return $ sizeInPoints s
186186 Left msg -> do
src/Text/Pandoc/Writers/RTF.hs+1−1
@@ -56,7 +56,7 @@ import Text.Printf (printf)
5656-- If file not found or filetype not jpeg or png, leave the inline unchanged.
5757rtfEmbedImage :: PandocMonad m => WriterOptions -> Inline -> m Inline
5858rtfEmbedImage opts x@(Image attr _ (src,_)) = catchError
59− (do result <- P.fetchItem (writerSourceURL opts) src
59+ (do result <- P.fetchItem src
6060 case result of
6161 (imgdata, Just mime)
6262 | mime == "image/jpeg" || mime == "image/png" -> do
test/Tests/Readers/Muse.hs+2−4
@@ -13,10 +13,8 @@ import Text.Pandoc.Class
1313
1414muse :: Text -> Pandoc
1515muse = purely $ \s -> do
16− putCommonState
17− def { stInputFiles = Just ["in"]
18− , stOutputFile = Just "out"
19− }
16+ setInputFiles ["in"]
17+ setOutputFile (Just "out")
2018 readMuse def s
2119
2220infix 4 =:
test/Tests/Readers/Txt2Tags.hs+2−4
@@ -14,10 +14,8 @@ import Text.Pandoc.Class
1414t2t :: Text -> Pandoc
1515-- t2t = handleError . readTxt2Tags (T2TMeta "date" "mtime" "in" "out") def
1616t2t = purely $ \s -> do
17− putCommonState
18− def { stInputFiles = Just ["in"]
19− , stOutputFile = Just "out"
20− }
17+ setInputFiles ["in"]
18+ setOutputFile (Just "out")
2119 readTxt2Tags def s
2220
2321infix 4 =:
test/pandoc.tixnew file+1
@@ -0,0 +1 @@
1+Tix [ TixModule "pandoc-2.0-3BMtEkU5Hqi529URohVtzN/Text.Pandoc.Class" 286124609 1293 [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,16,98,98,98,98,16,0,0,16,16,98,114,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,36,36,0,36,36,36,36,729,729,729,729,729,729,729,236,0,0,0,236,493,493,729,729,729,2877,1411,2877,2877,2877,2877,2877,2877,2877,2339,2339,2339,2339,2339,220,220,35,35,35,255,255,255,255,255,220,0,220,220,255,475,22,22,22,0,0,0,22,22,22,0,0,0,0,98,98,98,0,831,831,98,98,98,98,98,98,1488,1488,1488,1488,1488,1488,1488,98,98,98,98,98,98,98,98,48,48,0,0,0,0,0,0,0,0,0,0,48,48,48,48,0,0,0,0,0,0,0,98,98,98,98,0,98,98,98,98,0,0,98,82,48,82,82,98,98,98,0,0,0,98,98,98,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,98,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,98,98,98,98,2339,1411,53,1411,1411,2339,2339,0,11,11,11,11,11,0,6,0,0,0,0,0,0,6,0,0,0,0,6,6,6,98,2437,2437,2339,2339,2339,2339,2339,2339,98,98,98,98,0,0,0,0,0,0,98,98,98,98,98,98,0,0,0,0,0,0,0,2339,1411,1028,1411,1411,2339,2339,4280,4280,4280,4280,4280,4280,4280,4280,4280,36,36,4280,4280,3903,0,0,0,0,3903,3903,4280,4280,4280,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2339,2339,2339,2339,1411,406,1411,1411,2339,2339,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2877,2877,11,11,0,0,98,98,0,0,98,98,40931,40931,4720,4720,45426,50121,50121,50121,11303,11303,8136,11303,11303,11303,0,0,0,0,0,0,0,0,0,0,0,0,0,2339,2339,11,2339,2339,0,0,2339,2339,2339,0,31,92,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,34,34,34,0,0,0,0,0,0,0,0,0,0,0,0,0,2496,2496,2496,1536,1536,1536,1536,18,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9004,9004,9004,978,978,978,978,3,3,3,3,36,36,36,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11501,11501,11501,305,305,305,305,15,15,15,15,40931,40931,40931,40931,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40931,40931,40931,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,36,36,36,36,11,11,11,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,98,98,98,98,376,376,376,376,376,0,0,0,0,0,0,0,0,2339,2339,2339,2339,2339,11303,11303,8136,11303,11303,11303,11303,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,36,0,53,11,0,0,0,0,0,1411,1411], TixModule "pandoc-2.0-3BMtEkU5Hqi529URohVtzN/Text.Pandoc.Writers.HTML" 519911631 3376 [68,470,470,470,470,470,470,68,56,56,56,56,68,68,68,68,68,68,470,470,470,470,0,0,0,35,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2496,415,334,253,1494,2496,2496,33,33,33,33,33,33,33,33,33,33,33,33,33,33,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,33,33,52,52,52,52,0,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,104,104,104,12,12,12,12,12,12,4,4,4,4,4,4,4,4,4,4,88,104,104,52,52,52,52,52,52,16,16,16,16,16,10,2273,2273,2273,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,22,809,809,809,809,22,787,22,22,22,22,0,22,22,22,22,22,22,22,0,0,0,0,0,0,0,0,0,22,787,787,787,787,809,809,809,809,824,0,824,824,824,824,824,824,824,824,824,824,2218,2218,2218,674,1544,674,674,674,2218,2218,2218,2218,222,1996,222,222,222,222,222,2218,2218,2218,2218,2218,2218,838,2166,674,2166,2166,2166,2166,30,30,30,30,30,0,30,0,30,30,30,30,30,30,30,30,30,30,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,6,10,0,16,52,10,52,52,52,0,52,52,52,52,52,52,52,52,52,52,590,590,590,590,10863,10863,10863,10863,0,10863,0,10863,10863,10863,10863,121,121,121,121,121,121,121,121,121,15,890,6,890,15,9,6,9,6,15,15,15,9,6,9,9,9,9,9,9,6,6,6,0,6,0,0,0,0,0,0,6,6,6,6,6,6,6,15,15,890,890,890,875,15,875,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,890,890,890,890,1585,1585,1585,1585,1585,1585,688,688,688,688,688,688,688,688,688,403,403,403,403,403,403,403,285,285,285,285,285,285,285,82,82,82,82,82,43531,43531,43531,43531,43449,43449,82,82,82,82,82,43531,0,43613,313,2499,2499,1002,2499,2499,2499,2499,1002,690,312,690,690,690,690,690,690,690,690,312,312,312,1002,1002,2499,2499,1497,1002,1497,1002,1002,1002,2499,2499,2499,2499,2499,2499,2499,2499,2499,2499,2499,2499,797,797,797,124,673,124,673,797,797,801,124,677,677,677,677,677,415,262,415,262,801,801,801,2499,2499,2499,2499,2499,797,801,797,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,801,0,27,27,27,27,27,27,27,27,27,27,21,6,21,6,6,6,6,27,27,27,27,0,27,0,0,27,0,27,27,27,27,27,27,21,6,21,21,21,21,21,21,21,21,21,21,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,27,27,27,27,0,0,445,3778,3778,6,37,37,0,37,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,27,27,27,27,27,27,27,0,0,0,0,0,0,0,0,0,3509,3509,3509,3509,0,3509,0,0,3509,3509,0,635,3509,3509,3509,3509,3509,3509,3509,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,165,165,0,165,165,165,83,0,83,0,0,0,83,83,83,83,165,165,165,165,165,165,165,165,165,165,165,0,111,111,165,0,165,0,0,0,0,0,0,165,165,165,165,0,165,165,165,0,165,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,165,165,165,165,165,165,165,165,165,165,165,165,452,452,452,402,50,402,402,402,402,50,50,50,50,15,15,15,15,50,35,35,35,0,0,35,50,0,50,0,0,0,0,0,0,0,0,50,0,0,0,50,50,50,50,50,50,452,452,195,195,195,195,117,78,117,78,195,195,195,216,216,216,30,30,30,30,30,10,20,20,20,20,20,20,20,10,10,10,20,216,216,216,10,206,30,30,30,30,30,10,20,10,20,30,10,10,10,206,216,216,216,10,206,10,10,10,10,10,10,10,10,10,206,216,216,216,216,216,216,0,20,20,20,0,216,0,216,20,216,0,0,216,216,216,196,196,196,0,0,0,0,196,196,0,196,196,196,196,196,196,196,196,196,196,196,196,196,196,20,20,20,20,20,0,20,20,20,20,20,20,20,20,216,216,125,125,125,125,125,0,125,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,45,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,125,0,737,737,0,737,737,737,737,0,0,0,0,0,0,0,737,0,737,0,0,0,0,0,0,0,0,0,0,0,0,0,0,737,737,737,737,737,737,737,737,0,737,0,0,0,737,737,426,426,237,237,44,44,15,15,15,15,0,0,0,0,737,737,737,737,153,403,403,403,403,403,403,403,150,285,285,285,255,285,102,0,102,102,102,102,102,102,285,285,285,60,225,60,60,60,60,60,225,285,285,285,285,0,285,0,0,0,285,285,285,285,285,255,30,255,153,102,153,153,108,9,18,9,9,0,153,153,153,102,102,102,102,102,102,102,102,255,30,285,285,285,285,285,285,285,285,255,285,285,285,285,285,271,271,0,271,0,0,271,271,16,271,271,271,271,346,346,346,346,346,346,271,271,61,271,271,271,271,271,271,271,271,271,271,271,75,75,271,271,271,271,271,271,271,271,121,121,121,121,121,121,121,252,252,153,99,153,153,11,99,99,99,99,99,99,99,99,99,99,252,66,252,231,231,231,231,231,231,231,231,248,248,252,252,186,66,186,66,66,66,231,183,48,183,183,183,183,183,183,183,183,183,48,48,48,48,48,48,48,231,231,231,231,66,66,66,66,66,66,66,66,252,252,204,252,252,128,124,128,128,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,124,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,66,66,66,252,206,46,206,46,46,46,46,46,46,46,46,46,46,46,46,46,46,252,252,252,10265,4795,297,297,4795,4795,4795,1035,4718,4795,4795,4789,4789,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,0,75,0,75,75,75,75,75,75,75,75,75,75,75,75,75,75,0,0,0,0,0,0,0,0,0,0,0,0,0,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,0,0,0,0,0,75,75,75,75,75,75,75,75,75,75,75,1151,10562,10562,10562,10562,10562,10562,10562,10562,98,45941,45941,26523,26523,26523,26523,16206,16206,16206,16206,832,832,832,0,0,772,772,60,60,832,832,31,31,25,6,25,6,31,31,31,31,31,16,40,40,0,40,0,40,16,40,40,0,40,0,40,16,40,40,0,40,0,40,40,40,40,40,40,40,0,40,0,0,0,0,0,0,40,40,16,16,16,16,16,40,40,40,40,40,181,41,41,0,41,41,41,17,41,41,41,41,41,41,0,489,489,489,489,489,489,0,167,167,167,167,167,167,205,205,205,205,0,5,5,5,205,5,205,0,0,205,205,5,205,200,200,200,0,0,0,0,200,200,0,200,200,200,200,200,200,200,200,200,5,5,0,5,5,5,5,0,5,5,5,5,5,5,5,5,205,0,15,15,15,15,15,15,0,8,8,8,8,8,8,8,8,8,0,60,60,60,60,60,60,0,45,45,45,45,45,45,240,150,150,150,150,150,90,90,90,90,90,240,240,240,0,240,0,0,0,0,0,0,0,0,0,0,0,0,240,240,240,240,240,240,45,240,240,240,240,135,39,135,135,135,124,124,124,124,124,109,15,109,15,124,124,124,124,135,135,11,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,0,0,11,11,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,124,124,124,0,124,124,124,124,124,124,124,124,124,15,9,6,9,6,15,15,124,124,109,15,15,15,15,15,124,124,124,135,135,15,15,15,0,15,0,0,0,0,15,0,15,15,15,15,15,15,15,804,804,804,30,774,0,30,30,30,30,30,30,30,30,30,30,0,774,774,144,774,774,144,144,144,0,144,0,144,144,144,144,144,144,144,144,144,630,774,774,774,774,774,774,774,774,774,774,774,774,774,774,774,774,53,721,53,53,53,53,53,53,721,721,721,721,774,774,0,774,774,774,774,774,774,774,639,135,639,135,135,135,135,135,774,774,774,52,52,52,0,52,52,52,52,52,52,52,52,52,52,0,52,0,0,0,0,0,52,52,52,52,52,52,52,52,15,37,15,15,15,15,52,52,52,52,52,0,52,52,52,52,52,0,52,52,52,52,52,52,52,40,12,40,12,52,52,52,52,52,52,52,52,52,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,0,75,0,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75,0,75,0,75,75,75,75,75,75,75,75,75,0,0,0,0,0,75,75,75,75,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,46035,46035,46035,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1541,4380,4380,736,736,736,736,736,36,36,36,736,736,0,0,0,0,0,0,0,0,0,736,736,0,736,736,736,36,736,736,36,36,36,736,736,736,736,736,736,736,0,736,0,0,736,736,736,736,736,736,736,0,0,0,736,736,736,736,736,0,736,736,736,736,736,736,736,0,0,0,3305,1619,1940,0,0,0,0,0,0,1940,3305,3305,296,3601,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,571,621,736,736,0,736,0,0,0,621,736,736,115,621,0,621,621,621,736,736,736,36,36,36,36,36,36,36,36,36,36,36,36,36,36,736,0,736,0,736,736,36,700,36,736,736,700,700,736,36,36,736,36,700,36,736,736,700,700,736,36,700,36,36,36,36,736,736,736,736,736,736,736,36,0,36,0,36,36,36,736,736,736,736,736,736,736,0,736,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,736,736,736,736,36,700,36,36,36,36,36,36,36,36,36,36,36,700,585,585,700,592,700,700,700,700,700,700,700,736,736,736,736,5116,891,0,0,0,0,0,39,39,0,39,39,59,891,59,59,59,59,39,59,59,59,59,59,59,59,59,59,59,18,18,18,18,18,18,18,891,891,891,891,891,891,873,18,873,18,18,18,891,891,891,891,891,0,0,0,891,0,891,0,0,0,0,0,0,59,891,891,891,159,159,891,891,891,18,448,891,891,891,891,891,15,891,891,891,891,891,891,891,891,39,39,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39,39,39,39,11,11,11,11,0,11,11,11,11,11,11,11,11,11,11,11,0,0,0,0,28,39,39,39,59,59,20,39,20,20,20,20,20,20,0,20,39,59,59,59,39,20,39,39,39,39,20,59,59,59,59,0,59,59,59,59,59,59,59,59,0,0,59,59,59,0,0,59,59,59,59,59,20,39,39,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,890,59,890,890,890,890,890,890,890,890,890,890,890,831,831,831,831,59,59,59,59,59,59,59,59,59,59,59,59,59,59,39,20,39,39,0,20,20,20,20,20,20,20,20,20,20,0,20,20,20,20,20,20,20,20,20,59,59,59,59,59,59,59,59,59,59,890,890,890,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,590,20,59,39,0,0,0,15,572,590,590,850,143,850,850,850,0,0,0,0,0,22,16,22,22,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,18,18,0,18,0,0,0,0,18,18,18,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,965,965,59,59,59,59,59,59,0,0,736,736,1994,1994,150,150,2050,2050]]