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

折月煮酒 提交于 2019-12-29 04:24:16

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/122108/how-do-you-store-the-markdown-using-wmd-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!