GitbookIO / plugin-mathjax

MathJAX plugin for GitBook
Apache License 2.0
89 stars 53 forks source link

inline formula notation issue #15

Closed brlin-tw closed 8 years ago

brlin-tw commented 8 years ago

I wonder why the inline formula notation $$...$$ is different with math mode - Inline equation in latex with text - TeX - LaTeX Stack Exchange $...$

cben commented 8 years ago

[not a gitbook dev, just providing context]

The problem everybody runs into with $ is false positives — texts like It costs between $20 and $37 occur naturally and having them turn into math unless escaped would be annoying to users who don't need math, and incompatible to the original markdown (well, any syntax extension is technically incompatible but practically the question is whether many or few existing documents change meaning).
There are many solutions to this, eg. constraining $ with heuristics (e.g. closing $ not followed by digit and not under full moon), using \( / \[ (which interfere with escaping some markdown syntaxes) or \\( / \\[ instead, etc.
Using $$ for both inline and display was I believe an invention of kramdown, and is one of the prettier solutions. There is interesting critique on https://github.com/GitbookIO/kramed/issues/3 however that it prevents conveying when display math is part of a larger "semantic paragraph" (a concept mostly ignored by Markdown but easily expressed in LaTeX). And {% math %}...{% endmath %} is of course modeled on Gitbook templating constructs.

FWIW, I'm cataloging math in markdown syntaxes at https://github.com/cben/mathdown/wiki/math-in-markdown

pkra commented 8 years ago

FWIW, I'm cataloging math in markdown syntaxes at https://github.com/cben/mathdown/wiki/math-in-markdown

@cben that's very useful! Thanks for sharing this.

SamyPesse commented 8 years ago

@cben Awesome answer :+1:

With GitBook, inline math are differentiated from block math using the first character, example:

Some inline math $$a = b$$

And a block of math:

$$
a = b
$$
cben commented 8 years ago

I like that! 2 late questions:

  1. If there are trailing spaces between the opening $$ and the newline it becomes inline. IMHO surprising, should be still block.
  2. It seems that's specific to GitBook plugins, kramed itself still uses same regex as kramdown, essentially /^ *$$...$$ *\n/ (sounds like should be alone on a line, but I tested kramdown and it actually must be alone in paragraph, as documented, there is probably extra logic...). Right?

    Given that kramed is "your" fork, any plans to match gitbook rule, or will you keep the kramdown rule?

weihuayi commented 5 years ago

For the inline math, does there exist any way to reset it to $ .... $ in gitbook? I find $$ ... $$ annoy me very much when I want to copy markdown to latex or other place.

yoczhang commented 5 years ago

For the inline math, does there exist any way to reset it to $ .... $ in gitbook? I find $$ ... $$ annoy me very much when I want to copy markdown to latex or other place.

Have you found the right way? @weihuayi

weihuayi commented 5 years ago

我尝试解决过这个问题,但一直没有成功。

---Original--- From: "YcZhang"notifications@github.com Date: Sat, Aug 10, 2019 02:39 AM To: "GitbookIO/plugin-mathjax"plugin-mathjax@noreply.github.com; Cc: "Huayi Wei"weihuayi@xtu.edu.cn;"Mention"mention@noreply.github.com; Subject: Re: [GitbookIO/plugin-mathjax] inline formula notation issue (#15)

For the inline math, does there exist any way to reset it to $ .... $ in gitbook? I find $$ ... $$ annoy me very much when I want to copy markdown to latex or other place.

Have you found the right way? @weihuayi

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

weihuayi commented 5 years ago

可以先把 markdown 转成 latex 试试

---Original--- From: "YcZhang"notifications@github.com Date: Sat, Aug 10, 2019 02:39 AM To: "GitbookIO/plugin-mathjax"plugin-mathjax@noreply.github.com; Cc: "Huayi Wei"weihuayi@xtu.edu.cn;"Mention"mention@noreply.github.com; Subject: Re: [GitbookIO/plugin-mathjax] inline formula notation issue (#15)

For the inline math, does there exist any way to reset it to $ .... $ in gitbook? I find $$ ... $$ annoy me very much when I want to copy markdown to latex or other place.

Have you found the right way? @weihuayi

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.