gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 274 forks source link

Add option for standard latex math notation #762

Closed yagarea closed 2 years ago

yagarea commented 2 years ago

Right now kramdown determinates is math block is in display or inline mode base on its surroundings. Which is weird and uncompatible with anything else.

Standard way to do it is:

Would you please consider adding some option for this standard latex notation ?

gettalong commented 2 years ago

This would only work in a major version release due to compatibility reasons, and I don't have any plans to implement this currently.

Apart from inline math using the same delimiters as block math, what is the problem?

yagarea commented 2 years ago

Apart from inline math using the same delimiters as block math, what is the problem?

Please reconsider addressing this issue because it is such a huge inconvenience and cases me so much waste of time. I am sure that I am not only person having this problem.

gettalong commented 2 years ago
* It interfere with markdown it self. For example you can not create bullet point with only math expression because it will render in display mode. There are a lot more cases like this.

So you mean you want to have a list item with span math and not block math? Easily possible:

* Some block math below
* $$x = 5$$
* Some span math below
* \$$x = 5$$

renders as

<ul>
  <li>Some block math below</li>
  <li>
\[x = 5\]
  </li>
  <li>Some span math below</li>
  <li>\(x = 5\)</li>
</ul>
* You can not use the same markdown text with any other convertor. I use kramdown at my device but I submit my texts to system using pandoc which absolutely breaks rendering because everything is rendered in display mode

That can be viewed as a problem with pandoc... Jokes aside, you don't want to mix and match Markdown libraries. This may be an obvious difference but there are surely other, more subtle differences.

* It is unpleasant to read because you have to care about context of math expression to know how it will render

Only when you start a paragraph with a math expression, otherwise it is clear.

* You can not use search bar in text editors to select only display mode or inline mode

Valid point but how often do you need to do that?

yagarea commented 2 years ago

So you mean you want to have a list item with span math and not block math? Easily possible:

Thanks for suggestion this will help me a lot. On the other hand it makes the syntax even more obscure and unintuitive. I can not help my self from seeing it as "duck tape" solution.

That can be viewed as a problem with pandoc... Jokes aside, you don't want to mix and match Markdown libraries. This may be an obvious difference but there are surely other, more subtle differences.

I understand your point. But TeX math notation is standard this way for last 40 years and I do not know anything else witch would not obey this standard.

If you look at it from the other side what benefits this current notation offers? I can not see anything positive about it and it is only bringing obscurity and incompatibility to this awesome project.

PS: Thank you for your fast and informative responses.

gettalong commented 2 years ago

Thanks for suggestion this will help me a lot. On the other hand it makes the syntax even more obscure and unintuitive. I can not help my self from seeing it as "duck tape" solution.

Yeah, it was implemented later to allow what appears to be math block to be a math span. However, it uses the standard escaping mechanism with backslashes, so not that bad.

If you look at it from the other side what benefits this current notation offers? I can not see anything positive about it and it is only bringing obscurity and incompatibility to this awesome project.

This was implemented in February 2010; to be honest, I can't really recall 100% why I chose this syntax. I think the main reason was avoiding problems with single dollar usage in paragraph, like: I owe you $10, and you own me $50. This is not a problem with LaTeX where people know they have to use a special syntax. (N.b. I have used LaTeX since 2000, so I was well aware of the syntax difference.)

The thing is it is not easily possible to change it now as it would break many existing documents.

yagarea commented 2 years ago

The thing is it is not easily possible to change it now as it would break many existing documents.

And have this as an option (something like --latex-notation) would be acceptable ? This would not interfere with existing documents and add this feature for those who seeks it.


I do not know if this is right place to ask, but I am trying to write a jekyll plugin and I am trying to figure out how to get list of all math expression in inlinde mode and list of math expressions in display mode.

I could to was this:

Kramdown::Document.new(page).root.children.select{ |i| i.type == ":math"}

But it returns list of some objects and it does not distinguish inline/display modes. Is there a way to achieve it ?

Thank you for previous and potential future answers

gettalong commented 2 years ago

And have this as an option (something like --latex-natation) would be acceptable ? This would not interfere with existing documents and add this feature for those who seeks it.

I have a policy of adding no (other) parser changing options to the main kramdown parser. The parser should work the same for everyone so that given a document, one can run kramdown on it and get valid output without knowing any other information.

As for your question regarding getting data from kramdown:

yagarea commented 2 years ago

I have a policy of adding no (other) parser changing options to the main kramdown parser. The parser should work the same for everyone so that given a document, one can run kramdown on it and get valid output without knowing any other information.

Understandable. Thank you for your time.

PS: Thank you for your suggestion. I will take a look at them