diff --git a/index.js b/index.js index 5b5792b..f35ca7f 100755 --- a/index.js +++ b/index.js @@ -116,7 +116,7 @@ let args = yargs .version(false) .command("* [source]", __`Process HTML input`, (yargs) => { yargs.positional("source", { - desc: "A file, an http(s) URL, or '-' for standard input", + desc: __`A file, an http(s) URL, or '-' for standard input`, type: "string" }); }) @@ -217,14 +217,14 @@ let args = yargs desc: __`Output properties as a JSON payload` }) .epilogue(__`The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n` + -__` no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties option.\n` + +__` no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n` + __` force Process the document even when unsure (may produce really bad output).\n` + __` exit When unsure, exit with an error.\n` + '\n' + __`Default value is "no-op".\n` + '\n' + '\n' + -__`The --properties option accepts a comma-separated list of values (with no spaces in-between). Suitable values are:\n` + +__`The --properties option accepts a list of values, separated by spaces. Suitable values are:\n` + __` html-title Outputs the article's title, wrapped in an

tag.\n` + __` title Outputs the title in the format "Title: $TITLE".\n` + __` excerpt Article description, or short excerpt from the content, in the format "Excerpt: $EXCERPT".\n` + @@ -235,7 +235,7 @@ __` html-content Outputs the article's main content as HTML.\n` + __` text-content Outputs the article's main content as plain text.\n` + '\n' + __`Text-content and Html-content are mutually exclusive, and are always printed last.\n` + -__`Default value is "html-title,html-content".\n`) +__`Default value is "html-title html-content".\n`) .wrap(Math.min(yargs.terminalWidth(), 120)) .strict() .parse(); @@ -291,7 +291,7 @@ let inputFile; let inputURL; let inputIsFromStdin = false; -if (args["is-url"] && inputArg.search(/^\w+:\/\//) != -1) +if (args["is-url"] && inputArg.search(/^\w+:\/\//) == -1) inputArg = "https://" + inputArg; if (!args["is-file"] && inputArg.search(/^\w+:\/\//) != -1) inputURL = inputArg; @@ -372,7 +372,6 @@ function onLoadDOM(dom) { const document = dom.window.document; let shouldParseArticle = true; - if (args["low-confidence"] != LowConfidenceMode.force) shouldParseArticle = isProbablyReaderable(document); @@ -384,7 +383,7 @@ function onLoadDOM(dom) { } else { if (!args["quiet"]) console.error(__`Not sure if this document should be processed. Not processing`); - if (wantedPropertiesCustom) { + if (args["json"] || wantedPropertiesCustom) { console.error(__`Can't output properties`); setErrored(ExitCodes.dataError); return; @@ -446,7 +445,12 @@ function onLoadDOM(dom) { writeStream.write(__`Length: ${article.length}\n`); } if (wantedProperties.includes(Properties.dir)) { - writeStream.write(__`Direction: ${article.dir}\n`); + if (article.dir == 'ltr') + writeStream.write(__`Direction: ltr\n`); + else if (article.dir == 'rtl') + writeStream.write(__`Direction: rtl\n`); + else + writeStream.write(__`Direction: ${article.dir}\n`); } if (wantedProperties.includes(Properties.htmlTitle)) { writeStream.write(`

${escapeHTML(article.title, document)}

\n`); diff --git a/locales/en.json b/locales/en.json index 8c3a00b..832f824 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1,5 +1,6 @@ { "Process HTML input": "Process HTML input", + "A file, an http(s) URL, or '-' for standard input": "A file, an http(s) URL, or '-' for standard input", "Print script for bash/zsh completion": "Print script for bash/zsh completion", "Print version": "Print version", "Show help": "Show help", @@ -13,11 +14,11 @@ "(deprecated) Interpret SOURCE as a URL rather than file name": "(deprecated) Interpret SOURCE as a URL rather than file name", "Output properties as a JSON payload": "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:\n": "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n", - " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties option.\n": " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties option.\n", + " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n", " force Process the document even when unsure (may produce really bad output).\n": " force Process the document even when unsure (may produce really bad output).\n", " exit When unsure, exit with an error.\n": " exit When unsure, exit with an error.\n", "Default value is \"no-op\".\n": "Default value is \"no-op\".\n", - "The --properties option accepts a comma-separated list of values (with no spaces in-between). Suitable values are:\n": "The --properties option accepts a comma-separated list of values (with no spaces in-between). Suitable values are:\n", + "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n", " html-title Outputs the article's title, wrapped in an

tag.\n": " html-title Outputs the article's title, wrapped in an

tag.\n", " title Outputs the title in the format \"Title: $TITLE\".\n": " title Outputs the title in the format \"Title: $TITLE\".\n", " excerpt Article description, or short excerpt from the content, in the format \"Excerpt: $EXCERPT\"\n": " excerpt Article description, or short excerpt from the content, in the format \"Excerpt: $EXCERPT\"\n", @@ -27,7 +28,7 @@ " html-content Outputs the article's main content as HTML.\n": " html-content Outputs the article's main content as HTML.\n", " text-content Outputs the article's main content as plain text.\n": " text-content Outputs the article's main content as plain text.\n", "Text-content and Html-content are mutually exclusive, and are always printed last.\n": "Text-content and Html-content are mutually exclusive, and are always printed last.\n", - "Default value is \"html-title,html-content\".\n": "Default value is \"html-title,html-content\".\n", + "Default value is \"html-title html-content\".\n": "Default value is \"html-title html-content\".\n", "No input provided": "No input provided.", "Note: --is-url option is deprecated.": "Note: --is-url option is deprecated.", "Note: --url option is deprecated, please use --base instead.": "Note: --url option is deprecated, please use --base instead.", @@ -44,6 +45,8 @@ "Excerpt: %s\n": "Excerpt: %s\n", "Author: %s\n": "Author: %s\n", "Length: %s\n": "Length: %s\n", + "Host not found: '%s'": "Host not found: '%s'", "Direction: %s\n": "Direction: %s\n", - "Host not found: '%s'": "Host not found: '%s'" + "Direction: ltr\n": "Direction: ltr\n", + "Direction: rtl\n": "Direction: rtl\n" } diff --git a/locales/ru.json b/locales/ru.json index 5c314cc..bcf119c 100644 --- a/locales/ru.json +++ b/locales/ru.json @@ -1,49 +1,52 @@ { "Process HTML input": "Обработать входной HTML", - "Print script for bash/zsh completion": "Print script for bash/zsh completion", - "Print version": "Print version", - "Show help": "Show help", - "The file to which the result should be output": "The file to which the result should be output", - "What to do if Readability.js is uncertain about what the core content actually is": "What to do if Readability.js is uncertain about what the core content actually is", - "Output specific properties of the parsed article": "Output specific properties of the parsed article", - "Don't output extra information to stderr": "Don't output extra information to stderr", - "Set the document URL when parsing standard input or a local file (this affects relative links)": "Set the document URL when parsing standard input or a local file (this affects relative links)", - "(deprecated) alias for --base": "(deprecated) alias for --base", - "Interpret SOURCE as a file name rather than a URL": "Interpret SOURCE as a file name rather than a URL", - "(deprecated) Interpret SOURCE as a URL rather than file name": "(deprecated) Interpret SOURCE as a URL rather than file name", - "Output properties as a JSON payload": "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:\n": "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n", - " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties option.\n": " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties option.\n", - " force Process the document even when unsure (may produce really bad output).\n": " force Process the document even when unsure (may produce really bad output).\n", - " exit When unsure, exit with an error.\n": " exit When unsure, exit with an error.\n", - "Default value is \"no-op\".\n": "Default value is \"no-op\".\n", - "The --properties option accepts a comma-separated list of values (with no spaces in-between). Suitable values are:\n": "The --properties option accepts a comma-separated list of values (with no spaces in-between). Suitable values are:\n", - " html-title Outputs the article's title, wrapped in an

tag.\n": " html-title Outputs the article's title, wrapped in an

tag.\n", - " title Outputs the title in the format \"Title: $TITLE\".\n": " title Outputs the title in the format \"Title: $TITLE\".\n", - " excerpt Article description, or short excerpt from the content, in the format \"Excerpt: $EXCERPT\"\n": " excerpt Article description, or short excerpt from the content, in the format \"Excerpt: $EXCERPT\"\n", - " byline Author metadata, in the format \"Author: $AUTHOR\"\n": " byline Author metadata, in the format \"Author: $AUTHOR\"\n", - " length Length of the article in characters, in the format \"Length: $LENGTH\"\n": " length Length of the article in characters, in the format \"Length: $LENGTH\"\n", - " dir Content direction, is either \"Direction: ltr\" or \"Direction: rtl\"\n": " dir Content direction, is either \"Direction: ltr\" or \"Direction: rtl\"\n", - " html-content Outputs the article's main content as HTML.\n": " html-content Outputs the article's main content as HTML.\n", - " text-content Outputs the article's main content as plain text.\n": " text-content Outputs the article's main content as plain text.\n", - "Text-content and Html-content are mutually exclusive, and are always printed last.\n": "Text-content and Html-content are mutually exclusive, and are always printed last.\n", - "Default value is \"html-title,html-content\".\n": "Default value is \"html-title,html-content\".\n", - "No input provided": "No input provided.", - "Note: --is-url option is deprecated.": "Note: --is-url option is deprecated.", - "Note: --url option is deprecated, please use --base instead.": "Note: --url option is deprecated, please use --base instead.", - "Retrieving...": "Retrieving...", - "Warning: piping input with unknown URL. This means that relative links will be broken. Supply the --base parameter to fix.": "Warning: piping input with unknown URL. This means that relative links will be broken. Supply the --base parameter to fix.", - "Not sure if this document should be processed. Not processing": "Not sure if this document should be processed. Not processing", - "Error while retrieving %s:": "Error while retrieving %s:", - "Invalid URL: %s": "Invalid URL: %s", - "Processing...": "Processing...", - "Not sure if this document should be processed, exiting": "Not sure if this document should be processed, exiting", - "Can't output properties": "Can't output properties", - "Couldn't process document.": "Couldn't process document.", - "Title: %s\n": "Title: %s\n", - "Excerpt: %s\n": "Excerpt: %s\n", - "Author: %s\n": "Author: %s\n", - "Length: %s\n": "Length: %s\n", - "Direction: %s\n": "Direction: %s\n", - "Host not found: '%s'": "Host not found: '%s'" + "A file, an http(s) URL, or '-' for standard input": "Файл, http(s) URL, или '-' для стандартного ввода", + "Print script for bash/zsh completion": "Напечатать скрипт для автодополнения Bash/Zsh", + "Print version": "Показать информацию про версию и выйти", + "Show help": "Показать помощь", + "The file to which the result should be output": "Файл, в который записывается результат", + "What to do if Readability.js is uncertain about what the core content actually is": "Что делать, когда Readability не может определить целевой контент", + "Output specific properties of the parsed article": "Показать определённые характеристики текста", + "Don't output extra information to stderr": "Не выдавать лишнюю информацию в стандартный вывод ошибок", + "Set the document URL when parsing standard input or a local file (this affects relative links)": "Указать URL документа при чтении из локального файла или стандартного ввода (влияет на относительные ссылки)", + "(deprecated) alias for --base": "(устаревшый) синоним для --base", + "Interpret SOURCE as a file name rather than a URL": "Интерпретировать [source] как файл, а не как URL", + "(deprecated) Interpret SOURCE as a URL rather than file name": "(устаревшее) Интерпретировать [source] как URL, а не как файл", + "Output properties as a JSON payload": "Показать характеристики текста в формате JSON", + "The --low-confidence option determines what should be done for documents where Readability can't tell what the core content is:\n": "Параметр --low-confidence определяет, что следует делать, если Readability не может определить целевой контент:\n", + " no-op When unsure, don't touch the HTML, output as-is. This is incompatible with the --properties and --json options.\n": " no-op В случае неуверенности, не трогать HTML, выдавать как есть. Не совместимо с параметрами --properties и --json.\n", + " force Process the document even when unsure (may produce really bad output).\n": " force Обработать документ даже в случае неуверенности (может выдать плохой результат).\n", + " exit When unsure, exit with an error.\n": " exit В случае неуверенности, выдать ошибку и выйти.\n", + "Default value is \"no-op\".\n": "По умолчанию выполняется \"no-op\".\n", + "The --properties option accepts a list of values, separated by spaces. Suitable values are:\n": "Параметр --properties принимает список значений (разделённых пробелами):\n", + " html-title Outputs the article's title, wrapped in an

tag.\n": " html-title Вывести заголовок статьи в тэге

.\n", + " title Outputs the title in the format \"Title: $TITLE\".\n": " title Вывести заголовок статьи в формате \"Заголовок: $ЗАГОЛОВОК\".\n", + " excerpt Article description, or short excerpt from the content, in the format \"Excerpt: $EXCERPT\"\n": " excerpt Краткий урывок из статьи, в формате \"Урывок: $УРЫВОК\".\n", + " byline Author metadata, in the format \"Author: $AUTHOR\"\n": " byline Данные об авторе статьи, в формате \"Автор: $AUTHOR\".\n", + " length Length of the article in characters, in the format \"Length: $LENGTH\"\n": " length Длинна статьи (количество символов) в формате \"Длинна: $ДЛИННА\".\n", + " dir Content direction, is either \"Direction: ltr\" or \"Direction: rtl\"\n": " dir Направление текста: либо \"Направление: слева направо\", либо \"Направление: справа налево\".\n", + " html-content Outputs the article's main content as HTML.\n": " html-content Вывести главный контент страницы в виде HTML.\n", + " text-content Outputs the article's main content as plain text.\n": " text-content Вывести главный контент страницы в виде обычного текста.\n", + "Text-content and Html-content are mutually exclusive, and are always printed last.\n": "text-content и html-content исключают друг друга, и всегда выводятся в конце.\n", + "Default value is \"html-title html-content\".\n": "По умолчанию \"html-title html-content\".\n", + "No input provided": "Данные не введены.", + "Note: --is-url option is deprecated.": "Внимание: параметр --is-url устаревший.", + "Note: --url option is deprecated, please use --base instead.": "Внимание: параметр --url устаревший, используйте вместо него --base.", + "Retrieving...": "Загружаем...", + "Warning: piping input with unknown URL. This means that relative links will be broken. Supply the --base parameter to fix.": "Внимание: считываем контент с неизвестным базовым URL. Пожалуйста, введите параметр --base.", + "Not sure if this document should be processed. Not processing": "Не уверен, стоит ли обрабатывать этот документ - не буду обрабатывать.", + "Error while retrieving %s:": "Ошибка во время загрузки %s:", + "Invalid URL: %s": "Неправильный URL: %s", + "Processing...": "Обрабатываем...", + "Not sure if this document should be processed, exiting": "Не уверен, стоит ли обрабатывать этот документ - выхожу", + "Can't output properties": "Не могу определить характеристики", + "Couldn't process document.": "Не удалось обработать документ.", + "Title: %s\n": "Заголовок: %s\n", + "Excerpt: %s\n": "Урывок: %s\n", + "Author: %s\n": "Автор: %s\n", + "Length: %s\n": "Длинна: %s\n", + "Host not found: '%s'": "Сервер не найден: '%s'", + "Direction: %s\n": "Направление: %s\n", + "Direction: ltr\n": "Направление: слева направо\n", + "Direction: rtl\n": "Направление: справа налево\n" }