htmlhint / HTMLHint

⚙️ The static code analysis tool you need for your HTML
https://htmlhint.com
MIT License
3.08k stars 383 forks source link

Access content between 2 a start tagf and an end tag #1443

Open lavanyaburlagadda1807 opened 3 months ago

lavanyaburlagadda1807 commented 3 months ago

I have some HTML code in that between style tag I will write some styles with classes. When added event listener with text it is not selecting the text

To Reproduce

 parser.addListener('tagstart', function (event) {
            if (event.tagName.toLowerCase() === 'style') {
               insideStyleTag = true
            }
         })

         parser.addListener('tagend', function (event) {
            if (event.tagName.toLowerCase() === 'style') {
               insideStyleTag = false
            }
         })

         parser.addListener('text', function (event) {
            if (insideStyleTag) {
               console.log('event', event)
               const cssText = event.raw
               const cssClassRegex = /\.([\w-]+)/g
               let match
               while ((match = cssClassRegex.exec(cssText)) !== null) {
                  classNames.add(match[1])
               }
            }
         })

I am expecting the content to be available at text listener