aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-04-10 18:56:08 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-04-10 18:56:08 -0700
commita4388279debf9f8f11ebc1726c40aba4f831fe4a (patch)
tree8310b9e92a709b56b790e776d0c9a31ebdf822c4 /src/Text/Pandoc/Readers
parent54c9d4348ad0b61713ab16ebf20d640f60ea5c39 (diff)
downloadpandoc-a4388279debf9f8f11ebc1726c40aba4f831fe4a.tar.gz
LaTeX reader: Parse 'dimension' arguments to unknown commands.
e.g. `\parindent0pt`
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs19
1 files changed, 13 insertions, 6 deletions
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