Socket
Socket
Sign inDemoInstall

@html-to/text-cli

Package Overview
Dependencies
13
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @html-to/text-cli

CLI html to plain text converter


Version published
Weekly downloads
751
decreased by-17.74%
Maintainers
1
Install size
1.38 MB
Created
Weekly downloads
 

Readme

Source

@html-to/text-cli

Command line interface for html-to-text Node.js package.

Features

  • almost all html-to-text options can be specified via command line arguments or json config (the only exception is functions such as custom formatters);
  • a couple of presets for common use cases (human reading in terminal and machine indexing/search).

Changelog

Available here: CHANGELOG.md

Installation

npm i -g @html-to/text-cli

Name collisions

  • old versions of html-to-text package expose a command with the same name. Make sure that package is not installed globally anymore.
  • there is an old abandoned CLI package that exposes a command with the same name and actually has nothing to do with html-to-text package. Make sure to only use namespaced package @html-to/text-cli.

Usage

  • Use html-to-text command (html-to-text.cmd in PowerShell);
  • Pipe HTML to stdin;
  • Get plain text from stdout;
  • Pass converter options as command arguments.

Command line arguments

> cat ./input.html | html-to-text [commands...] [keys and values...] > ./output.txt

In PowerShell:

PS> Get-Content .\input.html | html-to-text.cmd [commands...] [keys and values...] > .\output.txt

.ps1 wrapper installed by npm might not work with stdin, so use .cmd instead.

Available commands

CommandAliasArgumentDescription
json-j<file_name>Merge given json file contents with the parsed options object. This way you can provide all or some options from a file rather than explicitly from CLI.
preset-p<preset_name>Merge given preset into the parsed options object. Available presets listed below.
inspect-iPretty print the parsed options object and exit. Useful as a dry run to check how options are parsed.
unparse-uPrint the parsed options object back as args string and exit. Can be used to check what arguments produce the result equivalent to a given json file.
help-hPrint help message end exit.
version-vPrint version number and exit.

Note: short aliases cannot be merged.

Available presets

PresetDescription
humanSome options more suitable for human reading in terminal (ensure line length of 80 characters, format tables visually)
machineSome options more suitable for machine processing (no line length limit, format tables and cells as blocks)

Options syntax

Refer to html-to-text help output for brief syntax information.

Refer to aspargvs readme for more detailed information.

Note: PowerShell requires to escape quotes and curly braces.

Option examples

All options that are representable in JSON format (that is all except functions) can be specified via CLI arguments. Below are some examples.

JSONCLI
{ preserveNewlines: true }--preserveNewlines
{ wordwrap: 100 }--wordwrap=100
{ wordwrap: false }--!wordwrap
{ baseElements: { orderBy: 'occurrence' } }--baseElements.orderBy=occurrence
{ selectors: [
{ selector: 'img', format: 'skip' }
] }
--selectors[] {} :selector=img :format=skip
{ selectors: [
{ selector: 'h1', options: { uppercase: false } },
{ selector: 'h2', options: { uppercase: false } }
] }
--selectors[] {} :selector=h1 :!options.uppercase {} :selector=h2 :!options.uppercase
{ selectors: [
{ selector: 'table', format: 'dataTable', options: { uppercaseHeaderCells: false } }
] }
--selectors[] {} :selector=table :format=dataTable :options.uppercase-header-cells=false
{ selectors: [
{ selector: 'a', options: { linkBrackets: ['<', '>'] } }
] }
--selectors[] {} :selector=a :options.linkBrackets=['<','>']

License

MIT License

Keywords

FAQs

Last updated on 23 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc