Skip to content

parsing fails for scripts w/ html strings #36

Closed
@jonathanong

Description

@jonathanong
<!DOCTYPE html>
<html>
  <head></head><body><script>
      var a = {
        text: '<script src="asdf"></script>'
      };
  </script></body>
</html>
var parse5 = require('parse5');
var fs = require('fs');

var html = fs.readFileSync('index.html', 'utf8');

var parser = new parse5.Parser();

var document = parser.parse(html);
var html = document.childNodes[1];
var body = html.childNodes[html.childNodes.length - 1];
var script = body.childNodes[0];
var text = script.childNodes[0];
console.log(text.value);
// => '\n      var a = {\n        text: \'<script src="asdf">'

it's parsing the </script> inside the <script> as HTML, messing up the document =/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions