有什么好的 Markdown Javascript 库或控件吗?

我想建立一个网站,用户可以输入文本和格式化它在 Markdown。我之所以想要一个 Javascript 解决方案是因为我想要显示一个实时预览,就像在 StackOverflow 上一样。

然而,我的站点并不针对开发人员,因此编辑器控件是最理想的。

我猜在 StackOverflow 上,大规模杀伤性武器的编辑器被使用了。

在谷歌上快速搜索一下,还会出现 Showdown 库,我认为它实际上正在被大规模杀伤性武器所使用。

还有其他选择吗? 大规模杀伤性武器/摊牌已经是很好的工具了吗? 不同的选择你有什么经验?

33545 次浏览

As far as I know there really isn't any other browser-based editor for Markdown, at least none as extensive as the WMD editor.

Showdown is a Markdown converter in JS, which forms the basis for the HTML preview of WMD. They're both made by http://attacklab.net/.

And as far as I know there haven't been any big complaints about both (at least not on the Markdown mailing list). So go for it.

I've not tested this, but here is another option:

Markdown wysiwyg

We've been pretty happy with WMD. There are a few niggling bugs in it, however. Nothing major, but I would love if John Fraser (the author) made the code open source so we can fix some of them. He's promised to do so but other real life projects are getting in the way.

I do follow up with John every week. I'll post on the blog once the WMD source is finally available. Haven't been able to contact John Fraser in over a year now.

We have open sourced both the JavaScript Markdown library

http://code.google.com/p/pagedown/

and the server-side C# Markdown library

http://code.google.com/p/markdownsharp/

If you're not averse to using Ajax to generate the live preview, then another option is markItUp!. markItUp! is a universal markup-editor, and very flexible. It does provide an easy way of creating a markup editor, but unlike WMD, it doesn't provide its own live preview.

I used markItUp!, along with a simple JSP (using MarkdownJ) for one of my open-source projects (a Markdown plugin for Roller). If you're using another server-side technology, replace that simple JSP as appropriate.

I actually starting using this before I came across WMD. I'd agree, WMD is great, but has only just been open-sourced and is, at this stage, more difficult to customize the behavior of.

There is one named Showdown and it is currently hosted here: https://github.com/coreyti/showdown

And there is https://github.com/evilstreak/markdown-js :)

The question is ancient but hopefully this might help someone. I have just recently published a working version of my own Javascript markdown editor, uedit. You can find the source code here. It works on most browsers (including IE6+) and doesn't depend on any external JS libraries.

The question is even more ancient now but also even more relevant since much of the mentioned code is several years out of date.

However, I did find a few that still seems current:

Jquery-Markedit - This was forked from wmd-edit quite some time ago and refactored to use jQuery. Seems good at first sight.

EpicEditor - is also still maintained, has a flexible parser and, as you can see below, the author is highly responsive (see below). IT seems to have good documentation as well. Sadly not working with IE9.

MarkdownDeep is a third option that is still current. The interesting point with this one is support for Markdown Extra. Has a dependency on JQuery (actually you can also implement without JQuery). Based on the .NET version so documentation is more aligned to that than the JS version. This also works with IE9. It is very easy to use (with JQuery) & very simple. No significant development happening with this though as far as I can see.

js-markdown-extra is a fairly accurate port of the PHP library and is still under maintenance. It supports Markdown Extra of course.

After trying with several plugins to solve my own needs of offering a MarkDown seudo-WYSIWYG I ended implementing my own one:

Maybe is not as powerful as all the solutions commented here but I think that none is as simple and easy to integrate and customize.

Strapdown.js, which was recently released, "makes it embarrassingly simple to create elegant Markdown documents. No server-side compilation required."

I would recommend marked, which is lightweight, efficient, easy to use and supports GitHub Flavored Markdown (GFM) as well. It can be used in either server(nodejs) or client(browser) sides.