Coder Social home page Coder Social logo

Comments (12)

wooorm avatar wooorm commented on August 16, 2024 1

@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.

StaloneLab avatar StaloneLab commented on August 16, 2024

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.

wooorm avatar wooorm commented on August 16, 2024

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.

StaloneLab avatar StaloneLab commented on August 16, 2024

What do we do, then? My opinion on this is to treat it like emphasis, but how to decide?

from remark-math.

wooorm avatar wooorm commented on August 16, 2024

Emphasis is not entirely the same as the third option (pandoc), did you see the digit handling?

from remark-math.

StaloneLab avatar StaloneLab commented on August 16, 2024

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.

wooorm avatar wooorm commented on August 16, 2024

I think that’s covered by this test:

https://github.com/waylonflinn/markdown-it-katex/blob/81b84a7d91d74a1ba3d4769b847a5bf1947256cb/test/fixtures/default.txt#L185

from remark-math.

StaloneLab avatar StaloneLab commented on August 16, 2024

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.

wooorm avatar wooorm commented on August 16, 2024

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.

StaloneLab avatar StaloneLab commented on August 16, 2024

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.

wooorm avatar wooorm commented on August 16, 2024

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.

StaloneLab avatar StaloneLab commented on August 16, 2024

Thanks a lot, will look forward for your changes.

from remark-math.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.