diff options
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 23 | ||||
-rw-r--r-- | test/command/3804.md | 6 |
2 files changed, 21 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 diff --git a/test/command/3804.md b/test/command/3804.md new file mode 100644 index 000000000..c13c2ef42 --- /dev/null +++ b/test/command/3804.md @@ -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}"] +``` |