feat(macro): improve argument parsing (#2085)

* Improve macro argument parsing

* Make \above a primitive command

* Fix screenshotter data

* Normalize argument where necessary

* Improve argument location info

* Update comments

* Minor refactor

* Modularize group parsers

* Allow braced and blank size argument

for non-strict mode and \genfrac, respectively.

* Minor refactor & update comments

* Remove raw option in parseStringGroup

* Update tests

* Fix { delimited parameter

* Update tests

* Update tests

* Normalize argument in \genfrac

* Update tests

* Consume space before scanning an optional argument

* Fix \\, \newline, and \cr behavior

* Fix flow error

* Update comments

* Remove unnecessary mode switching

Parser mode affects neither fetch nor consume.

* Allow single (active) character macro

* Add function property `primitive`

* Set \mathchoice and \*style primitive

* Separate size-related improvements out to #2139

* Fix flow error

* Update screenshots

* Update demo example

* Add a migration guide

* Fix capitalization

* Make a primitive function unexpandable

* Update screenshots

* Update screenshots

* Revert "Document \def doesn't support delimiters (#2288) (#2289)"

This reverts commit f96fba6f7f.

* Update comments, errors, and tests

* Update screenshots
This commit is contained in:
ylemkimon
2020-09-06 12:56:13 +09:00
committed by GitHub
parent 8578d74f82
commit dc5f97aaa2
35 changed files with 432 additions and 348 deletions

View File

@@ -62,9 +62,9 @@
</a>
</div>
<textarea id="demo-input" spellcheck="false">
% \f is defined as f(#1) using the macro
\f{x} = \int_{-\infty}^\infty
\hat \f\xi\,e^{2 \pi i \xi x}
% \f is defined as #1f(#2) using the macro
\f\relax{x} = \int_{-\infty}^\infty
\f\hat\xi,e^{2 \pi i \xi x}
\,d\xi</textarea>
</div>
<div class="demo-right">
@@ -181,7 +181,7 @@
<h4><label for="macros">macros</label></h4>
<textarea id="macros" placeholder="JSON">
{
"\\f": "f(#1)"
"\\f": "#1f(#2)"
}</textarea>
<h3>Editor Options</h3>

View File

@@ -3,6 +3,6 @@
"Installation": ["node", "browser"],
"Usage": ["api", "cli", "autorender", "libs"],
"Configuring KaTeX": ["options", "security", "error", "font"],
"Misc": ["supported", "support_table", "issues"]
"Misc": ["supported", "support_table", "issues", "migration"]
}
}