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.

8

You are better off using links for table rendering:

links -width 80 -dump http://website.com/ > file.html
  • 2
    or links 2 or elinks or w3m. Try them all and see whose rendering you like best. – Gilles Mar 1 '11 at 21:59
  • Yes, the version I tested with was actually links2 – jamespo Mar 1 '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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.