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:
Rafał Pocztarski 2016-07-15 13:08:12 +02:00
parent 2cff85979b
commit 31c77995d5

View File

@ -1095,7 +1095,7 @@ function escape(html, encode) {
function unescape(html) {
// 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();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {