madebymany / sir-trevor-js

Rich content editing entirely re-imagined for the web
http://madebymany.github.io/sir-trevor-js/
MIT License
4.51k stars 399 forks source link

Support Latex Equations. #86

Open lucassimon994 opened 11 years ago

lucassimon994 commented 11 years ago

Latex support is one of the most important aspects of a modern blogging platform for many people in the sciences and mathematics because of its excellent support for rendering equations. One library which supports rendering of latex equations is mathjax. Although equations could be put into the page currently with the use of GIF's, it is a sluggish process to do so. With that, I think that mathjax or another latex equation rendering library should be implemented with sir trevor.

andflett commented 11 years ago

+1

Personally I'd love to find a way to make this possible.

Sir Trevor is all about making sure our inputs are as clean as possible, and we store data in a structured fashion so that it can be transformed by whatever display technology you want to use.

LaTeX commands are probably the best, cleanest way to store the data for these equations - you could easily create a custom block for this sort of input.

Then it's up to the front-end template to decide how it's rendered, be it MathJax or other libraries.

@cjbell88 @ninjabiscuit how do we currently handle shipping default rendering templates with block types at the moment?

lucassimon994 commented 11 years ago

If implemented, it would be helpful to have block types, but to also support nested Latex formatting as well. An example excerpt where this is useful is

Let $E$ be a measurable set and $f: E \rightarrow \mathbb{R}$ be a measurable function where

\begin{equation} \int_E f < \infty \end{equation}

This would render into something that looks like

codecogseqn

Except the integral at the bottom would be centered. It is common to use Latex formatting inline with the text.

simonwoodhead commented 10 years ago

If you are happy for the user to enter LaTeX code a custom LaTeX block should be quite easy. However LaTeX is not pretty, it would be equivalent of requiring users to enter \bold{this is some bold text} in the Text block. Ideally a WYSIWYG editor would be created (like the equation editor in Word). This is not a small task.

There are some options available:

MathQuill Uses its own system for formatting mathematics (not MathJax).

Wiris A complete online editor for mathematics (can use MathJax for display uses its own system for editing). There are plugins for lots of other editors and I assume creating one for Sir Trevor would not be too difficult. However, it does not particularly match the minimalist style. It is a commercial product.

A MathJax based editor Seems to be in very early development, but this editor uses MathJax for display and editing.

Mathway have an editor which is entirely built on MathJax but does not seem to be publicly available.

As @lucassimon994 has said you really want to be able to add LaTeX inline as well so you would want the ability to add inline mathematics in a normal Text block too.