Skip to content

Instantly share code, notes, and snippets.

@lucianmarin
Last active July 6, 2016 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucianmarin/5796a481d7bc54e2c4ba8e8144abc571 to your computer and use it in GitHub Desktop.
Save lucianmarin/5796a481d7bc54e2c4ba8e8144abc571 to your computer and use it in GitHub Desktop.
Create amp from url or html
#!/usr/bin/env node
var program = require('commander'),
read = require('node-readability'),
format = require('distro-mic').format;
program
.version('1.0.0')
.option('-u, --url [type]', 'Input article URL')
.option('-h, --html [type]', 'Input HTML code')
.parse(process.argv);
if (program.url && !program.html) {
read(program.url, function(err, article, meta) {
console.log(format(article.content).amp);
article.close();
});
}
if (program.html && !program.url) {
console.log(format(program.html).amp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment