【问题标题】:I'm using nodejs express to build a blog, and this blog can write by markdown, how to add code highlihgter to it?我在用nodejs express建一个博客,这个博客可以用markdown写,怎么加代码highlihgter呢?
【发布时间】:2013-05-05 14:33:32
【问题描述】:

我正在使用nodejs express搭建一个可以用markdown写的博客,如何添加代码高亮?

我尝试使用 syntaxhighlighter.js 来完成它,但它无法工作。 因为它需要这样写“<pre class="bruse:css">code here..</pre>. 但是marked.js 输出像这样“<pre><code>code here...</code></pre>”。

那么有人知道如何实现吗?

【问题讨论】:

    标签: express markdown syntaxhighlighter


    【解决方案1】:

    查看 Codemirror 的 Markdown 模式 http://codemirror.net/mode/markdown/ 喜欢:

    $('pre code').each(function() {
    
    var $this = $(this),
        $code = $this.html();
    
    $this.empty();
    
    var myCodeMirror = CodeMirror(this, {
        value: $code,
        mode: 'markdown',
        readOnly: true
    });
    
    });
    

    【讨论】:

    • 我没有找到代码语法部分,也不知道你想给我看什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 2020-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-10
    相关资源
    最近更新 更多