|
|
@ -2,8 +2,7 @@ |
|
|
|
|
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var entities = require('../common/entities'); |
|
|
|
var has = require('../common/utils').has; |
|
|
|
var decodeHTML = require('entities').decodeHTML; |
|
|
|
var isValidEntityCode = require('../common/utils').isValidEntityCode; |
|
|
|
var fromCodePoint = require('../common/utils').fromCodePoint; |
|
|
|
|
|
|
@ -13,7 +12,7 @@ var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i; |
|
|
|
|
|
|
|
|
|
|
|
module.exports = function entity(state, silent) { |
|
|
|
var ch, code, match, token, pos = state.pos, max = state.posMax; |
|
|
|
var ch, code, match, decoded, token, pos = state.pos, max = state.posMax; |
|
|
|
|
|
|
|
if (state.src.charCodeAt(pos) !== 0x26/* & */) return false; |
|
|
|
|
|
|
@ -38,10 +37,11 @@ module.exports = function entity(state, silent) { |
|
|
|
} else { |
|
|
|
match = state.src.slice(pos).match(NAMED_RE); |
|
|
|
if (match) { |
|
|
|
if (has(entities, match[1])) { |
|
|
|
decoded = decodeHTML(match[0]); |
|
|
|
if (decoded !== match[0]) { |
|
|
|
if (!silent) { |
|
|
|
token = state.push('text_special', '', 0); |
|
|
|
token.content = entities[match[1]]; |
|
|
|
token.content = decoded; |
|
|
|
token.markup = match[0]; |
|
|
|
token.info = 'entity'; |
|
|
|
} |
|
|
|