in reply to PerlMonks meets Twitter Bootstrap

There is a typo in pm2.js for the syntax highlighting
$('pre.blockcode code').each(function(i, block) { hljs.highlightBlock(block); });

Perlmoks produces these tags

<pre class="code"> <div class="codeblock"> <tt class="codetext">

So I would select on tt.codetext (i've tested seems to work)

javascript:(function () { $('tt.codetext').each(function(i, block) { hljs.highlightBlock(block); + }); }());

There is also  tt.inlinecode for no-newlines ... see Help for Display Settings

Replies are listed 'Best First'.
Re^2: PerlMonks meets Twitter Bootstrap
by tobyink (Canon) on Sep 04, 2014 at 08:54 UTC

    That selector actually matches up with a bit of Javascript just above it:

    $('p.code').each(function (i, c) { var code = $(c).find('tt.codetext').text().replace(/\u00a0/g,' '). +replace(/\s+$/,''); var dl = $(c).find('span.embed-code-dl'); var pre = $( '<pre class="blockcode"><code>' + $('<div/>').text(code).html() + '</code></pre>' ); var footer = $('<div style="text-align:right"><small></small></div +>'); if (dl.html()) footer.find('small').append(dl.html()); $(c).after(footer); $(c).replaceWith(pre); });

    The intention of that is to rewrite PerlMonks' code-block markup into a much simpler <pre class="blockcode"><code>...</code></pre>, which the syntax highlighter can then deal with.

    However PerlMonks' code-block markup does vary depending on your display settings for code listings. My settings are:

    Code Wrapping Off [ ] Code Wrap Length [ ] Auto Code Wrapping [ Yes ] Code Prefix [ ] Large Code Font [ ] Don't show embedded d/l links [ ] Show download link on code N lines long or more: [ 4 ]

    If you let me know your settings I can try to make sure pm2.js works better with them.

      If you let me know your settings I can try to make sure pm2.js works better with them.

      Logged out view, I'm Anonymous Monk :) I saw no highlighting before this tweak