prism highlight your code

prism的颜值很高,支持很多种语言,嗯,反正很多优点呢。

如下:


function prepareGallery() {
    if(!document.getElementByTagsName) return false;
    if(!document.getElementById('myimg')) return false;
    var gallery = document.getElementById('myimg');
    var links = gallery.getElementByTagsName('a');
    for (var i=0; i<links.length;i++) {
        links[i].onclick=function () {
            return showpic(this) ? false :true;
        }
    }
}

使用:


<pre>code class="language-xxx">xxxxxxxxxxxxxxxx</code>/pre>

//使用pre和code标签来包裹需要高亮的代码,class来指明此类代码的类型

.archive-pagination:before,
.clearfix:before,
.entry:before,
.site-inner:before,
.wrap:before {
    content: " ";
    display: table;
}

.archive-pagination:after,
.clearfix:after,
.entry:after,
.site-inner:after,
.wrap:after {
    clear: both;
    content: " ";
    display: table;
}


PRISM官网:http://prismjs.com/