git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Fixed failures on \ref{}, \label{} with `+raw_tex`.

Now these commands are parsed as raw if `+raw_tex`; otherwise, their argument is parsed as a bracketed string.

commit8f718b08834e496e98790e1b5b8a3cb9e1b932a6 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 24 May 2017, 23:04 (9 years ago) parent00fffef
1 file changed+9−6
src/Text/Pandoc/Readers/LaTeX.hs+9−6
src/Text/Pandoc/Readers/LaTeX.hs+9−6
@@ -482,9 +482,12 @@ inlineCommand = try $ do
482482 (lookupListDefault raw [name',name] inlineCommands <*
483483 optional (try (string "{}")))
484484
485−unlessParseRaw :: PandocMonad m => LP m ()
486−unlessParseRaw = getOption readerExtensions >>=
487− guard . not . extensionEnabled Ext_raw_tex
485+rawInlineOr :: PandocMonad m => String -> LP m Inlines -> LP m Inlines
486+rawInlineOr name' fallback = do
487+ parseRaw <- extensionEnabled Ext_raw_tex <$> getOption readerExtensions
488+ if parseRaw
489+ then rawInline "latex" <$> getRawCommand name'
490+ else fallback
488491
489492isBlockCommand :: String -> Bool
490493isBlockCommand s = s `M.member` (blockCommands :: M.Map String (LP PandocPure Blocks))
@@ -532,11 +535,11 @@ inlineCommands = M.fromList $
532535 , ("dots", lit "…")
533536 , ("mdots", lit "…")
534537 , ("sim", lit "~")
535− , ("label", unlessParseRaw >> (inBrackets <$> tok))
536− , ("ref", unlessParseRaw >> (inBrackets <$> tok))
538+ , ("label", rawInlineOr "label" (inBrackets <$> tok))
539+ , ("ref", rawInlineOr "ref" (inBrackets <$> tok))
537540 , ("textgreek", tok)
538541 , ("sep", lit ",")
539− , ("cref", unlessParseRaw >> (inBrackets <$> tok)) -- from cleveref.sty
542+ , ("cref", rawInlineOr "cref" (inBrackets <$> tok)) -- from cleveref.sty
540543 , ("(", mathInline $ manyTill anyChar (try $ string "\\)"))
541544 , ("[", mathDisplay $ manyTill anyChar (try $ string "\\]"))
542545 , ("ensuremath", mathInline braced)