Skip to content
This repository was archived by the owner on Jan 23, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bin/canonicalizr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node
/*
Copyright (c) 2015, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/

var fs = require('fs'),
Canonicalizr = require('../src/context-parser').Parser;

if (process.argv.length !== 3) {
console.log("Usage: canonicalizr filePath");
process.exit(1);
}

var html = fs.readFileSync(process.argv[2], "utf8");
var c = new Canonicalizr({
enableCanonicalization: true,
enableVoidingIEConditionalComments: true,
enableStateTracking: false
});

// do not use console.log(), which append an unnecessary linebreak
// console.log() in nodejs v0.12 or below are vulnerable to eat %
// ref: https://github.com/nodejs/node/issues/3396
process.stdout.write(c.contextualize(html));