@ -55,6 +55,7 @@ Options:
- U -- is - url Interpret SOURCE as a URL rather than file name
- q -- quiet Don ' t output extra information to stderr
- l -- low - confidence MODE What to do if Readability . js is uncertain about what the core content actually is
- j -- json Output properties as a JSON payload
The -- low - confidence option determines what should be done for documents where Readability can ' t tell what the core content is :
@ -82,7 +83,7 @@ Default value is "html-title,html-content".`);
const stringArgParams = [ '_' , "--" , "low-confidence" , "output" , "properties" , "url" , "base" ] ;
const boolArgParams = [ "quiet" , "help" , "version" , "is-url" ];
const boolArgParams = [ "quiet" , "help" , "version" , "is-url" , "json" ];
const alias = {
"url" : 'u' ,
"output" : 'o' ,
@ -92,7 +93,8 @@ const alias = {
"is-url" : 'U' ,
"quiet" : 'q' ,
"low-confidence" : 'l' ,
"help" : 'h'
"help" : 'h' ,
"json" : 'j'
}
let args = parseArgs ( process . argv . slice ( 2 ) , {
@ -185,7 +187,7 @@ delete args['--'];
const outputArg = args [ 'output' ] ;
const documentURL = args [ "base" ] || inputURL ;
const outputJSON = args [ 'json' ] ;
const Properties = {
@ -332,6 +334,10 @@ function onLoadDOM(dom) {
setErrored ( ExitCodes . dataError ) ;
return ;
}
if ( outputJSON ) {
writeStream . write ( JSON . stringify ( article ) ) ;
return ;
}
if ( wantedProperties . includes ( Properties . title ) ) {
writeStream . write ( ` Title: ${ article . title } \n ` ) ;