@@ -99,10 +99,10 @@ module Text.Pandoc.Shared (
9999
100100import Text.Pandoc.Definition
101101import Text.ParserCombinators.Parsec
102−import Text.PrettyPrint.HughesPJ ( Doc (..), fsep )
102+import Text.PrettyPrint.HughesPJ ( Doc, fsep )
103103import Text.Pandoc.CharacterReferences ( characterReference )
104−import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
105−import Data.List ( find, groupBy, isPrefixOf, isSuffixOf )
104+import Data.Char ( toLower, toUpper, ord, isLower, isUpper )
105+import Data.List ( find, isPrefixOf )
106106import Control.Monad ( join )
107107
108108--
@@ -137,7 +137,7 @@ substitute target replacement lst =
137137joinWithSep :: [a] -- ^ List to use as separator
138138 -> [[a]] -- ^ Lists to join
139139 -> [a]
140−joinWithSep sep [] = []
140+joinWithSep _ [] = []
141141joinWithSep sep lst = foldr1 (\a b -> a ++ sep ++ b) lst
142142
143143--
@@ -153,7 +153,7 @@ backslashEscapes = map (\ch -> (ch, ['\\',ch]))
153153-- | Escape a string of characters, using an association list of
154154-- characters and strings.
155155escapeStringUsing :: [(Char, String)] -> String -> String
156−escapeStringUsing escapeTable [] = ""
156+escapeStringUsing _ [] = ""
157157escapeStringUsing escapeTable (x:xs) =
158158 case (lookup x escapeTable) of
159159 Just str -> str ++ rest
@@ -194,20 +194,20 @@ toRomanNumeral x =
194194 if x >= 4000 || x < 0
195195 then "?"
196196 else case x of
197− x | x >= 1000 -> "M" ++ toRomanNumeral (x - 1000)
198− x | x >= 900 -> "CM" ++ toRomanNumeral (x - 900)
199− x | x >= 500 -> "D" ++ toRomanNumeral (x - 500)
200− x | x >= 400 -> "CD" ++ toRomanNumeral (x - 400)
201− x | x >= 100 -> "C" ++ toRomanNumeral (x - 100)
202− x | x >= 90 -> "XC" ++ toRomanNumeral (x - 90)
203− x | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
204− x | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
205− x | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
206− x | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
207− x | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
208− x | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
209− x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
210− 0 -> ""
197+ _ | x >= 1000 -> "M" ++ toRomanNumeral (x - 1000)
198+ _ | x >= 900 -> "CM" ++ toRomanNumeral (x - 900)
199+ _ | x >= 500 -> "D" ++ toRomanNumeral (x - 500)
200+ _ | x >= 400 -> "CD" ++ toRomanNumeral (x - 400)
201+ _ | x >= 100 -> "C" ++ toRomanNumeral (x - 100)
202+ _ | x >= 90 -> "XC" ++ toRomanNumeral (x - 90)
203+ _ | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
204+ _ | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
205+ _ | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
206+ _ | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
207+ _ | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
208+ _ | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
209+ _ | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
210+ _ -> ""
211211
212212-- | Wrap inlines to line length.
213213wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
@@ -294,9 +294,9 @@ parseFromString parser str = do
294294-- | Parse raw line block up to and including blank lines.
295295lineClump :: GenParser Char st String
296296lineClump = do
297− lines <- many1 (notFollowedBy blankline >> anyLine)
297+ lns <- many1 (notFollowedBy blankline >> anyLine)
298298 blanks <- blanklines <|> (eof >> return "\n")
299− return $ (unlines lines) ++ blanks
299+ return $ (unlines lns) ++ blanks
300300
301301-- | Parse a string of characters between an open character
302302-- and a close character, including text between balanced
@@ -327,8 +327,8 @@ charsInBalanced' open close = try $ do
327327-- | Parses a roman numeral (uppercase or lowercase), returns number.
328328romanNumeral :: Bool -- ^ Uppercase if true
329329 -> GenParser Char st Int
330−romanNumeral upper = do
331− let charAnyCase c = char (if upper then toUpper c else c)
330+romanNumeral upperCase = do
331+ let charAnyCase c = char (if upperCase then toUpper c else c)
332332 let one = charAnyCase 'i'
333333 let five = charAnyCase 'v'
334334 let ten = charAnyCase 'x'
@@ -481,7 +481,7 @@ orderedListMarker style delim = do
481481 Period -> inPeriod
482482 OneParen -> inOneParen
483483 TwoParens -> inTwoParens
484− (start, style, delim) <- context num
484+ (start, _, _) <- context num
485485 return start
486486
487487-- | Parses a character reference and returns a Str element.
@@ -626,7 +626,7 @@ indentBy :: Int -- ^ Number of spaces to indent the block
626626 -> Int -- ^ Number of spaces (rel to block) to indent first line
627627 -> String -- ^ Contents of block to indent
628628 -> String
629−indentBy num first [] = ""
629+indentBy _ _ [] = ""
630630indentBy num first str =
631631 let (firstLine:restLines) = lines str
632632 firstLineIndent = num + first
@@ -679,21 +679,21 @@ prettyPandoc (Pandoc meta blocks) = "Pandoc " ++ "(" ++ show meta ++
679679orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
680680orderedListMarkers (start, numstyle, numdelim) =
681681 let singleton c = [c]
682− seq = case numstyle of
683− DefaultStyle -> map show [start..]
684− Decimal -> map show [start..]
685− UpperAlpha -> drop (start - 1) $ cycle $
686− map singleton ['A'..'Z']
687− LowerAlpha -> drop (start - 1) $ cycle $
688− map singleton ['a'..'z']
689− UpperRoman -> map toRomanNumeral [start..]
690− LowerRoman -> map (map toLower . toRomanNumeral) [start..]
682+ nums = case numstyle of
683+ DefaultStyle -> map show [start..]
684+ Decimal -> map show [start..]
685+ UpperAlpha -> drop (start - 1) $ cycle $
686+ map singleton ['A'..'Z']
687+ LowerAlpha -> drop (start - 1) $ cycle $
688+ map singleton ['a'..'z']
689+ UpperRoman -> map toRomanNumeral [start..]
690+ LowerRoman -> map (map toLower . toRomanNumeral) [start..]
691691 inDelim str = case numdelim of
692692 DefaultDelim -> str ++ "."
693693 Period -> str ++ "."
694694 OneParen -> str ++ ")"
695695 TwoParens -> "(" ++ str ++ ")"
696− in map inDelim seq
696+ in map inDelim nums
697697
698698-- | Normalize a list of inline elements: remove leading and trailing
699699-- @Space@ elements, collapse double @Space@s into singles, and
@@ -726,18 +726,18 @@ compactify items =
726726 [Para a] -> if any containsPara others
727727 then items
728728 else others ++ [[Plain a]]
729− otherwise -> items
729+ _ -> items
730730
731731containsPara :: [Block] -> Bool
732732containsPara [] = False
733−containsPara ((Para a):rest) = True
733+containsPara ((Para _):_) = True
734734containsPara ((BulletList items):rest) = any containsPara items ||
735735 containsPara rest
736736containsPara ((OrderedList _ items):rest) = any containsPara items ||
737737 containsPara rest
738738containsPara ((DefinitionList items):rest) = any containsPara (map snd items) ||
739739 containsPara rest
740−containsPara (x:rest) = containsPara rest
740+containsPara (_:rest) = containsPara rest
741741
742742-- | Data structure for defining hierarchical Pandoc documents
743743data Element = Blk Block
@@ -746,7 +746,7 @@ data Element = Blk Block
746746-- | Returns @True@ on Header block with at least the specified level
747747headerAtLeast :: Int -> Block -> Bool
748748headerAtLeast level (Header x _) = x <= level
749−headerAtLeast level _ = False
749+headerAtLeast _ _ = False
750750
751751-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
752752hierarchicalize :: [Block] -> [Element]
@@ -787,6 +787,7 @@ data WriterOptions = WriterOptions
787787 } deriving Show
788788
789789-- | Default writer options.
790+defaultWriterOptions :: WriterOptions
790791defaultWriterOptions =
791792 WriterOptions { writerStandalone = False,
792793 writerHeader = "",