admin管理员组

文章数量:1313266

I'm using the Highlight.js library for syntax highlighting of code in Blogger and it refuses to highlight Lisp code properly.

In the article on Blogger:

<pre><code class="lisp">
  (coerce (average 1 2 3 4) 'float)
  > 2.5
</code></pre>

In the design template before the closing </head>:

<script src='.0/lisp.min.js' ></script>
<script src='.0/highlight.min.js' ></script>
<link href='.0/styles/github.min.css' rel='stylesheet' />
<script type='text/javascript'>
  hljs.initHighlightingOnLoad();
</script>

Upon opening the article the highlighting is broken, Firebug shows this in the HTML panel:

<pre>
  <code class="lisp ruby"> // WTF
  ... stylized RUBY tokens here ...
  </code>
</pre>

On some code snippets highlighter puts <code class="lisp undefined"> and refuses to highlight at all. As I'm on a Blogger, I really don't want to download anything to anywhere, especially when there is already published language packs. What magic should I do for Lisp to bee recognizable?

I'm using the Highlight.js library for syntax highlighting of code in Blogger and it refuses to highlight Lisp code properly.

In the article on Blogger:

<pre><code class="lisp">
  (coerce (average 1 2 3 4) 'float)
  > 2.5
</code></pre>

In the design template before the closing </head>:

<script src='http://yandex.st/highlightjs/7.0/lisp.min.js' ></script>
<script src='http://yandex.st/highlightjs/7.0/highlight.min.js' ></script>
<link href='http://yandex.st/highlightjs/7.0/styles/github.min.css' rel='stylesheet' />
<script type='text/javascript'>
  hljs.initHighlightingOnLoad();
</script>

Upon opening the article the highlighting is broken, Firebug shows this in the HTML panel:

<pre>
  <code class="lisp ruby"> // WTF
  ... stylized RUBY tokens here ...
  </code>
</pre>

On some code snippets highlighter puts <code class="lisp undefined"> and refuses to highlight at all. As I'm on a Blogger, I really don't want to download anything to anywhere, especially when there is already published language packs. What magic should I do for Lisp to bee recognizable?

Share Improve this question edited Dec 6, 2013 at 21:19 KyleMit 30.4k72 gold badges510 silver badges701 bronze badges asked Jul 2, 2012 at 7:43 hijarianhijarian 2,2281 gold badge29 silver badges35 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

You're using the hosted version which includes a number of definitions for mon languages but Lisp is not among them. See the download page for the full list. In this case the "lisp" word in the class attribute is unknown to highlight.js and it tries to detect the language automatically.

However even if Lisp was included in the package it wouldn't highlight your fragment since it includes output (> 2.5) that is not Lisp and the definition of Lisp in highlight.js doesn't allow for this.

本文标签: javascriptWhy the highlightjs ignores the language classesStack Overflow