Created
January 25, 2013 02:22
-
-
Save somian/4631182 to your computer and use it in GitHub Desktop.
My changes to Perlmonk tobyink's jQuery js code: using CodeMirror to syntax-highlight code posted on Perlmonks. node_id=1007668
This code is part of what is intended to be included by folks (logged-in, registered Monks) in their Free Nodelet Settings HTML. See the writeup for the original author's instructions. {{ req. knowledge level: HIGH }}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('p.code').each(function (i, c) { | |
var $code = $(c).find('tt.codetext').text().replace(/\u00a0/g,' '); | |
var $dclink = $(c).find('span.embed-code-dl'); | |
var $pre = $( | |
'<textarea class="CodeMirror">' | |
+ $('<div/>').text($code).html().replace(/\s+$/,'') | |
+ '</textarea>' | |
); | |
if ($dclink.html()) $(c).after( | |
'<div class="snippet-view-link" style="text-align:right">' | |
+ '<span class="embed-code-dl">' + $dclink.html() + '</span></div>' | |
); | |
$(c).replaceWith($pre); | |
CodeMirror.fromTextArea($pre.get(0), { | |
lineNumbers: true, | |
readOnly: true, | |
matchBrackets: true, | |
lineWrapping: true | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment