Fixes #99. We have added the hogan method for escaping user input and added a tutorial

This commit is contained in:
cktricky
2014-04-17 12:51:02 -04:00
parent 8cb6ff36ac
commit 8e4e084dc9
3 changed files with 158 additions and 0 deletions
+28
View File
@@ -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, '&amp;')
.replace(rLt, '&lt;')
.replace(rGt, '&gt;')
.replace(rApos, '&#39;')
.replace(rQuot, '&quot;') :
str;
}
$(document).ready(function(){
rubyCodeFormat()
});