<commit_before>/* jslint node: true */
/* globals document, phantom, window */
'use strict';

// TODO: add note in README.md that this makes PhantomJS a required global dependency

// usage: `phantomjs lib/save-html.js http://s.codepen.io/curtisj44/debug/xbQXbV`
// usage: `phantomjs lib/save-html.js http://s.codepen.io/curtisj44/debug/xbQXbV test`

var
	fs = require('fs'),
	page = require('webpage').create(),
	system = require('system'),

	url = system.args[1],
	saveTo = system.args[2];

page.onLoadStarted = function () {
	// TODO: get this to output in time in `node html-lint`
	console.log('Loading page...');
};

page.open(url, function (status) {
	var
		html,
		js = page.evaluate(function () {
			return document;
		}),
		origin = page.evaluate(function () {
			return window.location.origin;
		});

	page.viewportSize = { width: 1024, height: 768 };
	page.render('temp/' + saveTo + '.png');

	if (status === 'success') {
		html = js.all[0].outerHTML

			// Resolve domain-agnostic paths
			.replace(/\="\/\//g, '="https://')
			.replace(/\='\/\//g, '=\'https://')

			// Resolve relative paths
			.replace(/\="\//g, '="' + origin + '/')<commit_msg>save a slightly larger screenshot<commit_after>/* jslint node: true */
/* globals document, phantom, window */
'use strict';

// TODO: add note in README.md that this makes PhantomJS a required global dependency

// usage: `phantomjs lib/save-html.js http://s.codepen.io/curtisj44/debug/xbQXbV`
// usage: `phantomjs lib/save-html.js http://s.codepen.io/curtisj44/debug/xbQXbV test`

var
	fs = require('fs'),
	page = require('webpage').create(),
	system = require('system'),

	url = system.args[1],
	saveTo = system.args[2];

page.onLoadStarted = function () {
	// TODO: get this to output in time in `node html-lint`
	console.log('Loading page...');
};

page.open(url, function (status) {
	var
		html,
		js = page.evaluate(function () {
			return document;
		}),
		origin = page.evaluate(function () {
			return window.location.origin;
		});

	page.viewportSize = { width: 1200, height: 900 };
	page.render('temp/' + saveTo + '.png');

	if (status === 'success') {
		html = js.all[0].outerHTML

			// Resolve domain-agnostic paths
			.replace(/\="\/\//g, '="https://')
			.replace(/\='\/\//g, '=\'https://')

			// Resolve relative paths
			.replace(/\="\//g, '="' + origin + '/')
{'fraction_non_alphanumeric': 0.2, 'fraction_numerical': 0.011965811965811967, 'mean_word_length': 3.248638838475499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2307811', 'n_tokens_mistral': 904, 'n_tokens_neox': 816, 'n_words': 194}