aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-07-21 09:28:11 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-07-21 09:28:36 +0200
commit7191fe1f29f2f8b45f9be7e0f8bc9ed889e431d2 (patch)
tree59fbaf540b501c2505950ffa2d4c6b5107f86dae /src/Text
parent992943d98e14cc2dd249d6279c8c930dddc5547d (diff)
downloadpandoc-7191fe1f29f2f8b45f9be7e0f8bc9ed889e431d2.tar.gz
LaTeX reader: handle optional args in raw `\titleformat`.
Closes #3804.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index ab3994770..58a48c655 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1362,14 +1362,20 @@ rawInlineOr name' fallback = do
getRawCommand :: PandocMonad m => Text -> LP m String
getRawCommand txt = do
- (_, rawargs) <- withRaw
- ((if txt == "\\write"
- then () <$ satisfyTok isWordTok -- digits
- else return ()) *>
- skipangles *>
- skipopts *>
- option "" (try (optional sp *> dimenarg)) *>
- many braced)
+ (_, rawargs) <- withRaw $
+ case txt of
+ "\\write" -> do
+ void $ satisfyTok isWordTok -- digits
+ void braced
+ "\\titleformat" -> do
+ void braced
+ skipopts
+ void $ count 4 braced
+ _ -> do
+ skipangles
+ skipopts
+ option "" (try (optional sp *> dimenarg))
+ void $ many braced
return $ T.unpack (txt <> untokenize rawargs)
isBlockCommand :: Text -> Bool
@@ -1397,6 +1403,7 @@ treatAsBlock = Set.fromList
, "newpage"
, "clearpage"
, "pagebreak"
+ , "titleformat"
]
isInlineCommand :: Text -> Bool