This is where pandoc comes to the rescue. I’ve written about this
tool in the past discussing how to easily convert Markdown to PDF. It turns out that pandoc also supports arbitrary URL arguments which means that you can convert HTML files on the fly without having to download them first.
This means that we can take an arbitrary URL, pass it into pandoc, and spit out plain text. Furthermore, we can pipe this into less to get a nice pager for longer documents. The full string is shown below:
pandoc -f html -t plain https://www.theverge.com/2017/5/4/15547314/edward-snowden-cory-doctorow-nypl-talk-walkaway | less
In the example above,
-f specifies the input filetype, in this case HTML.
-t specifies the conversion filetype, in this case plain text. Pandoc supports a ton of different formats, you can read the man page for more info.
The image below shows the output in the terminal.
The next logical step is to make a script like my wordpress mutt poster to make this even easier. You could make a simple program called
reader and put it in
/usr/local/bin/reader. The contents of this script are:
#!/bin/bash # Terminal Reader Mode using Pandoc and Less url="$1" pandoc -f html -t plain $url | less
You can then use this by typing
If you made it this far, you should probably follow me on twitter. 🙂 Follow @levlaz