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

Support Inline Equation and Equation Block #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hupili
Copy link

@hupili hupili commented May 11, 2013

It seems more and more people are combining markdown and mathjax now. This modification is adapted from the original code fence parsing rules. It gives better highlighting in vim.

Before (some normal texts are highlighted as italic )

b

After

a

Sine there are a lot _ (underscore) in math formula, it is essential to isolate them in order not to other texts.

@hupili
Copy link
Author

hupili commented May 11, 2013

The modification is premature. I used the "Comment" option for the highlighting because it gives a better looking (different from code delimiter). Any idea to assign it a better group?

@oblitum
Copy link

oblitum commented May 28, 2013

+1, I was about to submit an issue about this:

math

but, except for the math with underscore which is not correctly displayed (and mess up the rest), does anyone knows why the red background on underscores, is it on purpose or error?

@hupili
Copy link
Author

hupili commented May 28, 2013

@oblitum , The following two lines are responsible for that red block.

 97 syn match markdownError "\w\@<=_\w\@="
129 hi def link markdownError                 Error

So the syntax is marked as error, on purpose.. I don't know the reason, either.

@oblitum
Copy link

oblitum commented May 28, 2013

@hupili ok thanks.

@CarlRJ
Copy link

CarlRJ commented May 31, 2013

I'm guessing the underscores are marked as errors to highlight the problem that unescaped mid-word underscores cause some Markdown parsers to start italicizing (valid behavior per the original spec, but many parsers have deactivated it for being too annoying) - I've noticed that if I enter, say, a url that contains underscores, they get flagged, but then if I wrap the url in <> or []() (or escape the _ with \ if just regular text), the error goes away.

I find myself adding unneeded (for parsers I use) backslashes in front of mid-word underscores simply to make the error indication go away in the Vim syntax highlighting -- actually, I'd love to be able to stop doing that.

Personally, I'd love to see some hypothetical Markdown 2.0 decree that mid-word _ isn't part of italics (everywhere, rather than just in some parsers).

@oblitum
Copy link

oblitum commented May 31, 2013

@CarlRJ, thanks, good to know. Also, I'd like a Markdown 2.0 too, that would provide syntax for "please this is not markdown. parser, don't touch this!", both for paragraph (div-like) and inline (span-like). Would solve issue with embedding MathJax and other stuff inside markdown for all parsers, currently I must use kramdown because of that.

@oblitum
Copy link

oblitum commented May 31, 2013

Also, it's one of the reasons of this highlighter issue. Really, I can't undertand how markdown started without this simple but useful feature, would solve so much.

@hupili
Copy link
Author

hupili commented Jun 1, 2013

Good to find this extended discussion. I'm also looking for MD 2.0. There are so many missing features in MD. I think the philosophy of MD is to only define syntax for 80% of your daily work. The rest 20% can always degrades to HTML. However, the original 80% daily work in the author's mind can only cover 50% of ours now, e.g. formula, table, etc.

I like the please this is not markdown. parser, don't touch this!-syntax mentioned by @oblitum . More generally, I would want a way to specify meta info. for a MD doc. One example: some people uses $ for inline math and some others use \( notation. Another example: MD has long been questioned due to * and _; Apparently they are not rare enough characters to use a delimiter. No matter how hard the original designer tries, he/she will miss some scenarios. Those characters are rare for some people but very common for others. I think a per-doc specification via meta info will help.

Leave some pointers for my trial on MD:

  • evermd is initiated last year when I switched my daily work to MD. At first, I only want to collect some "best current practices", like the how to generate MD headings Taglist . Later I find MD is so limited in function and did some extensions . That was before I massively study what others have done (e.g. different parsers) so the extensions are quite naive and the syntax is far from concise. Some notable features may be variable substitution; template embedding; tex style formula and table.
  • As to mathjax, people all over the world are trying hard to integrate it with MD. e.g. this discussion . Some clumsy solutions are to insert <span> or <div> to wrap your formula. Some parsers can support the Mathjax notation but no ideal (e.g. generate pics). At last, I decide to solve this by two steps: 1) wrap fragile formula with code syntax that all parsers support; 2) use JS to substitute them back (if $ symbol if found at the boundary). very short code diff . This is the best I found so far: 1) work with all parsers; 2) without JS, it degrades to code segment, at least giving some information; 3) with JS, it renders well.

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.

3 participants