Lint and format src/compiler/parse/utils/html.js

pull/8569/head
Simon Holthausen 3 years ago
parent 2c471b88a2
commit 2c541f66c1

@ -22,7 +22,9 @@ function reg_exp_entity(entity_name, is_attribute_value) {
*/ */
function get_entity_pattern(is_attribute_value) { function get_entity_pattern(is_attribute_value) {
const reg_exp_num = '#(?:x[a-fA-F\\d]+|\\d+)(?:;)?'; const reg_exp_num = '#(?:x[a-fA-F\\d]+|\\d+)(?:;)?';
const reg_exp_entities = Object.keys(entities).map((entity_name) => reg_exp_entity(entity_name, is_attribute_value)); const reg_exp_entities = Object.keys(entities).map((entity_name) =>
reg_exp_entity(entity_name, is_attribute_value)
);
const entity_pattern = new RegExp(`&(${reg_exp_num}|${reg_exp_entities.join('|')})`, 'g'); const entity_pattern = new RegExp(`&(${reg_exp_num}|${reg_exp_entities.join('|')})`, 'g');
return entity_pattern; return entity_pattern;
} }
@ -40,11 +42,9 @@ export function decode_character_references(html, is_attribute_value) {
// Handle named entities // Handle named entities
if (entity[0] !== '#') { if (entity[0] !== '#') {
code = entities[entity]; code = entities[entity];
} } else if (entity[1] === 'x') {
else if (entity[1] === 'x') {
code = parseInt(entity.substring(2), 16); code = parseInt(entity.substring(2), 16);
} } else {
else {
code = parseInt(entity.substring(1), 10); code = parseInt(entity.substring(1), 10);
} }
if (!code) { if (!code) {
@ -106,7 +106,11 @@ const disallowed_contents = new Map([
['dd', new Set(['dt', 'dd'])], ['dd', new Set(['dt', 'dd'])],
[ [
'p', 'p',
new Set('address article aside blockquote div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr main menu nav ol p pre section table ul'.split(' ')) new Set(
'address article aside blockquote div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr main menu nav ol p pre section table ul'.split(
' '
)
)
], ],
['rt', new Set(['rt', 'rp'])], ['rt', new Set(['rt', 'rp'])],
['rp', new Set(['rt', 'rp'])], ['rp', new Set(['rt', 'rp'])],
@ -134,7 +138,3 @@ export function closing_tag_omitted(current, next) {
} }
return false; return false;
} }

Loading…
Cancel
Save