Go to file
2021-01-29 11:39:08 +02:00
locales Output full <html> with <head> and <title> by default 2021-01-27 00:23:09 +02:00
.gitignore Add .html to .gitignore 2021-01-25 00:57:03 +02:00
index.js Sanitize whole HTML as DOM rather than string 2021-01-29 11:32:27 +02:00
LICENSE.md Add GPL-3.0 license 2020-07-15 13:37:33 +03:00
package-lock.json Switch away from Git dependency to scoped package (closes #4) 2021-01-29 11:39:08 +02:00
package.json Switch away from Git dependency to scoped package (closes #4) 2021-01-29 11:39:08 +02:00
README.md Localization READMEs 2021-01-25 22:13:02 +02:00

readability-cli

Firefox Reader View in your terminal!

readability-cli takes any HTML page and strips out unnecessary bloat by using Mozilla's Readability library. As a result, you get a web page which contains only the core content and nothing more. The resulting HTML is suitable for terminal browsers, text readers, and other uses.

Here is a before-and-after comparison, using an article from The Guardian as a test subject.

Standard view in W3M

An article from The Guardian in W3M

So much useless stuff that the main article does not even fit on the screen!

readability-cli + W3M

An article from The Guardian in W3M using readability-cli

Ah, much better.

Installation

readability-cli can be installed on any system with Node.js:

npm install -g readability-cli

Arch Linux

Arch Linux users may use the readability-cli AUR package instead.

Usage

readable [SOURCE] [options]

readable [options] -- [SOURCE]

where SOURCE is a file, an http(s) URL, or '-' for standard input

See readable --help for more information.

Examples

Read HTML from a file and output the result to the console:

readable index.html

Fetch a random Wikipedia article, get its title and an excerpt:

readable https://en.wikipedia.org/wiki/Special:Random -p title,excerpt

Fetch a web page and read it in W3M:

readable https://www.nytimes.com/2020/01/18/technology/clearview-privacy-facial-recognition.html | w3m -T text/html

Download a web page using cURL, parse it and output as JSON:

curl https://github.com/mozilla/readability | readable --base=https://github.com/mozilla/readability --json

It's a good idea to supply the --base parameter when piping input, otherwise readable won't know the document's URL, and things like relative links won't work.

Localization

See locales.

Why Node.js? It's so slow!

I know that it's slow, but JavaScript is the most sensible option for this, since Mozilla's Readabilty library is written in JavaScript. There have been ports of the Readability algorithm to other languages, but Mozilla's version is the only one that's actively maintained as of 2020.