html.js — svelte Source File
Architecture documentation for html.js, a javascript file in the svelte codebase. 1 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 06660fad_daa2_c824_01c8_ebafc63758a1["html.js"] 14e69600_d893_9395_036e_00d48caa6ebb["entities.js"] 06660fad_daa2_c824_01c8_ebafc63758a1 --> 14e69600_d893_9395_036e_00d48caa6ebb 206889ff_1f9f_b6c1_d530_059d001e1cf4["element.js"] 206889ff_1f9f_b6c1_d530_059d001e1cf4 --> 06660fad_daa2_c824_01c8_ebafc63758a1 6b133d64_dd9e_dc63_5b9b_73e9e80bc0dd["text.js"] 6b133d64_dd9e_dc63_5b9b_73e9e80bc0dd --> 06660fad_daa2_c824_01c8_ebafc63758a1 style 06660fad_daa2_c824_01c8_ebafc63758a1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import entities from './entities.js';
const windows_1252 = [
8364, 129, 8218, 402, 8222, 8230, 8224, 8225, 710, 8240, 352, 8249, 338, 141, 381, 143, 144, 8216,
8217, 8220, 8221, 8226, 8211, 8212, 732, 8482, 353, 8250, 339, 157, 382, 376
];
/**
* @param {string} entity_name
* @param {boolean} is_attribute_value
*/
function reg_exp_entity(entity_name, is_attribute_value) {
// https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
// doesn't decode the html entity which not ends with ; and next character is =, number or alphabet in attribute value.
if (is_attribute_value && !entity_name.endsWith(';')) {
return `${entity_name}\\b(?!=)`;
}
return entity_name;
}
/** @param {boolean} is_attribute_value */
function get_entity_pattern(is_attribute_value) {
const reg_exp_num = '#(?:x[a-fA-F\\d]+|\\d+)(?:;)?';
const reg_exp_entities = Object.keys(entities).map(
/** @param {any} entity_name */ (entity_name) => reg_exp_entity(entity_name, is_attribute_value)
);
const entity_pattern = new RegExp(`&(${reg_exp_num}|${reg_exp_entities.join('|')})`, 'g');
return entity_pattern;
}
const entity_pattern_content = get_entity_pattern(false);
const entity_pattern_attr_value = get_entity_pattern(true);
/**
* @param {string} html
* @param {boolean} is_attribute_value
*/
export function decode_character_references(html, is_attribute_value) {
const entity_pattern = is_attribute_value ? entity_pattern_attr_value : entity_pattern_content;
return html.replace(
entity_pattern,
/**
* @param {any} match
* @param {keyof typeof entities} entity
*/ (match, entity) => {
let code;
// Handle named entities
if (entity[0] !== '#') {
code = entities[entity];
} else if (entity[1] === 'x') {
code = parseInt(entity.substring(2), 16);
} else {
code = parseInt(entity.substring(1), 10);
}
if (!code) {
return match;
// ... (68 more lines)
Domain
Subdomains
Dependencies
Imported By
Source
Frequently Asked Questions
What does html.js do?
html.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in html.js?
html.js defines 4 function(s): decode_character_references, get_entity_pattern, reg_exp_entity, validate_code.
What does html.js depend on?
html.js imports 1 module(s): entities.js.
What files import html.js?
html.js is imported by 2 file(s): element.js, text.js.
Where is html.js in the architecture?
html.js is located at packages/svelte/src/compiler/phases/1-parse/utils/html.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/1-parse/utils).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free