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

Ignore some characters #845

Closed
badbye opened this issue Jan 20, 2017 · 6 comments
Closed

Ignore some characters #845

badbye opened this issue Jan 20, 2017 · 6 comments

Comments

@badbye
Copy link

badbye commented Jan 20, 2017

Is it possible to do some configuration to ignore some characters? For example, forbidden to use the _ character.

I am using Mathjax to render the latex equations, however sometimes marked convert $x_1y_1$ to $x<em>1y</em>1$.

@badbye
Copy link
Author

badbye commented Jan 20, 2017

I find the rules of em and try to edit it, however it does not work.

> marked.InlineLexer.rules.em
/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/

> marked.InlineLexer.rules.em = /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/

> marked('_hi_')
"<p><em>hi</em></p>
"

@badbye
Copy link
Author

badbye commented Jan 20, 2017

Alright, I see. Here is my solution:

> marked.InlineLexer.rules.gfm.em = /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/

> marked('_hi_')
"<p>_hi_</p>
"

Please let me know if there is a better solution.

@Jiang-Xuan
Copy link

Jiang-Xuan commented Feb 10, 2017

you want to output '_' char ?
you can escape some char.
for example:

marked('\\_hi\\_')

PS: I am a Chinese boy is not good at English and javascript.Please don't keep in mind if I say something wrong.

@Jiang-Xuan
Copy link

@badbye
If you edit marked.InlineLexer.rules.em to /^\*((?:\*\*|[\s\S])+?)\*(?!\*)/.

_marked_ can not to generate em element

@Feder1co5oave
Copy link
Contributor

It's as if you asked the C compiler to not parse plus signs, they're part of the language and they have semantics too.

@joshbruce
Copy link
Member

See #936 - closing as covered by another issue or request. Integrating math.

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

No branches or pull requests

4 participants