Shell – Converting html table into ncurses-like ascii table

lynxncursesshell-script

I have some documentation in an html table. I want to convert the table to an ascii table, like you see when you get a mysql command line result back, like this:

+------------+------------+
| header     | header     |
+------------+------------+
| cell data  | cell data  |
+------------+------------+
| cell data  | cell data  |
+------------+------------+

… so I can include it in some code comments.

How could I do this easily? I was thinking piping the output of lynx into a file, but lynx doesn't put ascii borders around tables 😛

I also want to control cell width, so that the content cells don't spill outside the accepted screen width of the code.

Best Answer

You are better off using links for table rendering:

links -width 80 -dump http://website.com/ > file.html
Related Question