How do you store the markdown using WMD in ASP.NET

2020-02-08 18:25发布

I have implemented the WMD control that Stack Overflow uses into a project of mine, it almost works like a charm, but when I save the changes to the database it is saving the HTML version and not the Markdown version.

So where I have this in my text box:

**boldtext**

It is really saving this:

<b>boldtext</b>

How do I make it save the Markdown version?

2条回答
Explosion°爆炸
2楼-- · 2020-02-08 19:00

Before you include wmd.js, or whatever you've named the WMD editor JavaScript code locally, add one line of JavaScript code:

wmd_options = {"output": "Markdown"};

This will force the output of the editor to Markdown.

查看更多
放我归山
3楼-- · 2020-02-08 19:01

If you're using the new WMD from http://code.google.com/p/wmd-new/, open wmd.js and add this line:

wmd.wmd_env.output = 'markdown';

Excerpt:

...
wmd.ieCachedRange = null; // cached textarea selection
wmd.ieRetardedClick = false; // flag

wmd.wmd_env.output = 'markdown'; // force markdown output

// Returns true if the DOM element is visible, false if it's hidden.
// Checks if display is anything other than none.
util.isVisible = function (elem) {
...

That should do the trick.

查看更多
登录 后发表回答