brrd / abricotine

Markdown editor with inline preview
GNU General Public License v3.0
2.63k stars 156 forks source link

Custom delimiters for math fomulas (inline and display) #15

Open brrd opened 8 years ago

brrd commented 8 years ago

From #7

Would it be possible to display math when wrapped only in single '$'s too (or is there an easy way to hack to config to allow this)? Doing so would help to make Abricotine more compatible with Pandoc Markdown.

More generally, the idea would be to allow the use of any delimiter with a new option in config.

Inline and display math should be supported.

adiultra commented 8 years ago

Katex supports custom delimiters, here is the syntax:

<script>
  renderMathInElement(
      document.getElementById("test"),
      {
          delimiters: [
              {left: "$$", right: "$$", display: true},
              {left: "\\[", right: "\\]", display: true},
              {left: "$", right: "$", display: false},
              {left: "\\(", right: "\\)", display: false}
          ]
      }
  );
</script>

16

joelostblom commented 8 years ago

This would be a great feature! As indicated in the issue, it would be very helpful to be able to use both $ and $$ as math delimiters in Abricotine, since Pandoc/Latex requires the single $ for inline math and double for displayed equations.

RoyiAvital commented 8 years ago

It can also be achieved in MathJaX:

<!-- Scripts to handle MathJax -->
    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
    });
    </script>
    <script async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <script async src="http://markdownedit.com/assets/js/mathjax-scripts.js"></script>

What really needed is making difference between Inline Math and Display Math.

Hugo-Trentesaux commented 6 years ago

If custom delimiters are supported, \begin{equation} and \end{equation} would be great to add :smile:

RoyiAvital commented 6 years ago

@Hugo-Trentesaux, No need. Once you warp the Math around a label which you guide MathJaX to handle you'll get support for those environments "For Free" (It's built in MathJax).