Reputation: 23
I'm building a Seaside application and I'm searching for a way to highlight some code snippets on the browser with JS. I found highlight.js which support Smalltalk syntax but it doesn't work. I add this script and hljs.initHighlightingOnLoad(); in the header but it doesn't work.
Probably I miss something but what?
Upvotes: 1
Views: 255
Reputation: 13396
I use highlight.js from CDN:
<link href='http://yandex.st/highlightjs/8.0/styles/sunburst.min.css' rel='stylesheet'/>
<script src='http://yandex.st/highlightjs/8.0/highlight.min.js' type='text/javascript'/>
I also define a format function like:
function format(){
var b=document.getElementsByTagName("pre");
for (i=0;i<b.length;i++) {
hljs.tabReplace = ' '; // 2 spaces
b[i].style.fontSize = '0.9em';
hljs.highlightBlock(b[i],' ',false);
}
}
and use
<pre class="smalltalk"><code>……</code></pre>
for highlightable block. Then I call format()
when the page is loaded (or a dynamic content with code is loaded into page)
Upvotes: 3