From a4388279debf9f8f11ebc1726c40aba4f831fe4a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 10 Apr 2012 18:56:08 -0700 Subject: LaTeX reader: Parse 'dimension' arguments to unknown commands. e.g. `\parindent0pt` --- src/Text/Pandoc/Readers/LaTeX.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 1c1d5cad7..d064c587c 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -85,6 +85,13 @@ controlSeq name = try $ do cs -> string cs <* notFollowedBy letter <* optional sp return name +dimenarg :: LP String +dimenarg = try $ do + ch <- option "" $ string "=" + num <- many1 digit + dim <- oneOfStrings ["pt","pc","in","bp","cm","mm","dd","cc","sp"] + return $ ch ++ num ++ dim + sp :: LP () sp = skipMany1 $ satisfy (\c -> c == ' ' || c == '\t') <|> (try $ newline >>~ lookAhead anyChar >>~ notFollowedBy blankline) @@ -318,12 +325,12 @@ inlineCommand = try $ do Just p -> p Nothing -> case M.lookup name inlineCommands of Just p -> p - Nothing - | parseRaw -> - (rawInline "latex" . (('\\':name') ++)) <$> - (withRaw (skipopts *> many braced) - >>= applyMacros' . snd) - | otherwise -> return mempty + Nothing -> + if parseRaw + then (rawInline "latex" . (('\\':name') ++)) <$> rawargs + else mempty <$> rawargs + where rawargs = withRaw (skipopts *> option "" dimenarg + *> many braced) >>= applyMacros' . snd isBlockCommand :: String -> Bool isBlockCommand s = maybe False (const True) $ M.lookup s blockCommands -- cgit v1.2.3