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

use non-greedy *? for display math content #168

Merged
merged 4 commits into from
Sep 28, 2016

Conversation

kleinschmidt
Copy link
Contributor

Using greedy * means that the regex will match across display math blocks. For example, the current regex matches this whole snippet (including the non-math bit in the middle):

\[
some math
\]
non-math
\[
more math
\]

The only potential downside I can see is that if, for some strange reason, someone wants a literal \] inside their display math block, the regex will think that the block ends early. But this seems less likely than the frustrating situation of having non-math font-locked as math in between two display math blocks (which is very common in my documents).

@syohex
Copy link
Collaborator

syohex commented Sep 24, 2016

Could you add test code ?

@kleinschmidt
Copy link
Contributor Author

I'll give it a try, but fair warning, my elisp skills are a little lacking :)

@kleinschmidt
Copy link
Contributor Author

Okay, tests added (and I confirmed they fail with greedy matching).

@kleinschmidt
Copy link
Contributor Author

I also added a test and a fix for a bug with italics and display math, where the font lock rules for display math were after the ones for italics and so the fences that normally keep _ from being interpreted as italics in math mode weren't catching display math.

@syohex
Copy link
Collaborator

syohex commented Sep 28, 2016

Thanks for work. I'll check.

@syohex syohex merged commit c81e26f into jrblevin:master Sep 28, 2016
@syohex
Copy link
Collaborator

syohex commented Sep 28, 2016

Looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants