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

skip Markdown parsing in math formulae #336

Open
anaderi opened this issue May 29, 2016 · 10 comments
Open

skip Markdown parsing in math formulae #336

anaderi opened this issue May 29, 2016 · 10 comments
Labels

Comments

@anaderi
Copy link

anaderi commented May 29, 2016

Hi,

I have a couple of formulae that I render with Katex:

$\dfrac{ F_s }{ F_b }$

$\dfrac{ F_s ( x_{event} ) }{ F_b }$

results are quite different:

obviously in the second case underscores are parsed by MD, and it can be fixed by manual escape of underscores by , but it's a bit ugly.

Is it possible to skip Markdown parsing within math formulae?

@anaderi
Copy link
Author

anaderi commented Nov 4, 2016

up?

@anaderi
Copy link
Author

anaderi commented Nov 6, 2016

Seems like this is supported in marked since v0.3.6
UPD: ah, no, it is still unmerged/open (markedjs/marked#722)

@jovo
Copy link

jovo commented Aug 17, 2017

i have the same problem. i don't understand the comment

it can be fixed by manual escape of underscores by , but it's a bit ugly.

perhaps @anaderi can explain?

@wookayin
Copy link

wookayin commented Aug 17, 2017

It means you can replace every usage of _ with \_. SO UGLLLYYYYYYYYYYYY

@jovo
Copy link

jovo commented Aug 23, 2017 via email

@liuq
Copy link

liuq commented Nov 9, 2017

up, it's mandatory to reuse existing LaTeX code

@cben
Copy link

cben commented May 22, 2018

Perhaps try switching to kramed, a fork of marked with some changes, including proper math support. It uses kramdown math syntax — $$ delimeters for both inline and display math (https://github.com/GitbookIO/kramed/blob/master/test/tests/math.text).

Or, consider using a literal-based math syntax such as Gitlab.
(see https://github.com/cben/mathdown/wiki/math-in-markdown#Gitlab for that and various other syntaxes). Literals can pass through any parser, keeping you free to use any markdown parser that fits your goals and simply handle math as post-processing, without bugs like this.

@yuekai
Copy link

yuekai commented Aug 28, 2019

I recently encountered this issue and decided to fix it. It's a bit of a hack because this is not really an issue with remark; it's an issue with marked, the markdown parser that remark depends on. The issue is further complicated by the fact that remark uses an old release of marked, and there have been many breaking changes (to marked) since the old release that remark depends on.

I forked an old release of marked and made the necessary changes to allow math passthrough. I also updated my fork of remark to use my fork of marked. I know this is a bit hacky, but this is the best solution I could come up with for now. Hope this helps.

@isentropic
Copy link

Is there any progress with this? This is perhaps the turning point for me to use remark fulltime. With lots of copying of latex equations, escaping underscores is not 2 way compatible with standard latex

@RMWinslow
Copy link

Here's another imperfect workaround:

I'm using remark with KaTeX and Jekyll (via github pages).

In the Jekyll template, instead of using {{page.content}}, I use {{page.content | replace: "_", "\_" }}

This means that the original equations are preserved in the markdown source, and Jekyll does the replacement while building the html files.

The downside is that all underscores are replaced with this method.

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

No branches or pull requests

9 participants