@@ -99,10 +99,10 @@ module Text.Pandoc.Shared (
100import Text.Pandoc.Definition
100import Text.Pandoc.Definition
101import Text.ParserCombinators.Parsec
101import Text.ParserCombinators.Parsec
102−import Text.PrettyPrint.HughesPJ ( Doc (..), fsep )
102+import Text.PrettyPrint.HughesPJ ( Doc, fsep )
103import Text.Pandoc.CharacterReferences ( characterReference )
103import Text.Pandoc.CharacterReferences ( characterReference )
104−import Data.Char ( toLower, toUpper, ord, chr, isLower, isUpper )
104+import Data.Char ( toLower, toUpper, ord, isLower, isUpper )
105−import Data.List ( find, groupBy, isPrefixOf, isSuffixOf )
105+import Data.List ( find, isPrefixOf )
106import Control.Monad ( join )
106import Control.Monad ( join )
@@ -137,7 +137,7 @@ substitute target replacement lst =
137joinWithSep :: [a] -- ^ List to use as separator
137joinWithSep :: [a] -- ^ List to use as separator
138 -> [[a]] -- ^ Lists to join
138 -> [[a]] -- ^ Lists to join
140−joinWithSep sep [] = []
140+joinWithSep _ [] = []
141joinWithSep sep lst = foldr1 (\a b -> a ++ sep ++ b) lst
141joinWithSep sep lst = foldr1 (\a b -> a ++ sep ++ b) lst
@@ -153,7 +153,7 @@ backslashEscapes = map (\ch -> (ch, ['\\',ch]))
153-- | Escape a string of characters, using an association list of
153-- | Escape a string of characters, using an association list of
154-- characters and strings.
154-- characters and strings.
155escapeStringUsing :: [(Char, String)] -> String -> String
155escapeStringUsing :: [(Char, String)] -> String -> String
156−escapeStringUsing escapeTable [] = ""
156+escapeStringUsing _ [] = ""
157escapeStringUsing escapeTable (x:xs) =
157escapeStringUsing escapeTable (x:xs) =
158 case (lookup x escapeTable) of
158 case (lookup x escapeTable) of
159 Just str -> str ++ rest
159 Just str -> str ++ rest
@@ -194,20 +194,20 @@ toRomanNumeral x =
194 if x >= 4000 || x < 0
194 if x >= 4000 || x < 0
196 else case x of
196 else case x of
197− x | x >= 1000 -> "M" ++ toRomanNumeral (x - 1000)
197+ _ | x >= 1000 -> "M" ++ toRomanNumeral (x - 1000)
198− x | x >= 900 -> "CM" ++ toRomanNumeral (x - 900)
198+ _ | x >= 900 -> "CM" ++ toRomanNumeral (x - 900)
199− x | x >= 500 -> "D" ++ toRomanNumeral (x - 500)
199+ _ | x >= 500 -> "D" ++ toRomanNumeral (x - 500)
200− x | x >= 400 -> "CD" ++ toRomanNumeral (x - 400)
200+ _ | x >= 400 -> "CD" ++ toRomanNumeral (x - 400)
201− x | x >= 100 -> "C" ++ toRomanNumeral (x - 100)
201+ _ | x >= 100 -> "C" ++ toRomanNumeral (x - 100)
202− x | x >= 90 -> "XC" ++ toRomanNumeral (x - 90)
202+ _ | x >= 90 -> "XC" ++ toRomanNumeral (x - 90)
203− x | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
203+ _ | x >= 50 -> "L" ++ toRomanNumeral (x - 50)
204− x | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
204+ _ | x >= 40 -> "XL" ++ toRomanNumeral (x - 40)
205− x | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
205+ _ | x >= 10 -> "X" ++ toRomanNumeral (x - 10)
206− x | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
206+ _ | x >= 9 -> "IX" ++ toRomanNumeral (x - 5)
207− x | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
207+ _ | x >= 5 -> "V" ++ toRomanNumeral (x - 5)
208− x | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
208+ _ | x >= 4 -> "IV" ++ toRomanNumeral (x - 4)
209− x | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
209+ _ | x >= 1 -> "I" ++ toRomanNumeral (x - 1)
212-- | Wrap inlines to line length.
212-- | Wrap inlines to line length.
213wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
213wrapped :: Monad m => ([Inline] -> m Doc) -> [Inline] -> m Doc
@@ -294,9 +294,9 @@ parseFromString parser str = do
294-- | Parse raw line block up to and including blank lines.
294-- | Parse raw line block up to and including blank lines.
295lineClump :: GenParser Char st String
295lineClump :: GenParser Char st String
296lineClump = do
296lineClump = do
297− lines <- many1 (notFollowedBy blankline >> anyLine)
297+ lns <- many1 (notFollowedBy blankline >> anyLine)
298 blanks <- blanklines <|> (eof >> return "\n")
298 blanks <- blanklines <|> (eof >> return "\n")
299− return $ (unlines lines) ++ blanks
299+ return $ (unlines lns) ++ blanks
301-- | Parse a string of characters between an open character
301-- | Parse a string of characters between an open character
302-- and a close character, including text between balanced
302-- and a close character, including text between balanced
@@ -327,8 +327,8 @@ charsInBalanced' open close = try $ do
327-- | Parses a roman numeral (uppercase or lowercase), returns number.
327-- | Parses a roman numeral (uppercase or lowercase), returns number.
328romanNumeral :: Bool -- ^ Uppercase if true
328romanNumeral :: Bool -- ^ Uppercase if true
329 -> GenParser Char st Int
329 -> GenParser Char st Int
330−romanNumeral upper = do
330+romanNumeral upperCase = do
331− let charAnyCase c = char (if upper then toUpper c else c)
331+ let charAnyCase c = char (if upperCase then toUpper c else c)
332 let one = charAnyCase 'i'
332 let one = charAnyCase 'i'
333 let five = charAnyCase 'v'
333 let five = charAnyCase 'v'
334 let ten = charAnyCase 'x'
334 let ten = charAnyCase 'x'
@@ -481,7 +481,7 @@ orderedListMarker style delim = do
481 Period -> inPeriod
481 Period -> inPeriod
482 OneParen -> inOneParen
482 OneParen -> inOneParen
483 TwoParens -> inTwoParens
483 TwoParens -> inTwoParens
484− (start, style, delim) <- context num
484+ (start, _, _) <- context num
485 return start
485 return start
487-- | Parses a character reference and returns a Str element.
487-- | Parses a character reference and returns a Str element.
@@ -626,7 +626,7 @@ indentBy :: Int -- ^ Number of spaces to indent the block
626 -> Int -- ^ Number of spaces (rel to block) to indent first line
626 -> Int -- ^ Number of spaces (rel to block) to indent first line
627 -> String -- ^ Contents of block to indent
627 -> String -- ^ Contents of block to indent
628 -> String
628 -> String
629−indentBy num first [] = ""
629+indentBy _ _ [] = ""
630indentBy num first str =
630indentBy num first str =
631 let (firstLine:restLines) = lines str
631 let (firstLine:restLines) = lines str
632 firstLineIndent = num + first
632 firstLineIndent = num + first
@@ -679,21 +679,21 @@ prettyPandoc (Pandoc meta blocks) = "Pandoc " ++ "(" ++ show meta ++
679orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
679orderedListMarkers :: (Int, ListNumberStyle, ListNumberDelim) -> [String]
680orderedListMarkers (start, numstyle, numdelim) =
680orderedListMarkers (start, numstyle, numdelim) =
681 let singleton c = [c]
681 let singleton c = [c]
682− seq = case numstyle of
682+ nums = case numstyle of
683− DefaultStyle -> map show [start..]
683+ DefaultStyle -> map show [start..]
684− Decimal -> map show [start..]
684+ Decimal -> map show [start..]
685− UpperAlpha -> drop (start - 1) $ cycle $
685+ UpperAlpha -> drop (start - 1) $ cycle $
686− map singleton ['A'..'Z']
686+ map singleton ['A'..'Z']
687− LowerAlpha -> drop (start - 1) $ cycle $
687+ LowerAlpha -> drop (start - 1) $ cycle $
688− map singleton ['a'..'z']
688+ map singleton ['a'..'z']
689− UpperRoman -> map toRomanNumeral [start..]
689+ UpperRoman -> map toRomanNumeral [start..]
690− LowerRoman -> map (map toLower . toRomanNumeral) [start..]
690+ LowerRoman -> map (map toLower . toRomanNumeral) [start..]
691 inDelim str = case numdelim of
691 inDelim str = case numdelim of
692 DefaultDelim -> str ++ "."
692 DefaultDelim -> str ++ "."
693 Period -> str ++ "."
693 Period -> str ++ "."
694 OneParen -> str ++ ")"
694 OneParen -> str ++ ")"
695 TwoParens -> "(" ++ str ++ ")"
695 TwoParens -> "(" ++ str ++ ")"
696− in map inDelim seq
696+ in map inDelim nums
698-- | Normalize a list of inline elements: remove leading and trailing
698-- | Normalize a list of inline elements: remove leading and trailing
699-- @Space@ elements, collapse double @Space@s into singles, and
699-- @Space@ elements, collapse double @Space@s into singles, and
@@ -726,18 +726,18 @@ compactify items =
726 [Para a] -> if any containsPara others
726 [Para a] -> if any containsPara others
727 then items
727 then items
728 else others ++ [[Plain a]]
728 else others ++ [[Plain a]]
729− otherwise -> items
729+ _ -> items
731containsPara :: [Block] -> Bool
731containsPara :: [Block] -> Bool
732containsPara [] = False
732containsPara [] = False
733−containsPara ((Para a):rest) = True
733+containsPara ((Para _):_) = True
734containsPara ((BulletList items):rest) = any containsPara items ||
734containsPara ((BulletList items):rest) = any containsPara items ||
735 containsPara rest
735 containsPara rest
736containsPara ((OrderedList _ items):rest) = any containsPara items ||
736containsPara ((OrderedList _ items):rest) = any containsPara items ||
737 containsPara rest
737 containsPara rest
738containsPara ((DefinitionList items):rest) = any containsPara (map snd items) ||
738containsPara ((DefinitionList items):rest) = any containsPara (map snd items) ||
739 containsPara rest
739 containsPara rest
740−containsPara (x:rest) = containsPara rest
740+containsPara (_:rest) = containsPara rest
742-- | Data structure for defining hierarchical Pandoc documents
742-- | Data structure for defining hierarchical Pandoc documents
743data Element = Blk Block
743data Element = Blk Block
@@ -746,7 +746,7 @@ data Element = Blk Block
746-- | Returns @True@ on Header block with at least the specified level
746-- | Returns @True@ on Header block with at least the specified level
747headerAtLeast :: Int -> Block -> Bool
747headerAtLeast :: Int -> Block -> Bool
748headerAtLeast level (Header x _) = x <= level
748headerAtLeast level (Header x _) = x <= level
749−headerAtLeast level _ = False
749+headerAtLeast _ _ = False
751-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
751-- | Convert list of Pandoc blocks into (hierarchical) list of Elements
752hierarchicalize :: [Block] -> [Element]
752hierarchicalize :: [Block] -> [Element]
@@ -787,6 +787,7 @@ data WriterOptions = WriterOptions
787 } deriving Show
787 } deriving Show
789-- | Default writer options.
789-- | Default writer options.
790+defaultWriterOptions :: WriterOptions
790defaultWriterOptions =
791defaultWriterOptions =
791 WriterOptions { writerStandalone = False,
792 WriterOptions { writerStandalone = False,
792 writerHeader = "",
793 writerHeader = "",