git.iko.soy/typeable/pandoc
on master help sign in
Removed links (internal and external).
commit6a7b16eb4d94683d1e3844b6296e5743e72deccc authorJohn MacFarlane <jgm@berkeley.edu> dateSun 4 Jul 2010, 18:40 (16 years ago) parentf895ee2
1 file changed+17−15
src/Text/Pandoc/Writers/EPUB.hs+17−15
src/Text/Pandoc/Writers/EPUB.hs+17−15
@@ -79,7 +79,7 @@ writeEPUB sourceDir stylesheet opts doc = do
7979 -- handle pictures
8080 picEntriesRef <- newIORef ([] :: [Entry])
8181 Pandoc meta blocks <- liftM (processWith transformBlock) $
82− processWithM (transformInline (writerHTMLMathMethod opts)
82+ processWithM (transformInlines (writerHTMLMathMethod opts)
8383 sourceDir picEntriesRef) doc
8484 picEntries <- readIORef picEntriesRef
8585 -- body pages
@@ -186,21 +186,21 @@ metadataElement metadataXML uuid lang title authors =
186186 [ unode "dc:creator" ! [("opf:role","aut")] $ a | a <- authors ]
187187 in elt{ elContent = elContent elt ++ map Elem newNodes }
188188
189−transformInline :: HTMLMathMethod
190− -> FilePath
191− -> IORef [Entry]
192− -> Inline
193− -> IO Inline
194−transformInline _ _ _ (Image lab (src,_)) | isNothing (imageTypeOf src) =
195− return (Emph lab)
196−transformInline _ sourceDir picsRef (Image lab (src,tit)) = do
189+transformInlines :: HTMLMathMethod
190+ -> FilePath
191+ -> IORef [Entry]
192+ -> [Inline]
193+ -> IO [Inline]
194+transformInlines _ _ _ (Image lab (src,_) : xs) | isNothing (imageTypeOf src) =
195+ return $ Emph lab : xs
196+transformInlines _ sourceDir picsRef (Image lab (src,tit) : xs) = do
197197 entries <- readIORef picsRef
198198 let newsrc = "images/img" ++ show (length entries) ++ takeExtension src
199199 catch (readEntry [] (sourceDir </> src) >>= \entry ->
200200 modifyIORef picsRef (entry{ eRelativePath = newsrc } :) >>
201− return (Image lab (newsrc, tit)))
202− (\_ -> return (Emph lab))
203−transformInline (MathML _) _ _ x@(Math _ _) = do
201+ return (Image lab (newsrc, tit) : xs))
202+ (\_ -> return (Emph lab : xs))
203+transformInlines (MathML _) _ _ (x@(Math _ _) : xs) = do
204204 let writeHtmlInline opts z = removeTrailingSpace $
205205 writeHtmlString opts $ Pandoc (Meta [] [] []) [Plain [z]]
206206 mathml = writeHtmlInline defaultWriterOptions{
@@ -211,9 +211,11 @@ transformInline (MathML _) _ _ x@(Math _ _) = do
211211 "<ops:case required-namespace=\"http://www.w3.org/1998/Math/MathML\">" ++
212212 mathml ++ "</ops:case><ops:default>" ++ fallback ++ "</ops:default>" ++
213213 "</ops:switch>"
214− return $ HtmlInline $ if "<math" `isPrefixOf` mathml then inOps else mathml
215−transformInline _ _ _ (HtmlInline _) = return $ Str ""
216−transformInline _ _ _ x = return x
214+ result = if "<math" `isPrefixOf` mathml then inOps else mathml
215+ return $ HtmlInline result : xs
216+transformInlines _ _ _ (HtmlInline _ : xs) = return $ Str "" : xs
217+transformInlines _ _ _ (Link lab (_,_) : xs) = return $ lab ++ xs
218+transformInlines mathmethod sourceDir picsRef xs = return xs
217219
218220transformBlock :: Block -> Block
219221transformBlock (RawHtml _) = Null