lzanini / mdbook-katex

A preprocessor for mdBook, rendering LaTex equations to HTML at build time.
MIT License
205 stars 34 forks source link

Use 1 split iterator to split while ignoring `\` #50

Closed SichangHe closed 1 year ago

SichangHe commented 1 year ago

Use iterator SplitIgnoreEscaped to split these ignoring the ones prefixed with \:

The rule is simplified to "escape whatever that is prefixed with \."

Notice

This changes the behavior on handling \$ and \$$. Previously, \$ was replaced as $, \$$ was not escaped. Now, both of the above would be preserved as is.

SichangHe commented 1 year ago

This change would mean that if someone has:

$$f(x)\\$$
and …

then, it would break because the \ is right before $$.

But, there are no obvious reason to do the above because creating a trailing new line inside math expressions is not really useful.

SichangHe commented 1 year ago

This change also makes the preprocessor slightly faster.