8

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 :P

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

user394
  • 14,194
  • 21
  • 66
  • 93

1 Answers1

8

You are better off using links for table rendering:

links -width 80 -dump http://website.com/ > file.html
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
jamespo
  • 1,171
  • 7
  • 6
  • 2
    or [links 2](http://links.twibright.com/development.php) or [elinks](http://elinks.or.cz/) or [w3m](http://w3m.sourceforge.net/). Try them all and see whose rendering you like best. – Gilles 'SO- stop being evil' Mar 01 '11 at 21:59
  • Yes, the version I tested with was actually links2 – jamespo Mar 01 '11 at 22:03
  • I tried both links2 and elinks, and did not get any border between cells. Could you please indicate whether you actually got them, and if so the version of links you used? – anol Mar 11 '15 at 16:39
  • @anol with elinks on centos 6 this works `elinks -dump http://www.html.am/html-codes/tables` however it depends if the table has borders configured itself – jamespo May 19 '15 at 19:38