summaryrefslogtreecommitdiff
path: root/src/parser/utils/names.ts
diff options
context:
space:
mode:
authorGravatar Drew Powers <1369770+drwpow@users.noreply.github.com> 2021-04-01 10:25:28 -0600
committerGravatar GitHub <noreply@github.com> 2021-04-01 10:25:28 -0600
commitc26c244ca2634d462616d6cf71072fbe26becba2 (patch)
tree1bd5e83eff9ca88200aacb272c84439f192015ec /src/parser/utils/names.ts
parentf6a7ac67befff863e34133673efb78ea7ac0fe48 (diff)
downloadastro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.gz
astro-c26c244ca2634d462616d6cf71072fbe26becba2.tar.zst
astro-c26c244ca2634d462616d6cf71072fbe26becba2.zip
Annoying Lint PR #2 (#47)
Diffstat (limited to '')
-rw-r--r--src/parser/utils/names.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/parser/utils/names.ts b/src/parser/utils/names.ts
index f2e1dfc8e..f041d20ce 100644
--- a/src/parser/utils/names.ts
+++ b/src/parser/utils/names.ts
@@ -113,10 +113,12 @@ export const reserved = new Set([
const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
+/** Is this a void HTML element? */
export function is_void(name: string) {
return void_element_names.test(name) || name.toLowerCase() === '!doctype';
}
+/** Is this a valid HTML element? */
export function is_valid(str: string): boolean {
let i = 0;
@@ -130,6 +132,7 @@ export function is_valid(str: string): boolean {
return true;
}
+/** Utility to normalize HTML */
export function sanitize(name: string) {
return name
.replace(/[^a-zA-Z0-9_]+/g, '_')