Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKEditor - have it return markdown syntax instead of HTML

I'm working on a CMS platform and I am planning to use CKEditor as it seems to offer everything I need.

One thing that is a bit of a bother to me is that I want my content to be in markdown format instead of html and while I found a BBCode extension for this, I couldn't figure out how it can be remade to support markdown.

I tried to find an editor that does markdown out of the box, but the ones I found are way too simple for what I need and CKEditor has the benefit of having a plugin system to adjust perfectly for me.

like image 397
Eman Avatar asked Mar 07 '14 14:03

Eman


2 Answers

CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.

Screenshots:

markdown WYSIWYG

markdown source

See also: Integrated Markdown WYSIWYG text editor (2012)

like image 63
a coder Avatar answered Oct 09 '22 11:10

a coder


Using Markdown instead of HTML is a very bad idea for several reasons:

  1. Markdown has no spec, so every library works differently in details. The output which you'll produce using CKEditor may give a different (even totally wrong) result when transformed to HTML by your back-end. For example - escaping image's title and link texts - you won't be able to ensure that the text user inserted does not break the output.
  2. Not all HTML can be transformed to Markdown.
    • There are plenty of tricky cases which are totally correct in HTML, but cannot be done in Markdown.
    • Markdown has fewer features than HTML, so you'd lose some content which users produced.
  3. You actually gain nothing by using Markdown instead of HTML.

I am a CKEditor core developer, so I know it very well. I tried to implement a Markdown writer for CKEditor and very quickly I found that it's completely pointless. I don't say that it's not possible, because it is, but only a limited stability can be achieved - too low for anything I would personally want to use in production.

like image 32
Reinmar Avatar answered Oct 09 '22 12:10

Reinmar