exports.testSerializer = function(test) { test.expect(1); var HTML5 = require('html5'); var p = new HTML5.Parser(); p.parse('<p class="Hello">Hi!</p><p class="hello there">Hi again</p>'); test.equals(HTML5.serialize(p.tree.document, null, {lowercase: true}), '<html><head></head><body><p class=Hello>Hi!</p><p class="hello there">Hi again</p></body></html>'); test.done(); }
request(req.body.article_url, function (error, response, body) { if (response.statusCode == 200) { var window = jsdom.jsdom(null, null, { parser: html5, features: { QuerySelector: true } }).createWindow(), parser = new html5.Parser({document: window.document}); parser.parse(body); get_article(window.document, parse_url[parse_url.length-1]); } res.render("index", { title: "SFU ENGAGE", user : userobject, status : "logged in", errormsg : error }) });
require.paths.unshift('lib') require.paths.unshift('deps/jsdom/lib') var HTML5 = require('html5'), Script = process.binding('evals').Script, util = require('util'), fs = require('fs'), jsdom = require('jsdom'), window = jsdom.createWindow(null, null, {parser: HTML5, document: new jsdom.dom.level1.core.Document()}); window.document.removeChild(window.document.childNodes[0]); // Clear the stub document that jsdom gives us var parser = new HTML5.Parser({document: window.document}); var inputfile = fs.readFileSync('doc/jquery-example.html'); parser.parse(inputfile); jsdom.jQueryify(window, 'deps/jquery/dist/jquery.js', function(window, jquery) { Script.runInNewContext('jQuery("p").append("<b>Hi!</b>")', window); sys.puts(window.document.innerHTML); });
require.paths.push('lib'); require.paths.push('deps/jsdom/lib'); var HTML5 = require('html5'), events = require('events'), sys = require('sys'), fs = require('fs'), assert = require('assert') var inp = fs.createReadStream(process.argv[2]) var p = new HTML5.Parser(); if(process.argv[3]) { var debugs = process.argv[3].split(','); for(var d in debugs) HTML5.enableDebug(debugs[d]); } p.on('end', function() { console.log(HTML5.serialize(p.document, null, {lowercase: true, quote_attr_values: false})) }) p.parse(inp);
.add('html5 v' + html5Version + ' (https://github.com/aredridel/html5)', function () { for (var i = 0; i < testPages.length; i++) { var parser = new html5.Parser(); parser.parse(testPages[i]); } })
var l = fs.readdirSync(base); for(var t in l) { if(process.argv[2] && process.argv[2] != l[t]) continue; var testname = l[t]; if(testname.match(/\.js$/)) continue; sys.debug("Test file: " + testname); var f = require('../tests/support/readTestData') var td = f.readTestData(base+testname); var tests = 1; for(var i in td) { try { if(process.argv[3] && process.argv[3] != i) continue; sys.debug("Test #" + i + ": "); sys.debug("Input data: " + sys.inspect(td[i].data.slice(0, td[i].data.length - 1))); if(td[i]['document-fragment']) sys.debug("Input document fragment: " + sys.inspect(td[i]['document-fragment'])) var p = new HTML5.Parser() if(td[i]['document-fragment']) { p.parse_fragment(td[i].data.slice(0, td[i].data.length - 1), td[i]['document-fragment'].slice(0, td[i]['document-fragment'].length - 1)) } else { p.parse(td[i].data.slice(0, td[i].data.length - 1)); } var errorsFixed = p.errors.map(function(e) { if(!HTML5.E[e[0]]) return e; return HTML5.E[e[0]].replace(/%\(.*?\)/, function(r) { if(e[1]) { return e[1][r.slice(2).slice(0, r.length - 3)]; } else { return r; } }); });
queries[i].callback = function(res, body) { parser.parse(body) jsdom.jQueryify(window, './jquery-1.6.1.min.js', function(window, $){ callback(null, window) }) }