我找不到任何真正的来源。我正在 ASP.NET MVC 3 中构建一个网站,并希望利用 Stack Overflow 使用的 Markdown 编辑器。有人有好的教程吗?
最新的markdown在哪里下载?它是用什么语言写的?我应该从哪里开始将其集成到 MVC 3 项目中?即使在我完成了所有的搜索和阅读之后,我仍然很困惑。
我发现了这个网站。但这似乎太古老了,而且我似乎必须学习一些关于 CGI 和 Perl 的知识,而我完全没有经验。如果有 JavaScript/jQuery 版本那就太好了。
更新
我注意到这个问题得到了相当多的关注,所以我决定用一些有用的参考资料来更新它。我设法让 Markdown 编辑器在我的网站上运行良好,并且我写了一些关于它的博客。
I couldn't find any real sources for this. I'm building a site in ASP.NET MVC 3 and would like to take advantage of the Markdown editor that Stack Overflow uses. Does anybody have a good tutorial?
Where do you download the latest markdown? What language is it written in? Where would I start in integrating this into an MVC 3 project? Even after all the searching and reading I've done I'm still pretty confused.
I came across this site. But this seems outlandishly old and it would seem I would have to learn a little something about CGI and Perl which I have absolutely no experience with. A JavaScript/jQuery version would be splendid.
Update
I noticed this question is getting a fair amount of views so I decided to update it with some helpful references. I managed to get a Markdown editor working nicely on my website, and I wrote a few blogs about it.
发布评论
评论(4)
Stackoverflow 向全世界开源了他们的 Markdown 版本。它名为 MarkdownSharp,是用 C# 编写的。
有人在这里写了一个 HtmlHelper:
http: //blog.dantup.com/2011/03/an-asp-net-mvc-htmlhelper-extension-method-for-markdown-using-markdownsharp
如果您正在寻找如何实现 JavaScript 编辑器,这里有一个现有的问题:
将 Markitup 文本编辑器集成到 ASP.NET MVC 项目
Stackoverflow open sourced their version of Markdown to the world. Its called MarkdownSharp and is written in C#.
Somebody wrote a HtmlHelper here:
http://blog.dantup.com/2011/03/an-asp-net-mvc-htmlhelper-extension-method-for-markdown-using-markdownsharp
If you are looking for how to implement a javascript editor there is an existing question:
Integrate Markitup text editor to ASP.NET MVC project
您可能正在寻找 MarkdownSharp
要将其集成到 MVC 应用程序中:
在直到或公共控制器中,添加以下操作方法
和客户端 JS:
<前><代码>$(函数 () {
var mdText = $("#mdText");
var mdFormatted = $("#mdFormatted");
函数 setFormatted(数据) {
mdFormatted.html(数据);
};
mdText.toObservable(“按键”)
.油门(200)
.订阅(函数() {
$.getJSON("@VirtualPathUtility.ToAbsolute("~/Util/FormatMarkdown/")", {
markdownText: mdText.val()
}, setFormatted);
})
下载 RxJs(来自 MSDN)并包含以下两个js文件
You are probably looking for MarkdownSharp
To integrate it into an MVC app:
In a until or common controller, add the following action method
in your client side view:
and client side JS:
Download RxJs (from MSDN) and include the following two js files
我知道这个问题已经很老了,但我偶然发现了另一个解决方案markdowndeep,它对MVC非常友好
它可以通过nuget安装PM>安装包 MarkdownDeep.Full
C# 中的 Markdown
编辑器
1.将提供的js、css、png和htm文件复制到您的服务器。根据您将这些文件放置在服务器上的位置,您可能需要更新 css 文件中的图像 URL。
2.更新您的页面以引用 jQuery、MarkdownDeep 库和 MarkdownDeep css 文件(同样,您可能需要更改路径)。
注意:MarkdownDeepLib.min.js 是 MarkdownDeep.js、MarkdownDeepEditor.js 和 MarkdownDeepEditorUI.js 的打包缩小版本。为了进行调试,您可以引用这三个文件。
3.将 Markdown 编辑器插入到您的页面中,如下所示:
注意:关联的 div 都是可选的,如果缺少,插件将创建它们。但是...如果这样做,您可能会在加载过程中遇到页面跳转的情况。即:建议明确包含它们。
4.调用 MarkdownDeep jQuery 插件将文本区域转换为 MarkdownEditor
虽然我真的很喜欢他们的产品我不隶属于 markdowndeep 的制作者。我只是觉得他们做了一个好产品
I know this question is old but I stumbled upon another solution markdowndeep which is very friendly with MVC
It can be installed through nuget PM> Install-Package MarkdownDeep.Full
Markdown in C#
Editor
1.Copy the supplied js, css, png and htm files to your server. Depending where you place these files on your server, you might need to update the image urls in the css file.
2.Update your page to reference jQuery, the MarkdownDeep library and the MarkdownDeep css file (again, you might need to change the paths).
NB: MarkdownDeepLib.min.js is a packaged, minified version of MarkdownDeep.js, MarkdownDeepEditor.js and MarkdownDeepEditorUI.js. For debugging, you can reference these three files instead.
3.Insert the Markdown editor into your page like this:
Note: the associated divs are all optional and if missing, the plugin will create them. However... you might experience the page jumping around during load if you do this. ie: it's recommended to explicitly include them.
4.Called the MarkdownDeep jQuery plugin to convert the textarea to a MarkdownEditor
Although I really like their product I am not affiliated with the makers of markdowndeep. I just thought they made a good product
这个问题已经很老了,但我只是在这里留下一个答案,以便将来的读者可以从中受益。
我已经使用了 MarkdownSharp v1.13,它不会清理你的html 输出。例如,如果您
在输入字段中键入:,MarkdownSharp 的输出将包含相同的脚本。因此,它会使您的网站面临 XSS 漏洞。
请阅读 Stackoverflow 的关于 PageDown 的文章:
因此,从其他角度来看,也许 Markdown 一开始就不应该清理你的输入,而 MarkdownSharp 的实现只是符合这些原则。我应该提到 Stackoverflow 确实在其服务器端使用 MarkdownSharp。
This question is old, but I'm just leaving an answer here so that future readers can benefit from it.
I have used MarkdownSharp v1.13, It does NOT sanitize your html output. For example, if you type:
Into your input field, the output from MarkdownSharp contains the same script. Thus it exposes your website to XSS vulnerability.
Read this from Stackoverflow's article on PageDown:
So, from other point of view, maybe Markdown was not supposed to sanitize your input in the first place and MarkdownSharp implementation of it just conformed with those principles. I should mention that Stackoverflow does uses MarkdownSharp on their server side.