Commit c63495f4 authored by Mael NICOLAS's avatar Mael NICOLAS

Text -> Maybe Text to backup pandoc errors

parent 54aa9ba5
...@@ -40,8 +40,8 @@ import Data.Either ...@@ -40,8 +40,8 @@ import Data.Either
-- (since there is no abstract) will see if other datas are relevant. -- (since there is no abstract) will see if other datas are relevant.
data Page = Page data Page = Page
{ {
_title :: T.Text _title :: Maybe T.Text
, _text :: T.Text , _text :: Maybe T.Text
} }
deriving (Show) deriving (Show)
...@@ -74,12 +74,11 @@ parsePage :: MonadThrow m => ConduitT Event o m (Maybe Page) ...@@ -74,12 +74,11 @@ parsePage :: MonadThrow m => ConduitT Event o m (Maybe Page)
parsePage = parsePage =
tagNoAttr "{http://www.mediawiki.org/xml/export-0.10/}page" $ do tagNoAttr "{http://www.mediawiki.org/xml/export-0.10/}page" $ do
title <- title <-
force "title is missing" $
tagNoAttr "{http://www.mediawiki.org/xml/export-0.10/}title" content tagNoAttr "{http://www.mediawiki.org/xml/export-0.10/}title" content
_ <- _ <-
consumeExcept "{http://www.mediawiki.org/xml/export-0.10/}revision" consumeExcept "{http://www.mediawiki.org/xml/export-0.10/}revision"
revision <- revision <-
force "revision is missing" $ parseRevision parseRevision
many_ $ ignoreAnyTreeContent many_ $ ignoreAnyTreeContent
return $ Page title revision return $ Page title revision
...@@ -94,10 +93,13 @@ mediawikiPageToPlain page = do ...@@ -94,10 +93,13 @@ mediawikiPageToPlain page = do
title <- mediaToPlain $ _title page title <- mediaToPlain $ _title page
revision <- mediaToPlain $ _text page revision <- mediaToPlain $ _text page
return $ Page title revision return $ Page title revision
where mediaToPlain media = do where mediaToPlain media =
res <- runIO $ do case media of
doc <- readMediaWiki def media (Nothing) -> return Nothing
writePlain def doc (Just med) -> do
case res of res <- runIO $ do
(Left _) -> return media doc <- readMediaWiki def med
(Right r) -> return r writePlain def doc
case res of
(Left _) -> return Nothing
(Right r) -> return $ Just r
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment