Fixes #99. We have added the hogan method for escaping user input and added a tutorial
This commit is contained in:
@@ -40,8 +40,36 @@ $("pre.ruby").snippet("ruby",{style:"rand01",transparent:true,showNum:true});
|
||||
// with a transparent background
|
||||
// without showing line numbers.
|
||||
|
||||
|
||||
|
||||
$("pre.javascript").snippet("javascript",{style:"rand01",transparent:true,showNum:true});
|
||||
// Finds <pre> elements with the class "js"
|
||||
// and snippet highlights the JAVASCRIPT code within
|
||||
// using a random style from the selection of 39
|
||||
// with a transparent background
|
||||
// without showing line numbers.
|
||||
|
||||
};
|
||||
|
||||
var rAmp = /&/g,
|
||||
rLt = /</g,
|
||||
rGt = />/g,
|
||||
rApos = /\'/g,
|
||||
rQuot = /\"/g,
|
||||
hChars = /[&<>\"\']/;
|
||||
|
||||
function hoganEscape(str) {
|
||||
str = coerceToString(str);
|
||||
return hChars.test(str) ?
|
||||
str
|
||||
.replace(rAmp, '&')
|
||||
.replace(rLt, '<')
|
||||
.replace(rGt, '>')
|
||||
.replace(rApos, ''')
|
||||
.replace(rQuot, '"') :
|
||||
str;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
rubyCodeFormat()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user