silverbulletmd / silverbullet-katex

KaTeX plug for Silver Bullet
6 stars 2 forks source link

Shorter way to render LaTeX #1

Open lluni opened 1 year ago

lluni commented 1 year ago

In for example Logseq or Obsidian it is possible to surround a given text with $/$$ to render the text inline/multi-line (kind of like the current option with the LaTeX code block, but usually centered like align*/equation* if not specified otherwise) respectively.

This would make it faster and simpler to write LaTeX as there wouldn't be as much overhead to make a code block anymore.

showgood163 commented 1 year ago

Agree. Inline math formatting and rendering support are very important.

showgood163 commented 9 months ago

Will this issue ever be updated?

alvorithm commented 6 months ago

Hi @zefhemel -- I think this and #4 are essentially asking for inline rendering of math, which in my experience is going to be needed by anybody who needs math.

In other words: I could be wrong, but a plugin that only does display (=paragraph) math is not useful for the vast majority of the math-using audience.

The architectural question is: is it possible to extend inline styles with the plugin mechanism, or does it require deeper changes in silverbullet?

Thank you so much for bringing silverbullet to the world!

zefhemel commented 6 months ago

Yes, I agree and this does indeed make things significantly harder. This cannot be done with a plug and requires extending the existing markdown parser built into SilverBullet.

alvorithm commented 6 months ago

I had a quick search. Since I am unfamiliar with all of Lezer, TS and KaTeX/Mathjax, I really hope these hits are relevant and help in to make math typesetting fully supported in silverbullet: it is such an central use-case for many students, scientists and engineers!

zefhemel commented 5 months ago

Yes those seem relevant. What makes this harder though is that the $bla syntax is already in use for anchors: https://silverbullet.md/Markdown/Anchors so somehow the parser would have to be able to disambiguate between $someFormula$ being parsed as a LaTeX formula and an anchor ending with a $. Perhaps forcing to put spaces around would be acceptable ($ someFormula $)?

alvorithm commented 5 months ago

Yes, that is unfortunate.

If it were up to my sole personal preference (others should chip in!) I'd rather disallow anchors ending with $ (this seems not too unreasonable given the semantics of $ as currency unit?)

Typing formulas is already quite cumbersome, so it'd be nice if it could be as efficient as possible. (Asciimath is a thing, but I think there's no way around the more verbose LaTeX syntax in terms of mindshare.)

For display math, it would be great if the conventional $$ ... $$ (with or without extra spaces, as you may decide) could be adopted. It rolls somewhat better off the fingers than the current latex block, which could be the syntax for syntax-highlighted (La)TeX code.

What do you think?

alvorithm commented 5 months ago

This discussion reminded me of the extensible markdown language designed for Pharo Smalltalk, Microdown (pdf paper). One of their highlights is that they provide for labeled equations, i.e. equations with anchors. Considering this scenario where the two syntaxes interact might help find a way forward.

Their approach to anchors makes it possible to link to figures, and to parameterize code. One of their design goals was for Microdown to remain a subset of Markdown.

Concretely, this how they do math support in microdown.

Something to highlight is that their @anchor is a block element, i.e. must stand on its own line, unlike $anchor in silverbullet.

alvorithm commented 5 months ago

Something I had not considered above is how $ doubling down for anchors and the start of inline math impacts the editing experience. I can think of two aspects to consider:

abhemanyus commented 3 weeks ago

Just chipping in, could an inline code block work, like pandoc's `x = 4`{.ruby}?