Skip to content
loading...
The DEV Team profile image The DEV Team

Wouldn't it be cool if DEV could render LaTeX?

twitter logo github logo ・1 min read  

Oh neat, you can.

c=±a2+b2 c = \pm\sqrt{a^2 + b^2}

Here's the code to produce that snippet:

{% katex %}
c = \pm\sqrt{a^2 + b^2}
{% endkatex %}

It's new and there will be kinks that need to be worked out.

Kudos to @maestromac for a really fabulous implementation.

Implement KatexTag #6237

What type of PR is this? (check all applicable)

  • [x] Feature

Description

Used katex-ruby gem to make a Katex Liquid Tag.

  • In order to make this work, I had to turn off Redcarpet's superscripts feature. I was more comfortable with this change when I learn that Github and Gitlab shared similar settings.
  • I found it impossible to pass our storybook prebuild because it can't resolve @import _katex as that is a geminifed CSS. I've decided to copy provided CSS into our own app. I'd imagine this would help with serving up CSS for stack bit apps. If this is a bad idea please let me know.

Misc resources:

Related Tickets & Documents

Resolves https://github.com/thepracticaldev/dev.to/issues/182 Resolves https://github.com/thepracticaldev/dev.to/issues/97

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Kapture 2020-02-21 at 16 07 15 image

Added tests?

  • [x] yes

Added to documentation?

  • [x] yes, need to add in the editor guide

[optional] Are there any post-deployment tasks we need to perform?

n/a

Happy coding!

twitter logo DISCUSS (18)
The team behind this very platform. 😄
markdown guide
 

(ωοwtαtsamazing) \int\left(\frac{\omega \omicron^w}{\mathit{t}\hbar \alpha t'^s\cdot a_ma\mathbf{z}ing}\right)\int
 
 

Cool to see that

LaTeXSupported Features\text{\LaTeX} \in \text{Supported Features}
 
 
 

I wanted this feature for a long time. Even, I asked this to DEVs on dev.to before.

Thanks everyone for adding this feature!

 

Damn... I haven't used LaTeX since the mid-90s. :)

 
 

Awesome!

It would also be great if we could get support for the double dollar sign notation:

$$x^2$$

I use this on my Jekyll blog, which also renders KaTeX :)

 

Interesting...

Is that fully inline, so $$x^2$$ automatically becomes...

x2 x^2

?

 
 

Yup, you can use it to generate both inline and block-level LaTeX:

This is $$x^2$$ a sentence.

Or:

$$x^2$$

 

Thank you! I was scratching my head wondering how to do this. This will enable math-related articles to be posted here.

 

LaTeX was a major part of my stint in academia. Have something of a love/hate relationship with it, but this is a welcome feature, nonetheless.

 
 
 
Classic DEV Post from Aug 28 '19

How did you feel after your first open source PR?

A thread discussing the sensation of contribution to open-source.

The DEV Team profile image
The hardworking team behind dev.to ❤️

Want to contribute to open source and help make the DEV community stronger?

All the dev.to code is freely available on GitHub.

You're welcome to jump in!

JOIN DEV NOW

We are a community