@markuplint/html-parser
Advanced tools
Comparing version 4.0.0-alpha.4 to 4.0.0-alpha.5
// @ts-nocheck TODO: Parse5(https://github.com/inikulin/parse5) supports to expose type definitions as submodules. | ||
import { detectElementType, getEndCol, getEndLine, sliceFragment, uuid } from '@markuplint/parser-utils'; | ||
import { detectElementType, getEndCol, getEndLine, sliceFragment, tagParser, uuid } from '@markuplint/parser-utils'; | ||
import { parse, parseFragment } from 'parse5'; | ||
import parseRawTag from './parse-raw-tag.js'; | ||
const P5_OPTIONS = { | ||
@@ -150,3 +149,3 @@ scriptingEnabled: false, | ||
: rawHtml.slice(startOffset, endOffset ?? startOffset); | ||
const tagTokens = parseRawTag(startTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn); | ||
const tagTokens = tagParser(startTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn); | ||
const tagName = tagTokens.tagName; | ||
@@ -172,3 +171,3 @@ let endTag = null; | ||
const endTagRaw = rawHtml.slice(startOffset, endOffset); | ||
const endTagTokens = parseRawTag(endTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn); | ||
const endTagTokens = tagParser(endTagRaw, startLine, startCol, startOffset, offsetOffset, offsetLine, offsetColumn); | ||
const endTagName = endTagTokens.tagName; | ||
@@ -175,0 +174,0 @@ endTag = { |
@@ -1,6 +0,4 @@ | ||
export { default as attrTokenizer } from './attr-tokenizer.js'; | ||
export { default as isDocumentFragment } from './is-document-fragment.js'; | ||
export { default as parseRawTag } from './parse-raw-tag.js'; | ||
export { isDocumentFragment } from './is-document-fragment.js'; | ||
export { getNamespace } from './get-namespace.js'; | ||
export { parse } from './parse.js'; | ||
export { createTree } from './create-tree.js'; |
@@ -1,6 +0,4 @@ | ||
export { default as attrTokenizer } from './attr-tokenizer.js'; | ||
export { default as isDocumentFragment } from './is-document-fragment.js'; | ||
export { default as parseRawTag } from './parse-raw-tag.js'; | ||
export { isDocumentFragment } from './is-document-fragment.js'; | ||
export { getNamespace } from './get-namespace.js'; | ||
export { parse } from './parse.js'; | ||
export { createTree } from './create-tree.js'; |
@@ -1,1 +0,1 @@ | ||
export default function isDocumentFragment(html: string): boolean; | ||
export declare function isDocumentFragment(html: string): boolean; |
@@ -1,3 +0,3 @@ | ||
export default function isDocumentFragment(html) { | ||
return !/^\s*(<!doctype html(?:\s*.+)?>|<html[\s>])/im.test(html); | ||
export function isDocumentFragment(html) { | ||
return !/^\s*(?:<!doctype html(?:\s*(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))?>|<html[\s>])/im.test(html); | ||
} |
@@ -8,5 +8,3 @@ const UNDUPLICATED_CHAR = '\uFFFD'; | ||
const bodies = []; | ||
const code = rawCode.replaceAll( | ||
// eslint-disable-next-line no-control-regex | ||
/(?<=<\/?)(?:head|body)(?=\u0009|\u000A|\u000C| |\/|>|\u0000)/gi, tag => { | ||
const code = rawCode.replaceAll(/(?<=<\/?)(?:head|body)(?=[\0\t\n\f />])/gi, tag => { | ||
const prefix = `x-${UNDUPLICATED_CHAR}`; | ||
@@ -13,0 +11,0 @@ let name; |
import { ignoreFrontMatter, flattenNodes } from '@markuplint/parser-utils'; | ||
import { createTree } from './create-tree.js'; | ||
import isDocumentFragment from './is-document-fragment.js'; | ||
import { isDocumentFragment } from './is-document-fragment.js'; | ||
import { isStartsHeadTagOrBodyTag, optimizeStartsHeadTagOrBodyTagResume, optimizeStartsHeadTagOrBodyTagSetup, } from './optimize-starts-head-or-body.js'; | ||
@@ -5,0 +5,0 @@ export const parse = (rawCode, options) => { |
{ | ||
"name": "@markuplint/html-parser", | ||
"version": "4.0.0-alpha.4", | ||
"version": "4.0.0-alpha.5", | ||
"description": "HTML parser for markuplint", | ||
@@ -28,8 +28,8 @@ "repository": "git@github.com:markuplint/markuplint.git", | ||
"dependencies": { | ||
"@markuplint/ml-ast": "4.0.0-alpha.4", | ||
"@markuplint/parser-utils": "4.0.0-alpha.4", | ||
"@markuplint/ml-ast": "4.0.0-alpha.5", | ||
"@markuplint/parser-utils": "4.0.0-alpha.5", | ||
"parse5": "7.1.2", | ||
"type-fest": "^4.5.0" | ||
}, | ||
"gitHead": "991b3aef77fde42c79343ee8c807257a35c589d7" | ||
"gitHead": "0c3e4690662edf1765bcc4b6411ec5507c1e2ea3" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17952
15
383
+ Added@markuplint/ml-ast@4.0.0-alpha.5(transitive)
+ Added@markuplint/parser-utils@4.0.0-alpha.5(transitive)
+ Added@markuplint/types@4.0.0-alpha.5(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedespree@9.6.1(transitive)
- Removed@markuplint/ml-ast@4.0.0-alpha.4(transitive)
- Removed@markuplint/parser-utils@4.0.0-alpha.4(transitive)
- Removed@markuplint/types@4.0.0-alpha.4(transitive)