-
I would like to use highlight.js for my RDoc rendering. Problem is RDoc doesn't provide <pre><code>...</pre></code>, instead it only does <pre>...</pre>. How can I use highlight.js in this case?
-
FYI, I used jQuery to add a code bracket:
$('pre').wrapInner('<code></code>');
While it would be nice it highlight.js could allow you to specify the css selector to apply to, my hack worked well enough. -
You can also patch highlight.js, like I did.
It's a one line change.=== modified file 'src/highlight.js'
--- src/highlight.js 2009-08-26 13:27:24 +0000
+++ src/highlight.js 2009-12-04 19:35:48 +0000
@@ -497,7 +497,8 @@
selected_languages = LANGUAGES;
var pres = document.getElementsByTagName('pre');
for (var i = 0; i < pres.length; i++) {
- var code = findCode(pres[i]);
+ // var code = findCode(pres[i]);
+ var code = pres[i];
if (code)
highlightBlock(code, hljs.tabReplace);
} -
This is actually intentional. HTML5 defines blocks of code to be marked up as
<pre><code>..</code></pre>, it makes sense and I want to be a part of the ecosystem that does everything consistently. All other variations generated by current software (<div class="pre">,<pre class="code">etc.) should be eventually replaced with the variant that everyone agrees with.
Внимание! Это довольно старый топик, посты в него не попадут в новые, и их никто не увидит. Пишите пост, если хотите просто дополнить топик, а чтобы задать новый вопрос — начните новый.

