LaTeX reader: handle optional args in raw \titleformat.

Closes #3804.
This commit is contained in:
John MacFarlane 2017-07-21 09:28:11 +02:00
parent 992943d98e
commit 7191fe1f29
2 changed files with 21 additions and 8 deletions

View file

@ -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

6
test/command/3804.md Normal file
View file

@ -0,0 +1,6 @@
```
% pandoc -t native
\titleformat{\chapter}[display]{\normalfont\large\bfseries}{第\thechapter{}章}{20pt}{\Huge}
^D
[RawBlock (Format "latex") "\\titleformat{\\chapter}[display]{\\normalfont\\large\\bfseries}{\31532\\thechapter{}\31456}{20pt}{\\Huge}"]
```