|
|
@ -91,6 +91,23 @@ function escapeHtml(str) { |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
function escapeHtmlKeepEntities(str) { |
|
|
|
if (str.indexOf('&') >= 0) { |
|
|
|
str = str.replace(/[&](?![#](x[a-f0-9]{1,8}|[0-9]{1,8});|[a-z][a-z0-9]{1,31};)/gi,'&'); |
|
|
|
} |
|
|
|
if (str.indexOf('<') >= 0) { str = str.replace(/</g, '<'); } |
|
|
|
if (str.indexOf('>') >= 0) { str = str.replace(/>/g, '>'); } |
|
|
|
if (str.indexOf('"') >= 0) { str = str.replace(/"/g, '"'); } |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
var UNESCAPE_MD_RE = /\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g; |
|
|
|
|
|
|
|
function unescapeMd(str) { |
|
|
|
if (str.indexOf('\\') < 0) { return str; } |
|
|
|
return str.replace(UNESCAPE_MD_RE, '$1'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
exports.isWhiteSpace = isWhiteSpace; |
|
|
|
exports.isEmpty = isEmpty; |
|
|
@ -100,3 +117,5 @@ exports.skipChars = skipChars; |
|
|
|
exports.getLines = getLines; |
|
|
|
exports.skipCharsBack = skipCharsBack; |
|
|
|
exports.escapeHtml = escapeHtml; |
|
|
|
exports.unescapeMd = unescapeMd; |
|
|
|
exports.escapeHtmlKeepEntities = escapeHtmlKeepEntities; |
|
|
|