@@ -1,3 +1,5 @@
1+{-# LANGUAGE PatternGuards #-}
2+
13{-
24Copyright (C) 2014 Jesse Rosenthal <jrosenthal@jhu.edu>
35
@@ -82,7 +84,7 @@ import Text.Pandoc.Walk
8284import Text.Pandoc.Readers.Docx.Parse
8385import Text.Pandoc.Readers.Docx.Lists
8486import Text.Pandoc.Readers.Docx.Reducible
85−import Data.Maybe (mapMaybe, isJust, fromJust)
87+import Data.Maybe (mapMaybe)
8688import Data.List (delete, isPrefixOf, (\\))
8789import qualified Data.ByteString as BS
8890import qualified Data.ByteString.Lazy as B
@@ -148,12 +150,10 @@ runStyleToContainers rPr =
148150
149151
150152divAttrToContainers :: [String] -> [(String, String)] -> [Container Block]
151−divAttrToContainers (c:cs) _ | isJust (isHeaderClass c) =
152− let n = fromJust (isHeaderClass c)
153− in
154− [(Container $ \blks ->
155− makeHeaderAnchor $
156− Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
153+divAttrToContainers (c:cs) _ | Just n <- isHeaderClass c =
154+ [(Container $ \blks ->
155+ makeHeaderAnchor $
156+ Header n ("", delete ("Heading" ++ show n) cs, []) (blksToInlines blks))]
157157divAttrToContainers (c:cs) kvs | c `elem` divsToKeep =
158158 (Container $ Div ("", [c], [])) : (divAttrToContainers cs kvs)
159159divAttrToContainers (c:cs) kvs | c `elem` codeDivs =
@@ -167,10 +167,10 @@ divAttrToContainers (c:cs) kvs | c `elem` listParagraphDivs =
167167divAttrToContainers (c:cs) kvs | c `elem` blockQuoteDivs =
168168 (Container BlockQuote) : (divAttrToContainers (cs \\ blockQuoteDivs) kvs)
169169divAttrToContainers (_:cs) kvs = divAttrToContainers cs kvs
170−divAttrToContainers [] kvs | isJust (lookup "indent" kvs) =
170+divAttrToContainers [] kvs | Just numString <- lookup "indent" kvs =
171171 let kvs' = filter (\(k,_) -> k /= "indent") kvs
172172 in
173− case fromJust (lookup "indent" kvs) of
173+ case numString of
174174 "0" -> divAttrToContainers [] kvs'
175175 ('-' : _) -> divAttrToContainers [] kvs'
176176 _ -> (Container BlockQuote) : divAttrToContainers [] kvs'