git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1099 from hdevalence/master

Minor HLint-suggested changes

commit3c4aa01664486701a531b0db29dd2bb5124965ee authorJohn MacFarlane <jgm@berkeley.edu> dateThu 19 Dec 2013, 20:20 (13 years ago) parent8053ba23d70059
23 files changed+69−69
pandoc.hs+3−5 src/Text/Pandoc/PDF.hs+2−1 src/Text/Pandoc/Parsing.hs+2−2 src/Text/Pandoc/Readers/DocBook.hs+4−3 src/Text/Pandoc/Readers/HTML.hs+2−2 src/Text/Pandoc/Readers/LaTeX.hs+2−3 src/Text/Pandoc/Readers/Markdown.hs+7−7 src/Text/Pandoc/Readers/MediaWiki.hs+4−3 src/Text/Pandoc/Readers/Textile.hs+1−1 src/Text/Pandoc/Shared.hs+5−9 src/Text/Pandoc/Writers/Docx.hs+4−2 src/Text/Pandoc/Writers/EPUB.hs+6−6 src/Text/Pandoc/Writers/HTML.hs+3−3 src/Text/Pandoc/Writers/LaTeX.hs+7−6 src/Text/Pandoc/Writers/Markdown.hs+6−5 src/Text/Pandoc/Writers/MediaWiki.hs+1−1 src/Text/Pandoc/Writers/ODT.hs+2−1 src/Text/Pandoc/Writers/Org.hs+1−1 src/Text/Pandoc/Writers/Shared.hs+1−2 src/Text/Pandoc/Writers/Textile.hs+1−1 tests/Tests/Readers/LaTeX.hs+1−1 tests/Tests/Readers/Markdown.hs+2−2 tests/Tests/Walk.hs+2−2
pandoc.hs+3−5
@@ -656,7 +656,7 @@ options =
656656 (ReqArg
657657 (\arg opt -> do
658658 let b = takeBaseName arg
659− if (b == "pdflatex" || b == "lualatex" || b == "xelatex")
659+ if b `elem` ["pdflatex", "lualatex", "xelatex"]
660660 then return opt { optLaTeXEngine = arg }
661661 else err 45 "latex-engine must be pdflatex, lualatex, or xelatex.")
662662 "PROGRAM")
@@ -1034,12 +1034,10 @@ main = do
10341034
10351035 variables' <- case mathMethod of
10361036 LaTeXMathML Nothing -> do
1037− s <- readDataFileUTF8 datadir
1038− ("LaTeXMathML.js")
1037+ s <- readDataFileUTF8 datadir "LaTeXMathML.js"
10391038 return $ ("mathml-script", s) : variables
10401039 MathML Nothing -> do
1041− s <- readDataFileUTF8 datadir
1042− ("MathMLinHTML.js")
1040+ s <- readDataFileUTF8 datadir "MathMLinHTML.js"
10431041 return $ ("mathml-script", s) : variables
10441042 _ -> return variables
10451043
src/Text/Pandoc/PDF.hs+2−1
@@ -41,6 +41,7 @@ import System.Directory
4141import System.Environment
4242import Control.Monad (unless)
4343import Data.List (isInfixOf)
44+import Data.Maybe (fromMaybe)
4445import qualified Data.ByteString.Base64 as B64
4546import qualified Text.Pandoc.UTF8 as UTF8
4647import Text.Pandoc.Definition
@@ -87,7 +88,7 @@ handleImage' baseURL tmpdir (Image ils (src,tit)) = do
8788 res <- fetchItem baseURL src
8889 case res of
8990 Right (contents, Just mime) -> do
90− let ext = maybe (takeExtension src) id $
91+ let ext = fromMaybe (takeExtension src) $
9192 extensionFromMimeType mime
9293 let basename = UTF8.toString $ B64.encode $ UTF8.fromString src
9394 let fname = tmpdir </> basename <.> ext
src/Text/Pandoc/Parsing.hs+2−2
@@ -271,7 +271,7 @@ spaceChar = satisfy $ \c -> c == ' ' || c == '\t'
271271
272272-- | Parses a nonspace, nonnewline character.
273273nonspaceChar :: Parser [Char] st Char
274−nonspaceChar = satisfy $ \x -> x /= '\t' && x /= '\n' && x /= ' ' && x /= '\r'
274+nonspaceChar = satisfy $ flip notElem ['\t', '\n', ' ', '\r']
275275
276276-- | Skips zero or more spaces or tabs.
277277skipSpaces :: Parser [Char] st ()
@@ -1062,7 +1062,7 @@ doubleQuoteStart :: Parser [Char] ParserState ()
10621062doubleQuoteStart = do
10631063 failIfInQuoteContext InDoubleQuote
10641064 try $ do charOrRef "\"\8220\147"
1065− notFollowedBy (satisfy (\c -> c == ' ' || c == '\t' || c == '\n'))
1065+ notFollowedBy . satisfy $ flip elem [' ', '\t', '\n']
10661066
10671067doubleQuoteEnd :: Parser [Char] st ()
10681068doubleQuoteEnd = do
src/Text/Pandoc/Readers/DocBook.hs+4−3
@@ -12,6 +12,7 @@ import Data.Char (isSpace)
1212import Control.Monad.State
1313import Control.Applicative ((<$>))
1414import Data.List (intersperse)
15+import Data.Maybe (fromMaybe)
1516
1617{-
1718
@@ -683,7 +684,7 @@ parseBlock (Elem e) =
683684 "lowerroman" -> LowerRoman
684685 "upperroman" -> UpperRoman
685686 _ -> Decimal
686− let start = maybe 1 id $
687+ let start = fromMaybe 1 $
687688 (attrValue "override" <$> filterElement (named "listitem") e)
688689 >>= safeRead
689690 orderedListWith (start,listStyle,DefaultDelim)
@@ -779,7 +780,7 @@ parseBlock (Elem e) =
779780 caption <- case filterChild isCaption e of
780781 Just t -> getInlines t
781782 Nothing -> return mempty
782− let e' = maybe e id $ filterChild (named "tgroup") e
783+ let e' = fromMaybe e $ filterChild (named "tgroup") e
783784 let isColspec x = named "colspec" x || named "col" x
784785 let colspecs = case filterChild (named "colgroup") e' of
785786 Just c -> filterChildren isColspec c
@@ -801,7 +802,7 @@ parseBlock (Elem e) =
801802 Just "center" -> AlignCenter
802803 _ -> AlignDefault
803804 let toWidth c = case findAttr (unqual "colwidth") c of
804− Just w -> maybe 0 id
805+ Just w -> fromMaybe 0
805806 $ safeRead $ '0': filter (\x ->
806807 (x >= '0' && x <= '9')
807808 || x == '.') w
src/Text/Pandoc/Readers/HTML.hs+2−2
@@ -207,7 +207,7 @@ pHeader = try $ do
207207 let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
208208 let level = read (drop 1 tagtype)
209209 contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
210− let ident = maybe "" id $ lookup "id" attr
210+ let ident = fromMaybe "" $ lookup "id" attr
211211 let classes = maybe [] words $ lookup "class" attr
212212 let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"]
213213 return $ if bodyTitle
@@ -257,7 +257,7 @@ pCol = try $ do
257257 skipMany pBlank
258258 return $ case lookup "width" attribs of
259259 Just x | not (null x) && last x == '%' ->
260− maybe 0.0 id $ safeRead ('0':'.':init x)
260+ fromMaybe 0.0 $ safeRead ('0':'.':init x)
261261 _ -> 0.0
262262
263263pColgroup :: TagParser [Double]
src/Text/Pandoc/Readers/LaTeX.hs+2−3
@@ -874,9 +874,8 @@ verbatimEnv = do
874874 (_,r) <- withRaw $ do
875875 controlSeq "begin"
876876 name <- braced
877− guard $ name == "verbatim" || name == "Verbatim" ||
878− name == "lstlisting" || name == "minted" ||
879− name == "alltt"
877+ guard $ name `elem` ["verbatim", "Verbatim", "lstlisting",
878+ "minted", "alltt"]
880879 verbEnv name
881880 rest <- getInput
882881 return (r,rest)
src/Text/Pandoc/Readers/Markdown.hs+7−7
@@ -730,7 +730,7 @@ listStart = bulletListStart <|> (anyOrderedListStart >> return ())
730730listLine :: MarkdownParser String
731731listLine = try $ do
732732 notFollowedBy' (do indentSpaces
733− many (spaceChar)
733+ many spaceChar
734734 listStart)
735735 notFollowedBy' $ htmlTag (~== TagClose "div")
736736 chunks <- manyTill
@@ -789,8 +789,8 @@ listItem start = try $ do
789789orderedList :: MarkdownParser (F Blocks)
790790orderedList = try $ do
791791 (start, style, delim) <- lookAhead anyOrderedListStart
792− unless ((style == DefaultStyle || style == Decimal || style == Example) &&
793− (delim == DefaultDelim || delim == Period)) $
792+ unless (style `elem` [DefaultStyle, Decimal, Example] &&
793+ delim `elem` [DefaultDelim, Period]) $
794794 guardEnabled Ext_fancy_lists
795795 when (style == Example) $ guardEnabled Ext_example_lists
796796 items <- fmap sequence $ many1 $ listItem
@@ -925,8 +925,8 @@ strictHtmlBlock = htmlInBalanced (not . isInlineTag)
925925
926926rawVerbatimBlock :: MarkdownParser String
927927rawVerbatimBlock = try $ do
928− (TagOpen tag _, open) <- htmlTag (tagOpen (\t ->
929− t == "pre" || t == "style" || t == "script")
928+ (TagOpen tag _, open) <- htmlTag (tagOpen (flip elem
929+ ["pre", "style", "script"])
930930 (const True))
931931 contents <- manyTill anyChar (htmlTag (~== TagClose tag))
932932 return $ open ++ contents ++ renderTags [TagClose tag]
@@ -1722,7 +1722,7 @@ spanHtml = try $ do
17221722 guardEnabled Ext_markdown_in_html_blocks
17231723 (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "span" [])
17241724 contents <- mconcat <$> manyTill inline (htmlTag (~== TagClose "span"))
1725− let ident = maybe "" id $ lookup "id" attrs
1725+ let ident = fromMaybe "" $ lookup "id" attrs
17261726 let classes = maybe [] words $ lookup "class" attrs
17271727 let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
17281728 return $ B.spanWith (ident, classes, keyvals) <$> contents
@@ -1732,7 +1732,7 @@ divHtml = try $ do
17321732 guardEnabled Ext_markdown_in_html_blocks
17331733 (TagOpen _ attrs, _) <- htmlTag (~== TagOpen "div" [])
17341734 contents <- mconcat <$> manyTill block (htmlTag (~== TagClose "div"))
1735− let ident = maybe "" id $ lookup "id" attrs
1735+ let ident = fromMaybe "" $ lookup "id" attrs
17361736 let classes = maybe [] words $ lookup "class" attrs
17371737 let keyvals = [(k,v) | (k,v) <- attrs, k /= "id" && k /= "class"]
17381738 return $ B.divWith (ident, classes, keyvals) <$> contents
src/Text/Pandoc/Readers/MediaWiki.hs+4−3
@@ -54,6 +54,7 @@ import Data.Sequence (viewl, ViewL(..), (<|))
5454import qualified Data.Foldable as F
5555import qualified Data.Map as M
5656import Data.Char (isDigit, isSpace)
57+import Data.Maybe (fromMaybe)
5758
5859-- | Read mediawiki from an input string and return a Pandoc document.
5960readMediaWiki :: ReaderOptions -- ^ Reader options
@@ -204,7 +205,7 @@ table = do
204205 tableStart
205206 styles <- option [] parseAttrs <* blankline
206207 let tableWidth = case lookup "width" styles of
207− Just w -> maybe 1.0 id $ parseWidth w
208+ Just w -> fromMaybe 1.0 $ parseWidth w
208209 Nothing -> 1.0
209210 caption <- option mempty tableCaption
210211 optional rowsep
@@ -285,7 +286,7 @@ tableCell = try $ do
285286 Just "center" -> AlignCenter
286287 _ -> AlignDefault
287288 let width = case lookup "width" attrs of
288− Just xs -> maybe 0.0 id $ parseWidth xs
289+ Just xs -> fromMaybe 0.0 $ parseWidth xs
289290 Nothing -> 0.0
290291 return ((align, width), bs)
291292
@@ -387,7 +388,7 @@ orderedList =
387388 spaces
388389 items <- many (listItem '#' <|> li)
389390 optional (htmlTag (~== TagClose "ol"))
390− let start = maybe 1 id $ safeRead $ fromAttrib "start" tag
391+ let start = fromMaybe 1 $ safeRead $ fromAttrib "start" tag
391392 return $ B.orderedListWith (start, DefaultStyle, DefaultDelim) items
392393
393394definitionList :: MWParser Blocks
src/Text/Pandoc/Readers/Textile.hs+1−1
@@ -594,7 +594,7 @@ surrounded border = enclosed (border *> notFollowedBy (oneOf " \t\n\r")) (try bo
594594simpleInline :: Parser [Char] ParserState t -- ^ surrounding parser
595595 -> ([Inline] -> Inline) -- ^ Inline constructor
596596 -> Parser [Char] ParserState Inline -- ^ content parser (to be used repeatedly)
597−simpleInline border construct = surrounded border (inlineWithAttribute) >>=
597+simpleInline border construct = surrounded border inlineWithAttribute >>=
598598 return . construct . normalizeSpaces
599599 where inlineWithAttribute = (try $ optional attributes) >> inline
600600
src/Text/Pandoc/Shared.hs+5−9
@@ -532,7 +532,7 @@ headerShift n = walk shift
532532
533533-- | Detect if a list is tight.
534534isTightList :: [[Block]] -> Bool
535−isTightList = and . map firstIsPlain
535+isTightList = all firstIsPlain
536536 where firstIsPlain (Plain _ : _) = True
537537 firstIsPlain _ = False
538538
@@ -564,14 +564,10 @@ makeMeta title authors date =
564564-- | Render HTML tags.
565565renderTags' :: [Tag String] -> String
566566renderTags' = renderTagsOptions
567− renderOptions{ optMinimize = \x ->
568− let y = map toLower x
569− in y == "hr" || y == "br" ||
570− y == "img" || y == "meta" ||
571− y == "link"
572− , optRawTag = \x ->
573− let y = map toLower x
574− in y == "script" || y == "style" }
567+ renderOptions{ optMinimize = matchTags ["hr", "br", "img",
568+ "meta", "link"]
569+ , optRawTag = matchTags ["script", "style"] }
570+ where matchTags = \tags -> flip elem tags . map toLower
575571
576572--
577573-- File handling
src/Text/Pandoc/Writers/Docx.hs+4−2
@@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2929Conversion of 'Pandoc' documents to docx.
3030-}
3131module Text.Pandoc.Writers.Docx ( writeDocx ) where
32+import Data.Maybe (fromMaybe)
3233import Data.List ( intercalate, groupBy )
3334import qualified Data.ByteString as B
3435import qualified Data.ByteString.Lazy as BL
@@ -130,7 +131,8 @@ writeDocx opts doc@(Pandoc meta _) = do
130131 let mkOverrideNode (part', contentType') = mknode "Override"
131132 [("PartName",part'),("ContentType",contentType')] ()
132133 let mkImageOverride (_, imgpath, mbMimeType, _, _) =
133− mkOverrideNode ("/word/" ++ imgpath, maybe "application/octet-stream" id mbMimeType)
134+ mkOverrideNode ("/word/" ++ imgpath,
135+ fromMaybe "application/octet-stream" mbMimeType)
134136 let overrides = map mkOverrideNode
135137 [("/word/webSettings.xml",
136138 "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml")
@@ -322,7 +324,7 @@ mkNum markers marker numid =
322324 NumberMarker _ _ start ->
323325 map (\lvl -> mknode "w:lvlOverride" [("w:ilvl",show (lvl :: Int))]
324326 $ mknode "w:startOverride" [("w:val",show start)] ()) [0..6]
325− where absnumid = maybe 0 id $ M.lookup marker markers
327+ where absnumid = fromMaybe 0 $ M.lookup marker markers
326328
327329mkAbstractNum :: (ListMarker,Int) -> IO Element
328330mkAbstractNum (marker,numid) = do
src/Text/Pandoc/Writers/EPUB.hs+6−6
@@ -176,8 +176,8 @@ addMetadataFromXML e@(Element (QName name _ (Just "dc")) attrs _ _) md
176176 , titleFileAs = getAttr "file-as"
177177 , titleType = getAttr "type"
178178 } : epubTitle md }
179− | name == "date" = md{ epubDate = maybe "" id $ normalizeDate'
180− $ strContent e }
179+ | name == "date" = md{ epubDate = fromMaybe "" $ normalizeDate'
180+ $ strContent e }
181181 | name == "language" = md{ epubLanguage = strContent e }
182182 | name == "creator" = md{ epubCreator =
183183 Creator{ creatorText = strContent e
@@ -271,7 +271,7 @@ metadataFromMeta opts meta = EPUBMetadata{
271271 }
272272 where identifiers = getIdentifier meta
273273 titles = getTitle meta
274− date = maybe "" id $
274+ date = fromMaybe "" $
275275 (metaValueToString <$> lookupMeta "date" meta) >>= normalizeDate'
276276 language = maybe "" metaValueToString $
277277 lookupMeta "language" meta `mplus` lookupMeta "lang" meta
@@ -297,7 +297,7 @@ writeEPUB :: WriterOptions -- ^ Writer options
297297 -> Pandoc -- ^ Document to convert
298298 -> IO B.ByteString
299299writeEPUB opts doc@(Pandoc meta _) = do
300− let version = maybe EPUB2 id (writerEpubVersion opts)
300+ let version = fromMaybe EPUB2 (writerEpubVersion opts)
301301 let epub3 = version == EPUB3
302302 epochtime <- floor `fmap` getPOSIXTime
303303 let mkEntry path content = toEntry path epochtime content
@@ -401,7 +401,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
401401 chapToEntry num (Chapter mbnum bs) = mkEntry (showChapter num)
402402 $ renderHtml
403403 $ writeHtml opts'{ writerNumberOffset =
404− maybe [] id mbnum }
404+ fromMaybe [] mbnum }
405405 $ case bs of
406406 (Header _ _ xs : _) ->
407407 Pandoc (setMeta "title" (fromList xs) nullMeta) bs
@@ -436,7 +436,7 @@ writeEPUB opts doc@(Pandoc meta _) = do
436436 let fontNode ent = unode "item" !
437437 [("id", takeBaseName $ eRelativePath ent),
438438 ("href", eRelativePath ent),
439− ("media-type", maybe "" id $ getMimeType $ eRelativePath ent)] $ ()
439+ ("media-type", fromMaybe "" $ getMimeType $ eRelativePath ent)] $ ()
440440 let plainTitle = case docTitle meta of
441441 [] -> case epubTitle metadata of
442442 [] -> "UNTITLED"
src/Text/Pandoc/Writers/HTML.hs+3−3
@@ -45,7 +45,7 @@ import Numeric ( showHex )
4545import Data.Char ( ord, toLower )
4646import Data.List ( isPrefixOf, intersperse )
4747import Data.String ( fromString )
48−import Data.Maybe ( catMaybes )
48+import Data.Maybe ( catMaybes, fromMaybe )
4949import Control.Monad.State
5050import Text.Blaze.Html hiding(contents)
5151import Text.Blaze.Internal(preEscapedString)
@@ -118,7 +118,7 @@ pandocToHtml opts (Pandoc meta blocks) = do
118118 let stringifyHTML = escapeStringForXML . stringify
119119 let authsMeta = map stringifyHTML $ docAuthors meta
120120 let dateMeta = stringifyHTML $ docDate meta
121− let slideLevel = maybe (getSlideLevel blocks) id $ writerSlideLevel opts
121+ let slideLevel = fromMaybe (getSlideLevel blocks) $ writerSlideLevel opts
122122 let sects = hierarchicalize $
123123 if writerSlideVariant opts == NoSlides
124124 then blocks
@@ -524,7 +524,7 @@ blockToHtml opts (DefinitionList lst) = do
524524 contents <- mapM (\(term, defs) ->
525525 do term' <- if null term
526526 then return mempty
527− else liftM (H.dt) $ inlineListToHtml opts term
527+ else liftM H.dt $ inlineListToHtml opts term
528528 defs' <- mapM ((liftM (\x -> H.dd $ (x >> nl opts))) .
529529 blockListToHtml opts) defs
530530 return $ mconcat $ nl opts : term' : nl opts :
src/Text/Pandoc/Writers/LaTeX.hs+7−6
@@ -40,6 +40,7 @@ import Network.URI ( isURI, unEscapeString )
4040import Data.List ( (\\), isSuffixOf, isInfixOf,
4141 isPrefixOf, intercalate, intersperse )
4242import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
43+import Data.Maybe ( fromMaybe )
4344import Control.Applicative ((<|>))
4445import Control.Monad.State
4546import Text.Pandoc.Pretty
@@ -190,7 +191,7 @@ stringToLaTeX _ [] = return ""
190191stringToLaTeX ctx (x:xs) = do
191192 opts <- gets stOptions
192193 rest <- stringToLaTeX ctx xs
193− let ligatures = writerTeXLigatures opts && not (ctx == CodeString)
194+ let ligatures = writerTeXLigatures opts && (ctx /= CodeString)
194195 let isUrl = ctx == URLString
195196 when (x == '€') $
196197 modify $ \st -> st{ stUsesEuro = True }
@@ -240,7 +241,7 @@ inCmd cmd contents = char '\\' <> text cmd <> braces contents
240241toSlides :: [Block] -> State WriterState [Block]
241242toSlides bs = do
242243 opts <- gets stOptions
243− let slideLevel = maybe (getSlideLevel bs) id $ writerSlideLevel opts
244+ let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts
244245 let bs' = prepSlides slideLevel bs
245246 concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs')
246247
@@ -443,7 +444,7 @@ blockToLaTeX (DefinitionList lst) = do
443444 incremental <- gets stIncremental
444445 let inc = if incremental then "[<+->]" else ""
445446 items <- mapM defListItemToLaTeX lst
446− let spacing = if and $ map isTightList (map snd lst)
447+ let spacing = if all isTightList (map snd lst)
447448 then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
448449 else empty
449450 return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$
@@ -764,9 +765,9 @@ citationsToNatbib cits
764765 | noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits
765766 = citeCommand "citep" p s ks
766767 where
767− noPrefix = and . map (null . citationPrefix)
768− noSuffix = and . map (null . citationSuffix)
769− ismode m = and . map (((==) m) . citationMode)
768+ noPrefix = all (null . citationPrefix)
769+ noSuffix = all (null . citationSuffix)
770+ ismode m = all (((==) m) . citationMode)
770771 p = citationPrefix $ head $ cits
771772 s = citationSuffix $ last $ cits
772773 ks = intercalate ", " $ map citationId cits
src/Text/Pandoc/Writers/Markdown.hs+6−5
@@ -338,7 +338,7 @@ blockToMarkdown opts (RawBlock f str)
338338 else return $ if isEnabled Ext_markdown_attribute opts
339339 then text (addMarkdownAttribute str) <> text "\n"
340340 else text str <> text "\n"
341− | f == "latex" || f == "tex" || f == "markdown" = do
341+ | f `elem` ["latex", "tex", "markdown"] = do
342342 st <- get
343343 if stPlain st
344344 then return empty
@@ -628,10 +628,11 @@ getReference label (src, tit) = do
628628 Nothing -> do
629629 let label' = case find ((== label) . fst) (stRefs st) of
630630 Just _ -> -- label is used; generate numerical label
631− case find (\n -> not (any (== [Str (show n)])
632− (map fst (stRefs st)))) [1..(10000 :: Integer)] of
633− Just x -> [Str (show x)]
634− Nothing -> error "no unique label"
631+ case find (\n -> notElem [Str (show n)]
632+ (map fst (stRefs st)))
633+ [1..(10000 :: Integer)] of
634+ Just x -> [Str (show x)]
635+ Nothing -> error "no unique label"
635636 Nothing -> label
636637 modify (\s -> s{ stRefs = (label', (src,tit)) : stRefs st })
637638 return label'
src/Text/Pandoc/Writers/MediaWiki.hs+1−1
@@ -51,7 +51,7 @@ data WriterState = WriterState {
5151writeMediaWiki :: WriterOptions -> Pandoc -> String
5252writeMediaWiki opts document =
5353 evalState (pandocToMediaWiki opts document)
54− (WriterState { stNotes = False, stListLevel = [], stUseTags = False })
54+ WriterState { stNotes = False, stListLevel = [], stUseTags = False }
5555
5656-- | Return MediaWiki representation of document.
5757pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
src/Text/Pandoc/Writers/ODT.hs+2−1
@@ -31,6 +31,7 @@ Conversion of 'Pandoc' documents to ODT.
3131module Text.Pandoc.Writers.ODT ( writeODT ) where
3232import Data.IORef
3333import Data.List ( isPrefixOf )
34+import Data.Maybe ( fromMaybe )
3435import qualified Data.ByteString.Lazy as B
3536import Text.Pandoc.UTF8 ( fromStringLazy )
3637import Codec.Archive.Zip
@@ -127,7 +128,7 @@ transformPic opts entriesRef (Image lab (src,_)) = do
127128 return $ Emph lab
128129 Right (img, _) -> do
129130 let size = imageSize img
130− let (w,h) = maybe (0,0) id $ sizeInPoints `fmap` size
131+ let (w,h) = fromMaybe (0,0) $ sizeInPoints `fmap` size
131132 let tit' = show w ++ "x" ++ show h
132133 entries <- readIORef entriesRef
133134 let newsrc = "Pictures/" ++ show (length entries) ++ takeExtension src
src/Text/Pandoc/Writers/Org.hs+1−1
@@ -129,7 +129,7 @@ blockToOrg (Para inlines) = do
129129blockToOrg (RawBlock "html" str) =
130130 return $ blankline $$ "#+BEGIN_HTML" $$
131131 nest 2 (text str) $$ "#+END_HTML" $$ blankline
132−blockToOrg (RawBlock f str) | f == "org" || f == "latex" || f == "tex" =
132+blockToOrg (RawBlock f str) | f `elem` ["org", "latex", "tex"] =
133133 return $ text str
134134blockToOrg (RawBlock _ _) = return empty
135135blockToOrg HorizontalRule = return $ blankline $$ "--------------" $$ blankline
src/Text/Pandoc/Writers/Shared.hs+1−2
@@ -65,8 +65,7 @@ metaToJSON opts blockWriter inlineWriter (Meta metamap)
6565 renderedMap <- Traversable.mapM
6666 (metaValueToJSON blockWriter inlineWriter)
6767 metamap
68− return $ M.foldWithKey (\key val obj -> defField key val obj)
69− baseContext renderedMap
68+ return $ M.foldWithKey defField baseContext renderedMap
7069 | otherwise = return (Object H.empty)
7170
7271metaValueToJSON :: Monad m
src/Text/Pandoc/Writers/Textile.hs+1−1
@@ -51,7 +51,7 @@ data WriterState = WriterState {
5151writeTextile :: WriterOptions -> Pandoc -> String
5252writeTextile opts document =
5353 evalState (pandocToTextile opts document)
54− (WriterState { stNotes = [], stListLevel = [], stUseTags = False })
54+ WriterState { stNotes = [], stListLevel = [], stUseTags = False }
5555
5656-- | Return Textile representation of document.
5757pandocToTextile :: WriterOptions -> Pandoc -> State WriterState String
tests/Tests/Readers/LaTeX.hs+1−1
@@ -21,7 +21,7 @@ tests = [ testGroup "basic"
2121 [ "simple" =:
2222 "word" =?> para "word"
2323 , "space" =:
24− "some text" =?> para ("some text")
24+ "some text" =?> para "some text"
2525 , "emphasized" =:
2626 "\\emph{emphasized}" =?> para (emph "emphasized")
2727 ]
tests/Tests/Readers/Markdown.hs+2−2
@@ -171,13 +171,13 @@ tests = [ testGroup "inline code"
171171 , testGroup "smart punctuation"
172172 [ test markdownSmart "quote before ellipses"
173173 ("'...hi'"
174− =?> para (singleQuoted ("…hi")))
174+ =?> para (singleQuoted "…hi"))
175175 , test markdownSmart "apostrophe before emph"
176176 ("D'oh! A l'*aide*!"
177177 =?> para ("D’oh! A l’" <> emph "aide" <> "!"))
178178 , test markdownSmart "apostrophe in French"
179179 ("À l'arrivée de la guerre, le thème de l'«impossibilité du socialisme»"
180− =?> para ("À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»"))
180+ =?> para "À l’arrivée de la guerre, le thème de l’«impossibilité du socialisme»")
181181 ]
182182 , testGroup "mixed emphasis and strong"
183183 [ "emph and strong emph alternating" =:
tests/Tests/Walk.hs+2−2
@@ -21,11 +21,11 @@ tests = [ testGroup "Walk"
2121
2222p_walk :: (Typeable a, Walkable a Pandoc)
2323 => (a -> a) -> Pandoc -> Bool
24−p_walk f = (\(d :: Pandoc) -> everywhere (mkT f) d == walk f d)
24+p_walk f d = everywhere (mkT f) d == walk f d
2525
2626p_query :: (Eq a, Typeable a1, Monoid a, Walkable a1 Pandoc)
2727 => (a1 -> a) -> Pandoc -> Bool
28−p_query f = (\(d :: Pandoc) -> everything mappend (mempty `mkQ` f) d == query f d)
28+p_query f d = everything mappend (mempty `mkQ` f) d == query f d
2929
3030inlineTrans :: Inline -> Inline
3131inlineTrans (Str xs) = Str $ map toUpper xs