|
|
@ -27,6 +27,7 @@ function assign(obj /*from1, from2, from3, ...*/) { |
|
|
|
return obj; |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
var UNESCAPE_MD_RE = /\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g; |
|
|
|
|
|
|
@ -35,6 +36,8 @@ function unescapeMd(str) { |
|
|
|
return str.replace(UNESCAPE_MD_RE, '$1'); |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
function isValidEntityCode(c) { |
|
|
|
/*eslint no-bitwise:0*/ |
|
|
|
// broken sequence
|
|
|
@ -91,10 +94,34 @@ function replaceEntities(str) { |
|
|
|
return str.replace(NAMED_ENTITY_RE, replaceEntityPattern); |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
var HTML_ESCAPE_TEST_RE = /[&<>"]/; |
|
|
|
var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g; |
|
|
|
var HTML_REPLACEMENTS = { |
|
|
|
'&': '&', |
|
|
|
'<': '<', |
|
|
|
'>': '>', |
|
|
|
'"': '"' |
|
|
|
}; |
|
|
|
|
|
|
|
function replaceUnsafeChar(ch) { |
|
|
|
return HTML_REPLACEMENTS[ch]; |
|
|
|
} |
|
|
|
|
|
|
|
function escapeHtml(str) { |
|
|
|
if (HTML_ESCAPE_TEST_RE.test(str)) { |
|
|
|
return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar); |
|
|
|
} |
|
|
|
return str; |
|
|
|
} |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
exports.assign = assign; |
|
|
|
exports.isString = isString; |
|
|
|
exports.unescapeMd = unescapeMd; |
|
|
|
exports.assign = assign; |
|
|
|
exports.isString = isString; |
|
|
|
exports.unescapeMd = unescapeMd; |
|
|
|
exports.isValidEntityCode = isValidEntityCode; |
|
|
|
exports.fromCodePoint = fromCodePoint; |
|
|
|
exports.replaceEntities = replaceEntities; |
|
|
|
exports.fromCodePoint = fromCodePoint; |
|
|
|
exports.replaceEntities = replaceEntities; |
|
|
|
exports.escapeHtml = escapeHtml; |
|
|
|