@@ -42,20 +42,18 @@ import Text.Pandoc.Options
42import Text.Pandoc.Parsing hiding ((<|>), many, optional, space,
42import Text.Pandoc.Parsing hiding ((<|>), many, optional, space,
43 mathDisplay, mathInline)
43 mathDisplay, mathInline)
44import qualified Text.Pandoc.UTF8 as UTF8
44import qualified Text.Pandoc.UTF8 as UTF8
45−import Data.Char ( chr, ord )
45+import Data.Char ( chr, ord, isLetter, isAlphaNum )
46import Control.Monad.Trans (lift)
46import Control.Monad.Trans (lift)
47import Control.Monad
47import Control.Monad
48import Text.Pandoc.Builder
48import Text.Pandoc.Builder
49−import Data.Char (isLetter, isAlphaNum)
50import Control.Applicative
49import Control.Applicative
51import Data.Monoid
50import Data.Monoid
52−import Data.Maybe (fromMaybe)
51+import Data.Maybe (fromMaybe, maybeToList)
53import System.Environment (getEnv)
52import System.Environment (getEnv)
54−import System.FilePath (replaceExtension, (</>))
53+import System.FilePath (replaceExtension, (</>), takeExtension, addExtension)
55−import Data.List (intercalate, intersperse)
54+import Data.List (intercalate)
56import qualified Data.Map as M
55import qualified Data.Map as M
57import qualified Control.Exception as E
56import qualified Control.Exception as E
58−import System.FilePath (takeExtension, addExtension)
59import Text.Pandoc.Highlighting (fromListingsLanguage)
57import Text.Pandoc.Highlighting (fromListingsLanguage)
60import Text.Pandoc.Error
58import Text.Pandoc.Error
@@ -74,17 +72,16 @@ parseLaTeX = do
74 let (Pandoc _ bs') = doc bs
72 let (Pandoc _ bs') = doc bs
75 return $ Pandoc meta bs'
73 return $ Pandoc meta bs'
77−type LP = Parser [Char] ParserState
75+type LP = Parser String ParserState
79anyControlSeq :: LP String
77anyControlSeq :: LP String
80anyControlSeq = do
78anyControlSeq = do
82 next <- option '\n' anyChar
80 next <- option '\n' anyChar
83− name <- case next of
81+ case next of
84− '\n' -> return ""
82+ '\n' -> return ""
85− c | isLetter c -> (c:) <$> (many letter <* optional sp)
83+ c | isLetter c -> (c:) <$> (many letter <* optional sp)
86− | otherwise -> return [c]
84+ | otherwise -> return [c]
89controlSeq :: String -> LP String
86controlSeq :: String -> LP String
90controlSeq name = try $ do
87controlSeq name = try $ do
@@ -104,7 +101,7 @@ dimenarg = try $ do
105sp :: LP ()
102sp :: LP ()
106sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
103sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t')
107− <|> (try $ newline <* lookAhead anyChar <* notFollowedBy blankline)
104+ <|> try (newline <* lookAhead anyChar <* notFollowedBy blankline)
109isLowerHex :: Char -> Bool
106isLowerHex :: Char -> Bool
110isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
107isLowerHex x = x >= '0' && x <= '9' || x >= 'a' && x <= 'f'
@@ -162,30 +159,28 @@ mathInline :: LP String -> LP Inlines
162mathInline p = math <$> (try p >>= applyMacros')
159mathInline p = math <$> (try p >>= applyMacros')
164mathChars :: LP String
161mathChars :: LP String
165−mathChars = concat <$>
162+mathChars = (concat <$>) $
166− many ( many1 (satisfy (\c -> c /= '$' && c /='\\'))
164+ many1 (satisfy (\c -> c /= '$' && c /='\\'))
167− <|> (\c -> ['\\',c]) <$> (try $ char '\\' *> anyChar)
165+ <|> (\c -> ['\\',c]) <$> try (char '\\' *> anyChar)
170quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
167quoted' :: (Inlines -> Inlines) -> LP String -> LP () -> LP Inlines
171quoted' f starter ender = do
168quoted' f starter ender = do
172 startchs <- starter
169 startchs <- starter
173 try ((f . mconcat) <$> manyTill inline ender) <|> lit startchs
170 try ((f . mconcat) <$> manyTill inline ender) <|> lit startchs
175−double_quote :: LP Inlines
172+doubleQuote :: LP Inlines
176−double_quote =
173+doubleQuote =
177− ( quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
174+ quoted' doubleQuoted (try $ string "``") (void $ try $ string "''")
178 <|> quoted' doubleQuoted (string "“") (void $ char '”')
175 <|> quoted' doubleQuoted (string "“") (void $ char '”')
179 -- the following is used by babel for localized quotes:
176 -- the following is used by babel for localized quotes:
180 <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
177 <|> quoted' doubleQuoted (try $ string "\"`") (void $ try $ string "\"'")
181 <|> quoted' doubleQuoted (string "\"") (void $ char '"')
178 <|> quoted' doubleQuoted (string "\"") (void $ char '"')
184−single_quote :: LP Inlines
180+singleQuote :: LP Inlines
185−single_quote =
181+singleQuote =
186− ( quoted' singleQuoted (string "`") (try $ char '\'' >> notFollowedBy letter)
182+ quoted' singleQuoted (string "`") (try $ char '\'' >> notFollowedBy letter)
187 <|> quoted' singleQuoted (string "‘") (try $ char '’' >> notFollowedBy letter)
183 <|> quoted' singleQuoted (string "‘") (try $ char '’' >> notFollowedBy letter)
190inline :: LP Inlines
185inline :: LP Inlines
191inline = (mempty <$ comment)
186inline = (mempty <$ comment)
@@ -195,17 +190,17 @@ inline = (mempty <$ comment)
195 <|> inlineEnvironment
190 <|> inlineEnvironment
196 <|> inlineGroup
191 <|> inlineGroup
197 <|> (char '-' *> option (str "-")
192 <|> (char '-' *> option (str "-")
198− ((char '-') *> option (str "–") (str "—" <$ char '-')))
193+ (char '-' *> option (str "–") (str "—" <$ char '-')))
199− <|> double_quote
194+ <|> doubleQuote
200− <|> single_quote
195+ <|> singleQuote
201 <|> (str "”" <$ try (string "''"))
196 <|> (str "”" <$ try (string "''"))
202 <|> (str "”" <$ char '”')
197 <|> (str "”" <$ char '”')
203 <|> (str "’" <$ char '\'')
198 <|> (str "’" <$ char '\'')
204 <|> (str "’" <$ char '’')
199 <|> (str "’" <$ char '’')
205 <|> (str "\160" <$ char '~')
200 <|> (str "\160" <$ char '~')
206− <|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
201+ <|> mathDisplay (string "$$" *> mathChars <* string "$$")
207− <|> (mathInline $ char '$' *> mathChars <* char '$')
202+ <|> mathInline (char '$' *> mathChars <* char '$')
208− <|> (superscript <$> (char '^' *> tok))
203+ <|> try (superscript <$> (char '^' *> tok))
209 <|> (subscript <$> (char '_' *> tok))
204 <|> (subscript <$> (char '_' *> tok))
210 <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)
205 <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb)
211 <|> (str . (:[]) <$> tildeEscape)
206 <|> (str . (:[]) <$> tildeEscape)
@@ -244,6 +239,11 @@ getRawCommand name' = do
244 rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced)
239 rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced)
245 return $ '\\' : name' ++ snd rawargs
240 return $ '\\' : name' ++ snd rawargs
242+lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v
243+lookupListDefault d = (fromMaybe d .) . lookupList
245+ lookupList l m = msum $ map (`M.lookup` m) l
247blockCommand :: LP Blocks
247blockCommand :: LP Blocks
248blockCommand = try $ do
248blockCommand = try $ do
249 name <- anyControlSeq
249 name <- anyControlSeq
@@ -256,14 +256,10 @@ blockCommand = try $ do
256 guard $ transformed /= rawcommand
256 guard $ transformed /= rawcommand
257 notFollowedBy $ parseFromString inlines transformed
257 notFollowedBy $ parseFromString inlines transformed
258 parseFromString blocks transformed
258 parseFromString blocks transformed
259− case M.lookup name' blockCommands of
259+ lookupListDefault raw [name',name] blockCommands
261− Nothing -> case M.lookup name blockCommands of
265inBrackets :: Inlines -> Inlines
261inBrackets :: Inlines -> Inlines
266−inBrackets x = (str "[") <> x <> (str "]")
262+inBrackets x = str "[" <> x <> str "]"
268-- eat an optional argument and one or more arguments in braces
264-- eat an optional argument and one or more arguments in braces
269ignoreInlines :: String -> (String, LP Inlines)
265ignoreInlines :: String -> (String, LP Inlines)
@@ -271,14 +267,14 @@ ignoreInlines name = (name, doraw <|> (mempty <$ optargs))
271 where optargs = skipopts *> skipMany (try $ optional sp *> braced)
267 where optargs = skipopts *> skipMany (try $ optional sp *> braced)
272 contseq = '\\':name
268 contseq = '\\':name
273 doraw = (rawInline "latex" . (contseq ++) . snd) <$>
269 doraw = (rawInline "latex" . (contseq ++) . snd) <$>
274− (getOption readerParseRaw >>= guard >> (withRaw optargs))
270+ (getOption readerParseRaw >>= guard >> withRaw optargs)
276ignoreBlocks :: String -> (String, LP Blocks)
272ignoreBlocks :: String -> (String, LP Blocks)
277ignoreBlocks name = (name, doraw <|> (mempty <$ optargs))
273ignoreBlocks name = (name, doraw <|> (mempty <$ optargs))
278 where optargs = skipopts *> skipMany (try $ optional sp *> braced)
274 where optargs = skipopts *> skipMany (try $ optional sp *> braced)
279 contseq = '\\':name
275 contseq = '\\':name
280 doraw = (rawBlock "latex" . (contseq ++) . snd) <$>
276 doraw = (rawBlock "latex" . (contseq ++) . snd) <$>
281− (getOption readerParseRaw >>= guard >> (withRaw optargs))
277+ (getOption readerParseRaw >>= guard >> withRaw optargs)
283blockCommands :: M.Map String (LP Blocks)
279blockCommands :: M.Map String (LP Blocks)
284blockCommands = M.fromList $
280blockCommands = M.fromList $
@@ -316,7 +312,7 @@ blockCommands = M.fromList $
317 , ("hrule", pure horizontalRule)
313 , ("hrule", pure horizontalRule)
318 , ("rule", skipopts *> tok *> tok *> pure horizontalRule)
314 , ("rule", skipopts *> tok *> tok *> pure horizontalRule)
319− , ("item", skipopts *> loose_item)
315+ , ("item", skipopts *> looseItem)
320 , ("documentclass", skipopts *> braced *> preamble)
316 , ("documentclass", skipopts *> braced *> preamble)
321 , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
317 , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
322 , ("caption", skipopts *> setCaption)
318 , ("caption", skipopts *> setCaption)
@@ -403,17 +399,14 @@ inlineCommand = try $ do
403 else if parseRaw
399 else if parseRaw
404 then return $ rawInline "latex" rawcommand
400 then return $ rawInline "latex" rawcommand
405 else return mempty
401 else return mempty
406− case M.lookup name' inlineCommands of
408− Nothing -> case M.lookup name inlineCommands of
402+ lookupListDefault mzero [name',name] inlineCommands
410− Nothing -> raw
403+ <|> raw
412unlessParseRaw :: LP ()
405unlessParseRaw :: LP ()
413unlessParseRaw = getOption readerParseRaw >>= guard . not
406unlessParseRaw = getOption readerParseRaw >>= guard . not
415isBlockCommand :: String -> Bool
408isBlockCommand :: String -> Bool
416−isBlockCommand s = maybe False (const True) $ M.lookup s blockCommands
409+isBlockCommand s = s `M.member` blockCommands
419inlineEnvironments :: M.Map String (LP Inlines)
412inlineEnvironments :: M.Map String (LP Inlines)
@@ -459,7 +452,7 @@ inlineCommands = M.fromList $
459 , ("cref", unlessParseRaw >> (inBrackets <$> tok)) -- from cleveref.sty
452 , ("cref", unlessParseRaw >> (inBrackets <$> tok)) -- from cleveref.sty
460 , ("(", mathInline $ manyTill anyChar (try $ string "\\)"))
453 , ("(", mathInline $ manyTill anyChar (try $ string "\\)"))
461 , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]"))
454 , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]"))
462− , ("ensuremath", mathInline $ braced)
455+ , ("ensuremath", mathInline braced)
463 , ("texorpdfstring", (\_ x -> x) <$> tok <*> tok)
456 , ("texorpdfstring", (\_ x -> x) <$> tok <*> tok)
464 , ("P", lit "¶")
457 , ("P", lit "¶")
465 , ("S", lit "§")
458 , ("S", lit "§")
@@ -631,7 +624,7 @@ lit = pure . str
631accent :: (Char -> String) -> Inlines -> LP Inlines
624accent :: (Char -> String) -> Inlines -> LP Inlines
632accent f ils =
625accent f ils =
633 case toList ils of
626 case toList ils of
634− (Str (x:xs) : ys) -> return $ fromList $ (Str (f x ++ xs) : ys)
627+ (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys)
635 [] -> mzero
628 [] -> mzero
636 _ -> return ils
629 _ -> return ils
@@ -820,7 +813,7 @@ breve 'u' = "ŭ"
820breve c = [c]
813breve c = [c]
822tok :: LP Inlines
815tok :: LP Inlines
823−tok = try $ grouped inline <|> inlineCommand <|> str <$> (count 1 $ inlineChar)
816+tok = try $ grouped inline <|> inlineCommand <|> str <$> count 1 inlineChar
825opt :: LP Inlines
818opt :: LP Inlines
826opt = bracketed inline <* optional sp
819opt = bracketed inline <* optional sp
@@ -838,17 +831,14 @@ environment :: LP Blocks
838environment = do
831environment = do
839 controlSeq "begin"
832 controlSeq "begin"
840 name <- braced
833 name <- braced
841− case M.lookup name environments of
834+ M.findWithDefault mzero name environments
842− Just p -> p <|> rawEnv name
843− Nothing -> rawEnv name
835+ <|> rawEnv name
845inlineEnvironment :: LP Inlines
837inlineEnvironment :: LP Inlines
846inlineEnvironment = try $ do
838inlineEnvironment = try $ do
847 controlSeq "begin"
839 controlSeq "begin"
848 name <- braced
840 name <- braced
849− case M.lookup name inlineEnvironments of
841+ M.findWithDefault mzero name inlineEnvironments
853rawEnv :: String -> LP Blocks
843rawEnv :: String -> LP Blocks
854rawEnv name = do
844rawEnv name = do
@@ -861,7 +851,7 @@ rawEnv name = do
864−type IncludeParser = ParserT [Char] [String] IO String
854+type IncludeParser = ParserT String [String] IO String
866-- | Replace "include" commands with file contents.
856-- | Replace "include" commands with file contents.
867handleIncludes :: String -> IO (Either PandocError String)
857handleIncludes :: String -> IO (Either PandocError String)
@@ -921,7 +911,7 @@ include' = do
921 <|> try (string "input")
911 <|> try (string "input")
922 <|> string "usepackage"
912 <|> string "usepackage"
923 -- skip options
913 -- skip options
924− skipMany $ try $ char '[' *> (manyTill anyChar (char ']'))
914+ skipMany $ try $ char '[' *> manyTill anyChar (char ']')
925 fs <- (map trim . splitBy (==',')) <$> braced'
915 fs <- (map trim . splitBy (==',')) <$> braced'
926 return $ if name == "usepackage"
916 return $ if name == "usepackage"
927 then map (maybeAddExtension ".sty") fs
917 then map (maybeAddExtension ".sty") fs
@@ -994,14 +984,14 @@ keyvals = try $ char '[' *> manyTill keyval (char ']')
994alltt :: String -> LP Blocks
984alltt :: String -> LP Blocks
995alltt t = walk strToCode <$> parseFromString blocks
985alltt t = walk strToCode <$> parseFromString blocks
996 (substitute " " "\\ " $ substitute "%" "\\%" $
986 (substitute " " "\\ " $ substitute "%" "\\%" $
997− concat $ intersperse "\\\\\n" $ lines t)
987+ intercalate "\\\\\n" $ lines t)
998 where strToCode (Str s) = Code nullAttr s
988 where strToCode (Str s) = Code nullAttr s
999 strToCode x = x
989 strToCode x = x
1001−rawLaTeXBlock :: Parser [Char] ParserState String
991+rawLaTeXBlock :: LP String
1002rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
992rawLaTeXBlock = snd <$> try (withRaw (environment <|> blockCommand))
1004−rawLaTeXInline :: Parser [Char] ParserState Inline
994+rawLaTeXInline :: LP Inline
1005rawLaTeXInline = do
995rawLaTeXInline = do
1006 raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
996 raw <- (snd <$> withRaw inlineCommand) <|> (snd <$> withRaw blockCommand)
1007 RawInline "latex" <$> applyMacros' raw
997 RawInline "latex" <$> applyMacros' raw
@@ -1010,24 +1000,24 @@ addImageCaption :: Blocks -> LP Blocks
1010addImageCaption = walkM go
1000addImageCaption = walkM go
1011 where go (Image alt (src,tit)) = do
1001 where go (Image alt (src,tit)) = do
1012 mbcapt <- stateCaption <$> getState
1002 mbcapt <- stateCaption <$> getState
1013− case mbcapt of
1003+ return $ case mbcapt of
1014− Just ils -> return (Image (toList ils) (src, "fig:"))
1004+ Just ils -> Image (toList ils) (src, "fig:")
1015− Nothing -> return (Image alt (src,tit))
1005+ Nothing -> Image alt (src,tit)
1016 go x = return x
1006 go x = return x
1018addTableCaption :: Blocks -> LP Blocks
1008addTableCaption :: Blocks -> LP Blocks
1019addTableCaption = walkM go
1009addTableCaption = walkM go
1020 where go (Table c als ws hs rs) = do
1010 where go (Table c als ws hs rs) = do
1021 mbcapt <- stateCaption <$> getState
1011 mbcapt <- stateCaption <$> getState
1022− case mbcapt of
1012+ return $ case mbcapt of
1023− Just ils -> return (Table (toList ils) als ws hs rs)
1013+ Just ils -> Table (toList ils) als ws hs rs
1024− Nothing -> return (Table c als ws hs rs)
1014+ Nothing -> Table c als ws hs rs
1025 go x = return x
1015 go x = return x
1027environments :: M.Map String (LP Blocks)
1017environments :: M.Map String (LP Blocks)
1028environments = M.fromList
1018environments = M.fromList
1029 [ ("document", env "document" blocks <* skipMany anyChar)
1019 [ ("document", env "document" blocks <* skipMany anyChar)
1030− , ("letter", env "letter" letter_contents)
1020+ , ("letter", env "letter" letterContents)
1031 , ("figure", env "figure" $
1021 , ("figure", env "figure" $
1032 resetCaption *> skipopts *> blocks >>= addImageCaption)
1022 resetCaption *> skipopts *> blocks >>= addImageCaption)
1033 , ("center", env "center" blocks)
1023 , ("center", env "center" blocks)
@@ -1040,12 +1030,12 @@ environments = M.fromList
1040 , ("verse", blockQuote <$> env "verse" blocks)
1030 , ("verse", blockQuote <$> env "verse" blocks)
1041 , ("itemize", bulletList <$> listenv "itemize" (many item))
1031 , ("itemize", bulletList <$> listenv "itemize" (many item))
1042 , ("description", definitionList <$> listenv "description" (many descItem))
1032 , ("description", definitionList <$> listenv "description" (many descItem))
1043− , ("enumerate", ordered_list)
1033+ , ("enumerate", orderedList')
1044 , ("alltt", alltt =<< verbEnv "alltt")
1034 , ("alltt", alltt =<< verbEnv "alltt")
1045 , ("code", guardEnabled Ext_literate_haskell *>
1035 , ("code", guardEnabled Ext_literate_haskell *>
1046 (codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
1036 (codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
1047 verbEnv "code"))
1037 verbEnv "code"))
1048− , ("verbatim", codeBlock <$> (verbEnv "verbatim"))
1038+ , ("verbatim", codeBlock <$> verbEnv "verbatim")
1049 , ("Verbatim", do options <- option [] keyvals
1039 , ("Verbatim", do options <- option [] keyvals
1050 let kvs = [ (if k == "firstnumber"
1040 let kvs = [ (if k == "firstnumber"
1051 then "startFrom"
1041 then "startFrom"
@@ -1053,17 +1043,17 @@ environments = M.fromList
1053 let classes = [ "numberLines" |
1043 let classes = [ "numberLines" |
1054 lookup "numbers" options == Just "left" ]
1044 lookup "numbers" options == Just "left" ]
1055 let attr = ("",classes,kvs)
1045 let attr = ("",classes,kvs)
1056− codeBlockWith attr <$> (verbEnv "Verbatim"))
1046+ codeBlockWith attr <$> verbEnv "Verbatim")
1057 , ("lstlisting", do options <- option [] keyvals
1047 , ("lstlisting", do options <- option [] keyvals
1058 let kvs = [ (if k == "firstnumber"
1048 let kvs = [ (if k == "firstnumber"
1059 then "startFrom"
1049 then "startFrom"
1060 else k, v) | (k,v) <- options ]
1050 else k, v) | (k,v) <- options ]
1061 let classes = [ "numberLines" |
1051 let classes = [ "numberLines" |
1062 lookup "numbers" options == Just "left" ]
1052 lookup "numbers" options == Just "left" ]
1063− ++ maybe [] (:[]) (lookup "language" options
1053+ ++ maybeToList (lookup "language" options
1064 >>= fromListingsLanguage)
1054 >>= fromListingsLanguage)
1065 let attr = (fromMaybe "" (lookup "label" options),classes,kvs)
1055 let attr = (fromMaybe "" (lookup "label" options),classes,kvs)
1066− codeBlockWith attr <$> (verbEnv "lstlisting"))
1056+ codeBlockWith attr <$> verbEnv "lstlisting")
1067 , ("minted", do options <- option [] keyvals
1057 , ("minted", do options <- option [] keyvals
1068 lang <- grouped (many1 $ satisfy (/='}'))
1058 lang <- grouped (many1 $ satisfy (/='}'))
1069 let kvs = [ (if k == "firstnumber"
1059 let kvs = [ (if k == "firstnumber"
@@ -1073,7 +1063,7 @@ environments = M.fromList
1073 [ "numberLines" |
1063 [ "numberLines" |
1074 lookup "linenos" options == Just "true" ]
1064 lookup "linenos" options == Just "true" ]
1075 let attr = ("",classes,kvs)
1065 let attr = ("",classes,kvs)
1076− codeBlockWith attr <$> (verbEnv "minted"))
1066+ codeBlockWith attr <$> verbEnv "minted")
1077 , ("obeylines", parseFromString
1067 , ("obeylines", parseFromString
1078 (para . trimInlines . mconcat <$> many inline) =<<
1068 (para . trimInlines . mconcat <$> many inline) =<<
1079 intercalate "\\\\\n" . lines <$> verbEnv "obeylines")
1069 intercalate "\\\\\n" . lines <$> verbEnv "obeylines")
@@ -1092,8 +1082,8 @@ environments = M.fromList
1092 , ("alignat*", mathEnv para (Just "aligned") "alignat*")
1082 , ("alignat*", mathEnv para (Just "aligned") "alignat*")
1095−letter_contents :: LP Blocks
1085+letterContents :: LP Blocks
1096−letter_contents = do
1086+letterContents = do
1097 bs <- blocks
1087 bs <- blocks
1098 st <- getState
1088 st <- getState
1099 -- add signature (author) and address (title)
1089 -- add signature (author) and address (title)
@@ -1120,8 +1110,8 @@ closing = do
1120item :: LP Blocks
1110item :: LP Blocks
1121item = blocks *> controlSeq "item" *> skipopts *> blocks
1111item = blocks *> controlSeq "item" *> skipopts *> blocks
1123−loose_item :: LP Blocks
1113+looseItem :: LP Blocks
1124−loose_item = do
1114+looseItem = do
1125 ctx <- stateParserContext `fmap` getState
1115 ctx <- stateParserContext `fmap` getState
1126 if ctx == ListItemState
1116 if ctx == ListItemState
1127 then mzero
1117 then mzero
@@ -1164,8 +1154,8 @@ verbEnv name = do
1164 res <- manyTill anyChar endEnv
1154 res <- manyTill anyChar endEnv
1165 return $ stripTrailingNewlines res
1155 return $ stripTrailingNewlines res
1167−ordered_list :: LP Blocks
1157+orderedList' :: LP Blocks
1168−ordered_list = do
1158+orderedList' = do
1169 optional sp
1159 optional sp
1170 (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $
1160 (_, style, delim) <- option (1, DefaultStyle, DefaultDelim) $
1171 try $ char '[' *> anyOrderedListMarker <* char ']'
1161 try $ char '[' *> anyOrderedListMarker <* char ']'
@@ -1177,7 +1167,7 @@ ordered_list = do
1177 optional sp
1167 optional sp
1178 num <- grouped (many1 digit)
1168 num <- grouped (many1 digit)
1180− return $ (read num + 1 :: Int)
1170+ return (read num + 1 :: Int)
1181 bs <- listenv "enumerate" (many item)
1171 bs <- listenv "enumerate" (many item)
1182 return $ orderedListWith (start, style, delim) bs
1172 return $ orderedListWith (start, style, delim) bs
@@ -1191,14 +1181,14 @@ paragraph = do
1191preamble :: LP Blocks
1181preamble :: LP Blocks
1192preamble = mempty <$> manyTill preambleBlock beginDoc
1182preamble = mempty <$> manyTill preambleBlock beginDoc
1193 where beginDoc = lookAhead $ try $ controlSeq "begin" *> string "{document}"
1183 where beginDoc = lookAhead $ try $ controlSeq "begin" *> string "{document}"
1194− preambleBlock = (void comment)
1184+ preambleBlock = void comment
1195− <|> (void sp)
1185+ <|> void sp
1196− <|> (void blanklines)
1186+ <|> void blanklines
1197− <|> (void macro)
1187+ <|> void macro
1198− <|> (void blockCommand)
1188+ <|> void blockCommand
1199− <|> (void anyControlSeq)
1189+ <|> void anyControlSeq
1200− <|> (void braced)
1190+ <|> void braced
1201− <|> (void anyChar)
1191+ <|> void anyChar
@@ -1274,7 +1264,7 @@ complexNatbibCitation mode = try $ do
1274 suff <- ils
1264 suff <- ils
1275 skipSpaces
1265 skipSpaces
1276 optional $ char ';'
1266 optional $ char ';'
1277− return $ addPrefix pref $ addSuffix suff $ cits'
1267+ return $ addPrefix pref $ addSuffix suff cits'
1278 (c:cits, raw) <- withRaw $ grouped parseOne
1268 (c:cits, raw) <- withRaw $ grouped parseOne
1279 return $ cite (c{ citationMode = mode }:cits)
1269 return $ cite (c{ citationMode = mode }:cits)
1280 (rawInline "latex" $ "\\citetext" ++ raw)
1270 (rawInline "latex" $ "\\citetext" ++ raw)
@@ -1298,13 +1288,13 @@ parseAligns = try $ do
1298 return aligns'
1288 return aligns'
1300hline :: LP ()
1290hline :: LP ()
1301−hline = () <$ (try $ spaces' *> controlSeq "hline" <* spaces')
1291+hline = () <$ try (spaces' *> controlSeq "hline" <* spaces')
1303lbreak :: LP ()
1293lbreak :: LP ()
1304−lbreak = () <$ (try $ spaces' *> controlSeq "\\" <* spaces')
1294+lbreak = () <$ try (spaces' *> controlSeq "\\" <* spaces')
1306amp :: LP ()
1296amp :: LP ()
1307−amp = () <$ (try $ spaces' *> char '&')
1297+amp = () <$ try (spaces' *> char '&')
1309parseTableRow :: Int -- ^ number of columns
1299parseTableRow :: Int -- ^ number of columns
1310 -> LP [Blocks]
1300 -> LP [Blocks]