MCPcopy
hub / github.com/htmlhint/HTMLHint / parse

Method parse

src/core/htmlparser.ts:52–228  ·  view source on GitHub ↗
(html: string)

Source from the content-addressed store, hash-verified

50 }
51
52 public parse(html: string): void {
53 const mapCdataTags = this._mapCdataTags
54
55 const regTag =
56 // eslint-disable-next-line no-control-regex
57 /<(?:\/([^\s>]+)\s*|!--([\s\S]*?)--|!([^>]*?)|([\w\-:]+)((?:\s+[^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]*))?)*?)\s*(\/?))>/g
58 const regAttr =
59 // eslint-disable-next-line no-control-regex
60 /\s*([^\s"'>\/=\x00-\x0F\x7F\x80-\x9F]+)(?:\s*=\s*(?:(")([^"]*)"|(')([^']*)'|([^\s"'>]*)))?/g
61 const regLine = /\r?\n/g
62
63 let match: RegExpExecArray | null
64 let matchIndex: number
65 let lastIndex = 0
66 let tagName: string
67 let arrAttrs: Attr[]
68 let tagCDATA: string | null = null
69 let attrsCDATA: Attr[] | undefined
70 let arrCDATA: string[] = []
71 let lastCDATAIndex = 0
72 let text: string
73 let lastLineIndex = 0
74 let line = 1
75 const arrBlocks = this._arrBlocks
76
77 this.fire('start', {
78 pos: 0,
79 line: 1,
80 col: 1,
81 })
82
83 // Do not ignore validation inside <script type="ng/template"> template
84 const isMapCdataTagsRequired = () => {
85 const attrType = arrAttrs.find((attr) => attr.name === 'type') || {
86 value: '',
87 }
88
89 return (
90 mapCdataTags[tagName] &&
91 attrType.value.indexOf('text/ng-template') === -1
92 )
93 }
94
95 // Memory block
96 const saveBlock = (
97 type: string,
98 raw: string,
99 pos: number,
100 data?: Partial<Block>
101 ) => {
102 const col = pos - lastLineIndex + 1
103 if (data === undefined) {
104 data = {}
105 }
106 data.raw = raw
107 data.pos = pos
108 data.line = line
109 data.col = col

Callers 8

verifyMethod · 0.95
init.spec.jsFile · 0.80
htmlparser.spec.jsFile · 0.80
sarif.spec.jsFile · 0.80
json.spec.jsFile · 0.80
htmlhint.tsFile · 0.80
getConfigFunction · 0.80
sarifFormatterFunction · 0.80

Calls 1

fireMethod · 0.95

Tested by

no test coverage detected