Log in

Change the default markdown editor

Hello,

I would like to have mathematical formulas in the posts, but the default markdown editor does not support latex.
I found this: https://github.com/JaapJoris/django-pandocfield, which provides latex support in markdown.
Can I replace the default editor with this? If yes, can you give me some hint on that.

Thanks a lot.

nitelyEsteban Castro Borsani

mmmh, mistune (spirit's markdown) does support Math/MathJax[0]. I'm guessing that would be easier to implement, since it would just be installing contrib lib and enabling the plugin. Otherwise you gotta replace mistune server-side[1] and re-implement too many features (pools, mentions, etc) and the client side editor[2], but I can't really help you there, it's too much work

[0] https://github.com/lepture/mistune#contribution--extensions
[1] https://github.com/nitely/Spirit/blob/master/spirit/core/utils/markdown/markdown.py
[2] https://github.com/nitely/Spirit/blob/master/spirit/comment/templates/spirit/comment/_editor.html

  • 7 Nov

Thank you for your answer.

I installed mistune-contrib and successfully have tex commands shown in markdown. Btw, spirit is awesome

pdp7Losing Braincells
  • 14 Nov

Tried to find out more about the mistune but there is no documentation what markdown works and what not?

Most seem to work, but I didn't get tasklist to work.. so far.

  • [x] Write the press release
  • [ ] Update the website
  • [ ] Contact the media

Otherwise markdown cheat sheet works fine...

nitelyEsteban Castro Borsani
  • 14 Nov

@pdp7 everything here https://daringfireball.net/projects/markdown/syntax , I meant to add a help link below the editor to show the syntax but never got to it. The tasklist thing is something non-standard, but I can implement it if you need it.

pdp7Losing Braincells
  • 14 Nov

@nitely Ok then. That's good thing to know, since I can make relevant how-to post for our new and shiny! That tasklist was in markdown cheat sheet and I just tested them through and noticed this one doesn't work.

All looks excellent so far. Lightweight but still all those whistles and blings one "need" for modern forum. Nice work!

Is there some default limit for image size? Couldn't find anything about it.

Thanks again!

nitelyEsteban Castro Borsani
  • 1
  • 16 Nov

Is there some default limit for image size? Couldn't find anything about it.

You should reject big images before they hit Django. Public sites should use something like nginx in front of Django (i.e: as a reverse proxy) and set the limit there. Otherwise Django will receive the whole image even if you reject it later within the form validator.

pdp7Losing Braincells
  • 16 Nov

Ach so! So there is some limit set in upload process. I was wondering why many of the images are ending up in error. Also I noticed that for some reason some files ending .JPG and not .jpg are producing an error. And I have tested this with same image just renaming it.

nitelyEsteban Castro Borsani
  • 1
  • 16 Nov

There are some validators in place, for example the file extension and the file integrity are checked, so only real images are accepted. The extension is case sensitive for some reason, I'll open an issue t make it insensitive. There is a setting to allow more image formats [0]

So there is some limit set in upload process

mmh, if spirit is behind a reverse proxy like nginx then sure. Nginx has a 1MB file size limit by default, I think. Apache has some limit too.

[0] https://spirit.readthedocs.io/en/latest/settings.html#spirit.core.conf.defaults.ST_ALLOWED_UPLOAD_IMAGE_FORMAT

pdp7Losing Braincells
  • 16 Nov

Ok then clears some things. That case sensitiveness is something that might be confusing for the first time, but I have laid out these and other things for the forum users, so they can easily access the information and not get frustrated when their pictures might trigger an error.

Apache is what server mine to the world, so I'll check that then. Don't really know since that isn't my box. But things are looking good at the moment and when these minor thingies are solved one way or another everything will be great!

Thanks again!

Reply