{"action":"created","issue":{"url":"https://api.github.com/repos/Lullabot/amp-library/issues/68","repository_url":"https://api.github.com/repos/Lullabot/amp-library","labels_url":"https://api.github.com/repos/Lullabot/amp-library/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/Lullabot/amp-library/issues/68/comments","events_url":"https://api.github.com/repos/Lullabot/amp-library/issues/68/events","html_url":"https://github.com/Lullabot/amp-library/issues/68","id":156469817,"number":68,"title":"Provide better HTML5 support and add workaround for line numbers","user":{"login":"sidkshatriya","id":638477,"avatar_url":"https://avatars.githubusercontent.com/u/638477?v=3","gravatar_id":"","url":"https://api.github.com/users/sidkshatriya","html_url":"https://github.com/sidkshatriya","followers_url":"https://api.github.com/users/sidkshatriya/followers","following_url":"https://api.github.com/users/sidkshatriya/following{/other_user}","gists_url":"https://api.github.com/users/sidkshatriya/gists{/gist_id}","starred_url":"https://api.github.com/users/sidkshatriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidkshatriya/subscriptions","organizations_url":"https://api.github.com/users/sidkshatriya/orgs","repos_url":"https://api.github.com/users/sidkshatriya/repos","events_url":"https://api.github.com/users/sidkshatriya/events{/privacy}","received_events_url":"https://api.github.com/users/sidkshatriya/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Lullabot/amp-library/labels/Phase%202","name":"Phase 2","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"sidkshatriya","id":638477,"avatar_url":"https://avatars.githubusercontent.com/u/638477?v=3","gravatar_id":"","url":"https://api.github.com/users/sidkshatriya","html_url":"https://github.com/sidkshatriya","followers_url":"https://api.github.com/users/sidkshatriya/followers","following_url":"https://api.github.com/users/sidkshatriya/following{/other_user}","gists_url":"https://api.github.com/users/sidkshatriya/gists{/gist_id}","starred_url":"https://api.github.com/users/sidkshatriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidkshatriya/subscriptions","organizations_url":"https://api.github.com/users/sidkshatriya/orgs","repos_url":"https://api.github.com/users/sidkshatriya/repos","events_url":"https://api.github.com/users/sidkshatriya/events{/privacy}","received_events_url":"https://api.github.com/users/sidkshatriya/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-05-24T10:10:47Z","updated_at":"2016-05-24T11:17:49Z","closed_at":null,"body":"While working on #62 I encountered problems related to the AMP library's support for HTML5. The main issue is that we're using the inbuilt HTML parser of PHP DOM (i.e. the libxml 2.9.0 html parser).\r\n\r\nThe following does not parse properly for instance:\r\n\r\n```html\r\n<audio controls autoplay>\r\n    <p>Your browser does not support the <strong>audio</strong> tag</p>\r\n    <source src=\"abc.wav\" type=\"audio/wav\">\r\n    <source src=\"xyz.mp3\" type=\"audio/mpeg\">\r\n</audio>\r\n```\r\n(The above HTML actually parses without any fatal errors but the parse tree is not correct).\r\n\r\nThis HTML needs to be changed to:\r\n\r\n```html\r\n<audio controls autoplay>\r\n    <p>Your browser does not support the <strong>audio</strong> tag</p>\r\n    <source src=\"abc.wav\" type=\"audio/wav\" />\r\n    <source src=\"xyz.mp3\" type=\"audio/mpeg\" />\r\n</audio>\r\n```\r\n\r\nNotice that `<source>` was changed to `<source />` so that the PHP dom parser knows that the tag has ended.\r\n\r\n**We can't expect users to do this while entering HTML**. Users should be able to provide valid HTML5 in additional to traditional HTML.\r\n\r\nThe solution is to _not_ use the default parser but the [`mastermind/html5-php`](https://github.com/Masterminds/html5-php) library to parse the HTML5 to build the `DOMDocument`. (We're already using this library for HTML output)\r\n\r\nThe use of mastermind for input is a seemingly small change but causes a huge problem: We cannot point out line numbers when we find validation issues.  [`DOMNode::getLineNo()`](http://php.net/manual/en/domnode.getlineno.php) always returns zero.\r\n\r\nI filed an [issue](https://github.com/Masterminds/html5-php/issues/113) on the `mastermind/html5-php`. Sadly there has been no response on it (yet). \r\n\r\nI have been able to make my own  [workaround](https://github.com/Masterminds/html5-php/issues/113#issuecomment-221214077) though (See filed issue for workaround details).\r\n\r\nTask for this ticket: \r\n- Make the changes in the AMP Library to use the mastermind/html5-php library for input HTML parsing. Add [workaround](https://github.com/Masterminds/html5-php/issues/113#issuecomment-221214077) for line numbers.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Lullabot/amp-library/issues/comments/221239018","html_url":"https://github.com/Lullabot/amp-library/issues/68#issuecomment-221239018","issue_url":"https://api.github.com/repos/Lullabot/amp-library/issues/68","id":221239018,"user":{"login":"sidkshatriya","id":638477,"avatar_url":"https://avatars.githubusercontent.com/u/638477?v=3","gravatar_id":"","url":"https://api.github.com/users/sidkshatriya","html_url":"https://github.com/sidkshatriya","followers_url":"https://api.github.com/users/sidkshatriya/followers","following_url":"https://api.github.com/users/sidkshatriya/following{/other_user}","gists_url":"https://api.github.com/users/sidkshatriya/gists{/gist_id}","starred_url":"https://api.github.com/users/sidkshatriya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sidkshatriya/subscriptions","organizations_url":"https://api.github.com/users/sidkshatriya/orgs","repos_url":"https://api.github.com/users/sidkshatriya/repos","events_url":"https://api.github.com/users/sidkshatriya/events{/privacy}","received_events_url":"https://api.github.com/users/sidkshatriya/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T11:17:49Z","updated_at":"2016-05-24T11:17:49Z","body":"This is quite an intrusive change though its basically done.  \r\n\r\nI wont be merging this to master yet. I want to do more testing and make sure things are robust enough."}}
{"actor":{"display_login":"sidkshatriya"}}