Comparing version 0.6.0 to 0.7.0
@@ -9,2 +9,3 @@ #!/usr/bin/env node | ||
var pkg = require('../package.json') | ||
var clipboardy = require('clipboardy') | ||
@@ -33,10 +34,13 @@ function loadHTMLFromURI(uri, callback) { | ||
.version(pkg.version) | ||
.arguments('<file>') | ||
.action(function(file) { | ||
if (/^(http|https):\/\//.test(file)) { | ||
loadHTMLFromURI(file, onHTMLReady) | ||
} else if (file) { | ||
onHTMLReady(loadHTMLFromFile(file)) | ||
.option('-f, --file <file>', 'HTML file path or an url adress', '') | ||
.option('-c, --clipboard', 'read HTML from clipboard') | ||
.action(function(env) { | ||
if (env.clipboard) { | ||
onHTMLReady(clipboardy.readSync() || '') | ||
} else if (/^(http|https):\/\//.test(env.file)) { | ||
loadHTMLFromURI(env.file, onHTMLReady) | ||
} else if (env.file) { | ||
onHTMLReady(loadHTMLFromFile(env.file)) | ||
} else { | ||
throw new Error('an http url or file path must be given') | ||
console.log('use h2m -h to learn usage') | ||
} | ||
@@ -43,0 +47,0 @@ }) |
{ | ||
"name": "h2m", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Transform HTML to markdown base on posthtml.", | ||
@@ -32,2 +32,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"clipboardy": "~1.2.3", | ||
"commander": "^2.9.0", | ||
@@ -34,0 +35,0 @@ "htmlparser2": "^3.9.0", |
@@ -77,8 +77,8 @@ # h2m | ||
Usage: h2m [options] <file> | ||
Options: | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-V, --version output the version number | ||
-f, --file <file> HTML file path or an url adress (default: ) | ||
-c, --clipboard read HTML from clipboard | ||
-h, --help output usage information | ||
``` | ||
@@ -89,3 +89,3 @@ | ||
```bash | ||
$ h2m index.html | ||
$ h2m -f index.html | ||
@@ -102,9 +102,15 @@ converting HTML to Markdown | ||
```bash | ||
$ h2m https://baidu.com | ||
$ h2m -f https://baidu.com | ||
``` | ||
Convert from clipboard: | ||
```bash | ||
$ h2m -c | ||
``` | ||
Save result: | ||
```bash | ||
$ h2m https://google.com > google.md | ||
$ h2m -f https://google.com > google.md | ||
``` | ||
@@ -111,0 +117,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1027109
9219
146
4
+ Addedclipboardy@~1.2.3
+ Addedarch@2.2.0(transitive)
+ Addedclipboardy@1.2.3(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addedexeca@0.8.0(transitive)
+ Addedget-stream@3.0.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedyallist@2.1.2(transitive)