aboutsummaryrefslogtreecommitdiff
path: root/test/command
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-08-11 16:14:34 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2021-08-11 16:14:34 -0700
commite3a263df4669450049c49043412f791261e049a4 (patch)
tree3628249c9bf847e1738dbbb2a08e77eac41086ce /test/command
parentf00f7ec63c19c55644cbf98133dfca4d8c10b590 (diff)
downloadpandoc-e3a263df4669450049c49043412f791261e049a4.tar.gz
Fix scope for LaTeX macros.
They should by default scope over the group in which they are defined (except `\gdef` and `\xdef`, which are global). In addition, environments must be treated as groups. We handle this by making sMacros in the LaTeX parser state a STACK of macro tables. Opening a group adds a table to the stack, closing one removes one. Only the top of the stack is queried. This commit adds a parameter for scope to the Macro constructor (not exported). Closes #7494.
Diffstat (limited to 'test/command')
-rw-r--r--test/command/7494.md50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/command/7494.md b/test/command/7494.md
new file mode 100644
index 000000000..d8a2ff7a5
--- /dev/null
+++ b/test/command/7494.md
@@ -0,0 +1,50 @@
+```
+% pandoc -f latex -t plain
+\def\foo{BAR}
+{\foo
+\def\foo{BAZ}
+\foo
+}
+\foo
+^D
+BAR BAZ BAR
+```
+
+```
+% pandoc -f latex -t plain
+\def\foo{BAR}
+{\foo
+\gdef\foo{BAZ}
+\foo
+}
+\foo
+^D
+BAR BAZ BAZ
+```
+
+```
+% pandoc -f latex -t plain
+\newcommand{\aaa}{BBB}
+{
+\renewcommand{\aaa}{AAA}
+\aaa
+}
+\aaa
+^D
+AAA BBB
+```
+
+```
+% pandoc -f latex -t markdown
+\newcommand{\aaa}{BBB}
+\begin{quote}
+\renewcommand{\aaa}{AAA}
+\aaa
+\end{quote}
+\aaa
+^D
+> AAA
+
+BBB
+```
+