我在Stack Overflow上使用the same JavaScript Markdown。我的问题是:
我有一个文本字段:
<textarea id="markdown" class="markdown"></textarea>在keyup上,我执行以下事件和逻辑:
var converter = new Markdown.Converter();
$('textarea#markdown').keyup(function() {
if($(this).val().length >= 1) {
var html = $(this).val().replace(/<script(.*?)>(.*?)<\/script>/gi, '');
$('div#markdown_preview').html( converter.makeHtml( html ) );
} else {
$('div#markdown_preview').html('Your Markdown will be previewed in here...');
}
});正如您所看到的,在我的正则表达式中,我剥离了所有的<script>语句,因此类似于:
<code> <script></script> </code> 也不会起作用。我如何才能让它工作,就像在Stack Overflow上一样?
发布于 2013-03-09 03:06:25
使用Kramdown,您也许可以使用
{::comment}
This text is completely ignored by kramdown - a comment in the text.
{:/comment}https://stackoverflow.com/questions/15299805
复制相似问题