Since it's going in the tipsy title, it actually ends up needing to be double escaped. I wrote a could functions to handle that dynamically: // escape all the characters in a string that need to be escaped for Regular Expressions
esRE = function (s) {
var escapeForRegexp = /(\\|\/|\[|\]|\(|\)|\{|\}|\?|\+|\*|\||\.|\^|\$)/g;
return s.replace(escapeForRegexp,"\\$1");
},
HE = (function(){
var entities={
//' ' : '&'+'nbsp'+';',
'<' : '&'+'lt'+';',
'>' : '&'+'gt'+';',
"'" : '&'+'#39'+';',
'@' : '&'+'#64'+';',
'{' : '&'+'#123'+';',
'|' : '&'+'#124'+';',
'}' : '&'+'#125'+';',
'[' : '&'+'#91'+';',
']' : '&'+'#93'+';',
'&' : '&'+'amp'+';',
'"' : '&'+'quot'+';',
'-' : '&'+'mdash'+';'
},
re=new RegExp('('+_.map(_.keys(entities),esRE).join('|')+')','g');
return function(s){
return s.replace(re, function(c){ return entities[c] || c; });
};
}()),
HE2 = _.compose(HE,HE); I put these both in buildInline, and wrapped both instances of inlineroll.expression with HE2() calls to double escape them. EDIT: This is now fixed in the mainline.