add optional semicolon in html entities regex
and make non-capturing group out of (\w+) that was not used in the function (only the entire surrounding group is used as a whole) The semicolon is outside of the capturing group so the input to the function is the same as before. See this comment: https://github.com/chjj/marked/pull/592/files/2cff859#r70888592
This commit is contained in:
parent
2cff85979b
commit
31c77995d5
@ -1095,7 +1095,7 @@ function escape(html, encode) {
|
|||||||
|
|
||||||
function unescape(html) {
|
function unescape(html) {
|
||||||
// explicitly match decimal, hex, and named HTML entities
|
// explicitly match decimal, hex, and named HTML entities
|
||||||
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(\w+))/g, function(_, n) {
|
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
|
||||||
n = n.toLowerCase();
|
n = n.toLowerCase();
|
||||||
if (n === 'colon') return ':';
|
if (n === 'colon') return ':';
|
||||||
if (n.charAt(0) === '#') {
|
if (n.charAt(0) === '#') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user