emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ASCII Tables with row and colspans


From: Ag Ibragimov
Subject: ASCII Tables with row and colspans
Date: Thu, 12 Oct 2023 16:05:08 -0500

I've driven myself into a self-imposed headache. I need to render an HTML table 
(Elisp representation of it, result of libxml-parse) in ASCII. Org-mode tables 
are notorious for their lack of support for spanned columns or rows. Yay, 
table.el can do it, it's nice for inserting a table and modifying the content 
interactively. However, it's not really suitable for filling out a table 
programmatically. There's a `table-insert-sequence` command in table.el that 
allows you to insert text into a selected cell while automatically adjusting 
the table, but it's agonizingly slow to call as a function. Sadly, table.el 
doesn't seem to have a function that could "adjust the table" the way how 
`org-ctrl-c-ctrl-c` does in org-mode (which, again, doesn't support spans).

Like if I have something like this (that's a parsed example from the 
Wiktionary):

'(table
    ((style . "background-color:#F0F0F0;width:100%")
     (class . "inflection-table"))
    (tbody
     nil
     (tr
      nil
      (th ((colspan . "2") (style . "background-color:#e2e4c0;")) "infinitive") 
" "
      (td ((colspan . "6") (style . "text-align:center;")) "conocer"))
     (tr
      nil (th ((colspan . "2") (style . "background-color:#e2e4c0;")) 
"gerundive") " "
      (td
       ((colspan . "6") (style . "text-align:center;"))
       (span
        ((class . "Latn") (lang . "ast"))
        (a ((href . "/wiki/conociendo#Asturian")
            (title . "conociendo"))
           "conociendo")) " "))
     (tr...)
     (tr...)
     (tr...)
     (tr...)))

What's fast and easy way to render it in ASCII?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]