Terminal Reader Mode with Pandoc and Less
The other day Aosheng send me an article to read from the verge. When I tried to read it, it took about 5 minutes to load because of the 15 various JavaScript things that were running in addition to ads loading in the background. Firefox was unhappy, and even when I tried to turn on “Reader View” (which strips out all of the junk) it took another minute to load. I’ve been on a UNIX binge lately so I figured there had to be a clever hack to make my own reader view in a terminal. 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
-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 pagefor more info.
The next logical step is to make a script like my wordpress mutt posterto 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:
1 2 3 4 5 6 |
#!/bin/bash # Terminal Reader Mode using Pandoc and Less |
reader $URL
.
Thank you for reading! Share your thoughts with me on bluesky, mastodon, or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Now What?
- Setting up ANTLR4 on Windows
- SQLite DB Migrations with PRAGMA user_version
- My Custom Miniflux CSS Theme
- Meritocracy?
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Useful Bluesky Tools from Robb Knight • Posts • Atom Feed
- Re: Bluesky from Colin Devroe
- From the Red Hell to the Sky of Blue from Straphanger
- We don’t need to use what we make from Derek Sivers blog
- Ubuntu Summit 2024: A joyful experience filled with sorrow from Planet KDE | English
- Sabotage from jwz
- What if My Tribe Is Wrong? from Armin Ronacher's Thoughts and Writings
- It’s the “1998” of the AI Revolution. So Why Can I Safely Ignore It? from The Internet Review
Articles from blogs I follow around the net
17/11/2024
# Back in May I wrote about being inspired to write a track based on a YouTube comment. I recorded a test not long after and built on that into June. Then the breakdown struck and I had a massive crisis of confidence alongside the depression and anxiety. I …
via Colin Walker - Daily Feed November 23, 2024Weeknotes: asynchronous LLMs, synchronous embeddings, and I kind of started a podcast
These past few weeks I've been bringing Datasette and LLM together and distracting myself with a new sort-of-podcast crossed with a live streaming experiment. Project: interviewing people about their projects Datasette Public Office Hours Async LLM …
via Simon Willison's Weblog: Entries November 22, 2024DNA Lounge: Wherein it's our birthday
DNA Lounge is 39 years old today, having opened on November 22, 1985! Our oldest known flyer. Photos from opening night. Our "Legacy" plaque. If you'd like us to stick around for the next four decades, or until the oceans boil, the stars weep bloo…
via jwz November 22, 2024Generated by openring