catdoc to preview Word documents from the command line. Is there something similar for HTML?
In other words I would like to do
cathtml Webpage.html | less and get more or less a
man page look output.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
One solution is to use
lynx -dump, as in
lynx -dump file.html
echo "<div>this is a div</div>" | lynx -dump -stdin
w3m -dump, it respects the page layout. It is awesome.
sudo aptitude install w3m w3m -dump file.html echo "<div>x</div>" | w3m -dump -T text/html
You can set the number of columns of the terminal for getting the better layout, for example, if you are using a full-window terminal, 200 can be a good try:
w3m -dump -cols 200 file.html
There are these so-called text html browsers, of which I have successfully tested Lynks and eLinks. Of which elinks has became my favorite.
Anyway, they are different than a "web page previewers" as you suggest in your question. They are more like active real time browsers, which carries on lots of useful features for an easy web browsing and of course, you can also use it for local/remote web pages preview.
My elinks screenshot for you to see elinks in action:
html2text Webpage.html | mdless
curl to download the file first
curl https://askubuntu.com | html2text | mdless
The curl does download the file in the
html2text. This gives
mdless the markdown which will be shown like a pager.