parent
e3a263df46
commit
dd1a956a8a
2 changed files with 22 additions and 2 deletions
|
@ -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")
|
||||
|
|
|
@ -22,6 +22,18 @@ BAR BAZ BAR
|
|||
BAR BAZ BAZ
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f latex -t plain
|
||||
\def\foo{BAR}
|
||||
{\foo
|
||||
\global\def\foo{BAZ}
|
||||
\foo
|
||||
}
|
||||
\foo
|
||||
^D
|
||||
BAR BAZ BAZ
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f latex -t plain
|
||||
\newcommand{\aaa}{BBB}
|
||||
|
|
Loading…
Add table
Reference in a new issue