1. T. Sawyer

    07.10.2009

    0 ↑
    0 ↓
    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?
  2. T. Sawyer

    07.10.2009

    0 ↑
    0 ↓
    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.
  3. Anonymous

    05.12.2009

    0 ↑
    0 ↓
    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);
    }
  4. Иван Сагалаев

    05.12.2009

    0 ↑
    0 ↓

    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.

Внимание! Это довольно старый топик, посты в него не попадут в новые, и их никто не увидит. Пишите пост, если хотите просто дополнить топик, а чтобы задать новый вопрос — начните новый.