Giter Site home page Giter Site logo

Add support for maths input about joplin HOT 15 CLOSED

laurent22 avatar laurent22 commented on May 3, 2024 11
Add support for maths input

from joplin.

Comments (15)

laurent22 avatar laurent22 commented on May 3, 2024 2

For information, I got it working in this branch but there's some issue with the CSS which makes the fraction bar appears slightly too high. Other than that it seems to be fine.

Since it's the second most popular request, I might look at it again later, or if someone can figure out the CSS that would be great.

from joplin.

jeanm avatar jeanm commented on May 3, 2024 2

That looks brilliant!

Any chance it could use a syntax already used by other markdown engines/app, instead of a new one? Such as the pandoc one, with $$ for display and $ for inline? There is a summary table here of all the places that already support this syntax.

from joplin.

laurent22 avatar laurent22 commented on May 3, 2024 2

Done, the next release will support both $ and backtick syntaxes.

from joplin.

jeanm avatar jeanm commented on May 3, 2024 1

Thanks for looking into this!

@cofinley's suggestion would work, but I would also look into markdown-it-katex. KaTeX is a new typesetting library built by the Khan Academy people, because MathJax was too slow for them. Look at the comparison at the bottom of their homepage: https://khan.github.io/KaTeX/ . For Joplin's use case I would expect the speed gains from using KaTeX vs MathJax to be non-trivial. Not to mention the lack of reflowing, which is something really annoying in long pages that use MathJax.

from joplin.

laurent22 avatar laurent22 commented on May 3, 2024

I'm using markdown-it for rendering and there are two plugins for Math support:

https://github.com/runarberg/markdown-it-math

https://github.com/waylonflinn/markdown-it-katex

Do you know about the syntax they use? Is one better than the other?

from joplin.

cofinley avatar cofinley commented on May 3, 2024

I'd say MathJax, which seems to be the markdown editor standard.

Github
NPM

from joplin.

cofinley avatar cofinley commented on May 3, 2024

@jeanm: Oh cool! I didn't know that about its background.

I agree, long document load times are very noticeable with MathJax. It looks like there was some debate on Latex features support in Katex a few years ago, but I'd imagine it's better now.

from joplin.

laurent22 avatar laurent22 commented on May 3, 2024

The mathjax package seems to be abandoned, so it would probably be better to use a different one. Maybe the katex one then.

from joplin.

laurent22 avatar laurent22 commented on May 3, 2024

Support for Katex is now available. I've tried with various expressions and as far as I can tell it works, but if there's any mathematician here please give it a try and let me know if something's off.

In the end I've simply used the actual Katex lib instead of the plugin as this is well supported, and it means we can get the latest fixes and improvements easily.

To add an inline equation, wrap the expression in `{.katex}EXPRESSION`, eg. `{.katex}\sqrt{3x-1}+(1+x)^2`. To create an expression block, wrap it as follow:

```katex
EXPRESSION
```

For example:

```katex
f(x) = \int_{-\infty}^\infty
    \hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi
```

Here is an example with the Markdown and rendered result side by side:

from joplin.

laurent22 avatar laurent22 commented on May 3, 2024

This is now part of the desktop version and will be in Android and iOS soon too

from joplin.

hughwilliams94 avatar hughwilliams94 commented on May 3, 2024

Hey sorry to reopen this but is there any chance that $ and $$ could be added to the autocomplete so that typing one inserts the other half of the pair as already happens with square brackets etc.?

from joplin.

dzackgarza avatar dzackgarza commented on May 3, 2024

I may be missing something, but this issue says math support was added, and while I've created a note with $$ in markdown on the android app, it does not seem to render. Here's an image of what I'm seeing: test

from joplin.

Outi-s avatar Outi-s commented on May 3, 2024

@dzackgarza you've to edit the note, the note will render it. That red circle with pencil on it.
You've currently copied the content into the title field. After rendering:
screenshot_20181203-114038

from joplin.

dzackgarza avatar dzackgarza commented on May 3, 2024

Ahhh I see! I thought these were just plain markdown files, had no idea there was a title field or anything like that. Confirmed that this works, thanks.

from joplin.

Outi-s avatar Outi-s commented on May 3, 2024

@dzackgarza, your data is stored in markdown format. The Title field is there for the convenience of users. You don't actually have to use it, app takes the first line as Title as well.

from joplin.

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.