diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-08-11 16:28:53 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-08-11 16:28:53 -0700 |
commit | dd1a956a8aa7d0cadd37db1650698eee9274beee (patch) | |
tree | dade1c78121fc3e6e1e5f99e8b38fc7e1e0ea6f9 /src/Text/Pandoc/Readers/LaTeX | |
parent | e3a263df4669450049c49043412f791261e049a4 (diff) | |
download | pandoc-dd1a956a8aa7d0cadd37db1650698eee9274beee.tar.gz |
LaTeX reader: Support `\global` before `\def`, `\let`, etc.
See #7494.
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX/Macro.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX/Macro.hs b/src/Text/Pandoc/Readers/LaTeX/Macro.hs index 5709cbb8c..bd7979ef3 100644 --- a/src/Text/Pandoc/Readers/LaTeX/Macro.hs +++ b/src/Text/Pandoc/Readers/LaTeX/Macro.hs @@ -25,8 +25,8 @@ macroDef constructor = do guardDisabled Ext_latex_macros) <|> return mempty where commandDef = do - nameMacroPairs <- newcommand <|> letmacro <|> - edefmacro <|> defmacro <|> newif + nameMacroPairs <- newcommand <|> + checkGlobal (letmacro <|> edefmacro <|> defmacro <|> newif) guardDisabled Ext_latex_macros <|> mapM_ insertMacro nameMacroPairs environmentDef = do @@ -77,6 +77,14 @@ letmacro = do Macro GroupScope ExpandWhenDefined [] Nothing [target])] _ -> pure [(name, Macro GroupScope ExpandWhenDefined [] Nothing [target])] +checkGlobal :: PandocMonad m => LP m [(Text, Macro)] -> LP m [(Text, Macro)] +checkGlobal p = + (do controlSeq "global" + ms <- p + return $ map (\(n, Macro _ expand arg optarg contents) -> + (n, Macro GlobalScope expand arg optarg contents)) ms) + <|> p + edefmacro :: PandocMonad m => LP m [(Text, Macro)] edefmacro = do scope <- (GroupScope <$ controlSeq "edef") |