Comments (12)
@TitiAlone Hi there, thanks for the detailed issue!
Could you expand on why you think math should be different than code?
Hey, I'd like to buy this computer, but `1,000 is really expensive, I'll buy the one at `600 instead.
Yields:
<p>Hey, I'd like to buy this computer, but <code>1,000 is really expensive, I'll buy the one at </code>600 instead.</p>
You can also escape dollars btw:
Hey, I'd like to buy this computer, but \$1,000 is really expensive, I'll buy the one at \$600 instead.
from remark-math.
Well, I was thinking about emphasis and strong emphasis that require no space between the opening *
character and the content or between the closing *
and the content.
I know this is not handled by remark right now, but GFM example 360 and CommonMark example 351 require it:
*This is not emphasis *
Seems to me like it's not natural to escape the $
sign with a backslash while it is used for some other context in a sentence, while this is not the case with backtick that seldom are used in a normal sentence.
However, I know this is not made clear in any of the specifications, but we ran into the very specific case I included as an example of a forum, and it was quite unclear for the user why this happened.
from remark-math.
Yeah, remark-parse currently doesn’t handle emphasis correctly according to CM, that’s a bug and should be fixed (in micromark).
Still, the question is whether math is like code or like emphasis.
Like emphasis/importance: One way to look at is, is whether the marker ($
, *
, _
, `
) is used in “normal” text, and I think you’re right that the dollar ($
) is used more frequently than the grave accent ( `
).
Btw, about normal text: you don’t have two dollars in a paragraph too often. One is fine and won’t turn into math.
Like code: Another way is that code and emphasis/importance are different: code has a raw value, emphasis/importance have children (they can include more emphasis, importance, links, etc).
And math is more similar to code in that sense: it only has raw content. Therefore I think it makes sense for math to operate more like code.
Emphasis only allows one marker, importance two. I think math is similar to code in that it could have one or two.
Own rules: Finally, there’s Pandoc, which is followed by markdown-it-katex: https://github.com/waylonflinn/markdown-it-katex#syntax, which aligns with what you’re proposing
from remark-math.
What do we do, then? My opinion on this is to treat it like emphasis, but how to decide?
from remark-math.
Emphasis is not entirely the same as the third option (pandoc), did you see the digit handling?
from remark-math.
I don't really see the difference, it is stated that
$20,000 and $30,000 won’t parse as math
which makes it the same?
from remark-math.
I think that’s covered by this test:
from remark-math.
Now I see the difference; I like this syntax; moreover, it's a "convention" in some way. No idea if it is simple to implement, but following this rule would be great.
from remark-math.
Yeah! I like going with the “standard” of the extension. And there’s tests.
Can you work on a PR implementing it?
from remark-math.
I tried before opening the issue, but did not succeed. My major problem was to be able to detect opening vs. closing $
using the actual Regex method.
from remark-math.
Alright, working on it. I’ve got the inline part done, but it seems there’s also two parts in block math where markdown-it-katex
differs from remark-math
, I’ll figure that out in the coming days!
from remark-math.
Thanks a lot, will look forward for your changes.
from remark-math.
Related Issues (20)
- The dollar sign is not showing in single $ quote HOT 6
- rehype-mathjax should not have a dependency on @types/web HOT 13
- Generate (`pre` and) `code` elements instead of `div`, `span` HOT 1
- Hard break identifier immediately preceding $$ is not registered as a hard break. HOT 6
- Next.js hydration issue HOT 9
- Add mhchem support to rehype-katex HOT 14
- `rehype-katex` does not catch non-parse errors HOT 7
- Math and Katex renders incorrectly HOT 2
- remark-katex @mdx-js/rollup integration HOT 7
- rehype-mathjax: CHTML not rendering HOT 10
- Update KaTeX types HOT 5
- Mathjax Docs are Incorrect Due to Removal of index.js HOT 3
- MathJax error -- TypeError: Cannot read properties of null (reading '4') HOT 11
- Cannot read properties of undefined (reading 'mathFlowInside') HOT 14
- [Nuxt MDC] reading 'mathFlowInside' undefined when parsing a multi-line formula HOT 4
- Older version of `jsdom` (<23) causes deprecation warnings HOT 5
- Add a rehype plugin to use mathlive renderer HOT 3
- rehype-katex breaks in production build HOT 6
- mhchem doesn't seem to work with rehype-katex HOT 5
- KaTeX Macros With Global Scope HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remark-math.