remark
remark copied to clipboard
skip Markdown parsing in math formulae
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?
up?
Seems like this is supported in marked since v0.3.6 UPD: ah, no, it is still unmerged/open (https://github.com/chjj/marked/issues/722)
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?
It means you can replace every usage of _
with \_
. SO UGLLLYYYYYYYYYYYY
i see. that worked, though is a bit tedious....
On Wed, Aug 16, 2017 at 8:35 PM, Jongwook Choi [email protected] wrote:
It means you can replace every usage of _ with _.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gnab/remark/issues/336#issuecomment-322952816, or mute the thread https://github.com/notifications/unsubscribe-auth/AACjch7OydA9NkdgovyFHSduQhZR8ifaks5sY6cCgaJpZM4IpQmo .
-- the glass is all full: half water, half air. neurodata.io ps - i am committed to responding to every email i receive, it often takes about a week. thank you for understanding.
up, it's mandatory to reuse existing LaTeX code
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.
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.
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
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.