example.php 690 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require "vendor/autoload.php";
  3. use Masterminds\HTML5;
  4. $html = <<< 'HERE'
  5. <html>
  6. <head>
  7. <title>TEST</title>
  8. <script language="javascript">
  9. if (2 > 1) { alert("Math wins."); }
  10. </script>
  11. </head>
  12. <body id='foo'>
  13. <!-- This space intentionally left blank. -->
  14. <section class="section-a pretty" id="bar1">
  15. <h1>Hello World</h1><p>This is a test of the HTML5 parser.</p>
  16. <hr>
  17. &amp; Nobody nowhere.
  18. </section>
  19. <test xmlns:foo="http://example.com/foo">TEST</test>
  20. <![CDATA[Because we can.]]>
  21. &copy;
  22. </body></html>
  23. HERE;
  24. $html5 = new HTML5();
  25. $dom = $html5->loadHTML($html);
  26. print "Converting to HTML 5\n";
  27. $html5->save($dom, fopen("php://stdin", 'w'));