Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: FEATURE: custom inline and block math delimiters #19

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

danielhollas
Copy link
Contributor

@danielhollas danielhollas commented Mar 7, 2020

Per several user requests, this PR adds two new settings for users to specify custom (possibly multiple) math delimiters. Note that users using the old plugin have no good way to upgrade without this functionality.

The new code also handles things like \begin{align}...\end{align}. These must be treated as a special case because they need to be passed to MathJax.

Here's my test code:

Inline math $E=mc^2$  and inline math with custom delimiter `!`  !E=mc^3!

ascii math %E=mc^2%

Default Block Math
$$
E=mc^2
$$

Custom block math with `$$$`
$$$
E=mc^2
$$$

Custom block math starting with `\begin{align}`
\begin{align}
\hat{H}\Psi &= E \Psi \\
\hat{H_i}\Psi_i &= E_i \Psi
\end{align}

And here's how it looks:


image


(note that the \begin{align} does what it's supposed to do, i.e. align multiple equations on =)

TODO / TO DISCUSS:

  • The current approach does not allow for different delimiters for beginning and end, such as \[ display \]. If we want to support all that's out there, we should allow this. DONE ✔️

  • The current code only allows for single-character inline math delimiters (because that's how it was written originally), but one of standard TeX syntax for inline math is \( inline \) so we should allow this.

  • Instead of requiring admins to insert every \begin{*}...\end{*} environment they want to support, we could have a switch to process every block math of this form. This would be MathJaX only, KaTeX does not support these, although it might in near future. DONE: ✔️

@danielhollas danielhollas changed the title FEATURE: custom inline and block math delimiters WIP: FEATURE: custom inline and block math delimiters Mar 7, 2020
@ZogStriP
Copy link
Member

Was this discussed on https://meta.discourse.org?

@danielhollas
Copy link
Contributor Author

danielhollas commented Mar 10, 2020

@ZogStriP here's the latest user comment and here an earlier comment from Sam from the previous discussion on this topic.

At the end of the topic, there's also a separate convo about boundary characters and usage on Chinese forum. Since I will be touching that code anyway, I am inclined to include to do it as part of this PR, but it may be separate.

I am taking this as an exploration for now. This is not yet ready to review, but close. If I get a green light, I'll add lots of tests to cover different use cases.

I am unsure about this. Needs testing...

To make \( \) work, I needed to change the inline ruler from
inline.ruler.after('escape',...)
to
inline.ruler.before('escape,...)

I have to make sure this does not break anything.
Base automatically changed from master to main February 16, 2021 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants