Skip to content

Instantly share code, notes, and snippets.

@Deathspike
Created June 21, 2013 15:49
Show Gist options
  • Select an option

  • Save Deathspike/5832139 to your computer and use it in GitHub Desktop.

Select an option

Save Deathspike/5832139 to your computer and use it in GitHub Desktop.
js parsed html tree after consuming lexer tokens
[
{
"data": "<!DOCTYPE html>",
"index": 0,
"type": "doctype",
"indent": 0
},
{
"data": "\r\n",
"index": 15,
"type": "whitespace",
"indent": 0
},
{
"data": "<html>",
"index": 17,
"type": "element",
"name": "html",
"isBeginning": true,
"attributes": [],
"isStandalone": false,
"association": 32,
"indent": 0,
"children": [
{
"data": "\r\n\t",
"index": 23,
"type": "whitespace",
"indent": 1
},
{
"data": "<head>",
"index": 26,
"type": "element",
"name": "head",
"isBeginning": true,
"attributes": [],
"isStandalone": false,
"association": 10,
"indent": 1,
"children": [
{
"data": "\r\n\t\t",
"index": 32,
"type": "whitespace",
"indent": 2
},
{
"data": "<title>",
"index": 36,
"type": "element",
"name": "title",
"isBeginning": true,
"attributes": [],
"isStandalone": false,
"association": 8,
"indent": 2,
"children": [
{
"data": "Something <! with an invalid token",
"index": 43,
"type": "text",
"indent": 3
}
]
},
{
"data": "</title>",
"index": 77,
"type": "element",
"name": "title",
"isBeginning": false,
"association": 6,
"indent": 2
},
{
"data": "\r\n\t",
"index": 85,
"type": "whitespace",
"indent": 2
}
]
},
{
"data": "</head>",
"index": 88,
"type": "element",
"name": "head",
"isBeginning": false,
"association": 4,
"indent": 1
},
{
"data": "\r\n\t",
"index": 95,
"type": "whitespace",
"indent": 1
},
{
"data": "<body>",
"index": 98,
"type": "element",
"name": "body",
"isBeginning": true,
"attributes": [],
"isStandalone": false,
"association": 30,
"indent": 1,
"children": [
{
"data": "\r\n\t\t",
"index": 104,
"type": "whitespace",
"indent": 2
},
{
"data": "<a href=\"invalid\">",
"index": 108,
"type": "element",
"name": "a",
"isBeginning": true,
"attributes": [
{
"key": "href",
"value": "invalid",
"quote": "\""
}
],
"isStandalone": false,
"indent": 2
},
{
"data": "\r\n\t\t\t",
"index": 126,
"type": "whitespace",
"indent": 2
},
{
"data": "<a href=\"correct\">",
"index": 131,
"type": "element",
"name": "a",
"isBeginning": true,
"attributes": [
{
"key": "href",
"value": "correct",
"quote": "\""
}
],
"isStandalone": false,
"association": 18,
"indent": 2,
"children": [
{
"data": "bullshit here >_<\r\n\t\t",
"index": 149,
"type": "text",
"indent": 3
}
]
},
{
"data": "</a>",
"index": 170,
"type": "element",
"name": "a",
"isBeginning": false,
"association": 16,
"indent": 2
},
{
"data": "\r\n\t\t",
"index": 174,
"type": "whitespace",
"indent": 2
},
{
"data": "<!-- asdasd > asdasd > -->",
"index": 178,
"type": "comment",
"indent": 2
},
{
"data": "\r\n\t\t",
"index": 204,
"type": "whitespace",
"indent": 2
},
{
"data": "<script type=\"text/javascript\" data-bind=\"a'mazing\">",
"index": 208,
"type": "text",
"indent": 2
},
{
"data": "\r\n\t\t\t",
"index": 260,
"type": "whitespace",
"indent": 2
},
{
"data": "<div>",
"index": 265,
"type": "text",
"indent": 2
},
{
"data": "\r\n\t\t\t\tThis is totally text.\r\n\t\t\t",
"index": 270,
"type": "text",
"indent": 2
},
{
"data": "</div>",
"index": 302,
"type": "text",
"indent": 2
},
{
"data": "\r\n\t\t",
"index": 308,
"type": "whitespace",
"indent": 2
},
{
"data": "</script>",
"index": 312,
"type": "element",
"name": "script",
"isBeginning": false,
"indent": 2
},
{
"data": "\r\n\t",
"index": 321,
"type": "whitespace",
"indent": 2
}
]
},
{
"data": "</body>",
"index": 324,
"type": "element",
"name": "body",
"isBeginning": false,
"association": 12,
"indent": 1
},
{
"data": "\r\n",
"index": 331,
"type": "whitespace",
"indent": 1
}
]
},
{
"data": "</html>",
"index": 333,
"type": "element",
"name": "html",
"isBeginning": false,
"association": 2,
"indent": 0
},
{
"data": "\r\n",
"index": 340,
"type": "whitespace",
"indent": 0
},
{
"data": "<notanopening />",
"index": 342,
"type": "element",
"name": "notanopening",
"isBeginning": true,
"attributes": [],
"isStandalone": true,
"indent": 0
},
{
"data": "\r\n",
"index": 358,
"type": "whitespace",
"indent": 0
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment