orsharir / github-mathjax

Chrome extension for rendering LaTeX equations in GitHub with MathJax
Other
153 stars 49 forks source link

`{}` escape problem with the plugin #26

Closed david11rsww closed 5 years ago

david11rsww commented 5 years ago

When the mathjax expression is $\{...\}$ format, then the plugin will not render out {}. It requests a double escape format $\\{...\\}$ in order to render out the html content {} .

ghost commented 5 years ago

Duplicate of https://github.com/orsharir/github-mathjax/issues/10 . See this.

U=$\lbrace1,2,3\rbrace$

$U=\lbrace1,2,3\rbrace$

muzimuzhi commented 5 years ago

For commands having backslash and single non-letter symbol as its name, e.g. \{, \,..., it seems the backslash should be escaped. For example, use

$\\{a, b\\}$

to get $\{a, b\}$.

muzimuzhi commented 5 years ago

This is a "feature" of GitHub Flavored Markdown (GFM), aka, how GitHub converts markdown to html.

First, GitHub converts every pair of \ + <symbol> in markdown into the <symbol> in html, where the <symbol> is a non-letter symbol. See Backslash Escapes - GFM Spec.

Then the github-mathjax extension uses what GitHub outputs as its input. Hence, for github-mathjax to get a \{, you need type \\{ as the input of GitHub.

Since github-mathjax can only see what GitHub outputs, this "feature" hardly can repair.

ghost commented 5 years ago

Which editor are you using? I am using VSCode with vscode-markdown extension. Because this extension doesn't show \\{ appropriately in a live preview pane, I am typing \lbrace instead of \\{.

muzimuzhi commented 5 years ago

Which editor are you using?

@jinbeomhong

A program uses markdown text as input and outputs html is called a markdown previewer/engine. Every time you "see" the html version (with a plenty of text styles) of some markdown text, you actually "see" the output of some markdown engine.

Here, the vscode extension implements its own markdown engine, which acts, as you have found out, not the same as the engine used by GitHub. Actually, almost every markdown engine acts a bit different with each other, and most of those engines does not have a detailed specification. To this point, GitHub, with its GFM, does a good job.

Bad news is, I have not find any fully-offline markdown engine which acts 100% the same as the one used by GitHub. For example, try the examples in Tables (extension) - GFM in your vscode extension.