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