Getting Pagedown to preview markdown and mathjax at the same time?

  • 0
  • Pump00:00

First i got a js script to update a preview div from Pagedown textarea/Pagedown widget from Django-pagedown, with the code below:

  tex2jax: { inlineMath: [['$', '$'], ["\(", "\)"]] }

var timeout;
$(function () {
  function makePreview() {
    input = $('#id_content').val().replace(/</g, "&lt;").replace(/>/g, "&gt;");
    MathJax.Hub.Queue(["Typeset", MathJax.Hub, "preview"]);
  $('body').keyup(function () {
    if (timeout) {
      timeout = null;
    timeout = setTimeout(makePreview, 400);
  $('body').bind('updated', function () { makePreview() });

But the problem is that when this script updates the preview div, it also updates and removes the markdown? If i constantly type then the markdown shows correctly, but not mathjax. If I stop typing the markdown don’t show, but mathjax shows correctly?

I know the answer is here but i don’t know how to do it. Looks like i have to remove and store the math, and then put it back in later.

Default Asked on December 28, 2019 in Programming.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.