Create globalGroup option to place definitions in global scope (#2091)

If true, this allows \newcommand definitions to persist across calls to
renderToString.

Fix https://github.com/KaTeX/KaTeX/issues/2070
This commit is contained in:
Ciro Santilli,Opinions and content are my own, not my employer's,2018新疆改造中心,1989六四事件,1999法轮功 ,2019 996.ICU, 2018包子露宪,2015 710律师劫,2015巴拿马文件 邓家贵,2017低端人口,2008西藏骚乱scriptalert(1)/script
2019-09-22 20:03:44 +01:00
committed by Kevin Barabash
parent f03671ce61
commit 36595343b7
4 changed files with 31 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ You can provide an object of options as the last argument to [`katex.render` and
- Allow all commands with specific protocols: `trust: (context) => ['http', 'https', '_relative'].includes(context.protocol)`
- Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'`
- Allow certain commands with specific protocols: `trust: (context) => ['\\url', '\\href'].includes(context.command) && ['http', 'https', '_relative'].includes(context.protocol)`
- `globalGroup`: `boolean` (default: `false`). Place KaTeX code in the global group. As a consequence, `\def` and `\newcommand` persist in `macros` across render calls. In LaTeX, constructs such as `\begin{equation}` and `$$` create a local group and prevent definitions from becoming visible outside of those blocks.
For example: