* ASCII Tables with row and colspans
@ 2023-10-12 21:05 Ag Ibragimov
2023-10-13 12:02 ` Ihor Radchenko
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Ag Ibragimov @ 2023-10-12 21:05 UTC (permalink / raw)
To: emacs-devel
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?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-10-12 21:05 ASCII Tables with row and colspans Ag Ibragimov
@ 2023-10-13 12:02 ` Ihor Radchenko
2023-10-19 2:13 ` Ag Ibragimov
2023-10-19 6:46 ` Visuwesh
2023-11-03 10:20 ` Jean Louis
2 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2023-10-13 12:02 UTC (permalink / raw)
To: Ag Ibragimov; +Cc: emacs-devel
Ag Ibragimov <agzam.ibragimov@gmail.com> writes:
> 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.
> ...
> What's fast and easy way to render it in ASCII?
AFAIK, AsciiDoctor has a very flexible table syntax. So, you may
consider converting the AsciiDoctor format and then using AsciiDoctor
ASCII export.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-10-13 12:02 ` Ihor Radchenko
@ 2023-10-19 2:13 ` Ag Ibragimov
2023-10-19 3:21 ` Emanuel Berg
0 siblings, 1 reply; 12+ messages in thread
From: Ag Ibragimov @ 2023-10-19 2:13 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-devel
Ihor Radchenko <yantar92@posteo.net> writes:
> Ag Ibragimov <agzam.ibragimov@gmail.com> writes:
>
>> 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.
>> ...
>> What's fast and easy way to render it in ASCII?
>
> AFAIK, AsciiDoctor has a very flexible table syntax. So, you may
> consider converting the AsciiDoctor format and then using AsciiDoctor
> ASCII export.
I think you missed the point that I'm trying to do this in Elisp. This is for a small package I'm writing. I couldn't
find a function anywhere that prints an ASCII table with spans. I thought it would be trivial to write one, turned out
to be a bit trickier than I expected. I'm surprised that something like this doesn't exist already. I'm still hoping
someone already solved that.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-10-19 2:13 ` Ag Ibragimov
@ 2023-10-19 3:21 ` Emanuel Berg
0 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2023-10-19 3:21 UTC (permalink / raw)
To: emacs-devel
Ag Ibragimov wrote:
> I think you missed the point that I'm trying to do this in
> Elisp. This is for a small package I'm writing. I couldn't
> find a function anywhere that prints an ASCII table with
> spans. I thought it would be trivial to write one, turned
> out to be a bit trickier than I expected. I'm surprised that
> something like this doesn't exist already. I'm still hoping
> someone already solved that.
In the package manager, for GNU ELPA, NonGNU ELPA, and MELPA,
there are 84 hits for "table" and 16 hits for "ascii", there
is even a package called ascii-table,
https://github.com/lassik/emacs-ascii-table
Maybe that is what you look for?
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-10-12 21:05 ASCII Tables with row and colspans Ag Ibragimov
2023-10-13 12:02 ` Ihor Radchenko
@ 2023-10-19 6:46 ` Visuwesh
2023-11-03 10:20 ` Jean Louis
2 siblings, 0 replies; 12+ messages in thread
From: Visuwesh @ 2023-10-19 6:46 UTC (permalink / raw)
To: Ag Ibragimov; +Cc: emacs-devel
[வியாழன் அக்டோபர் 12, 2023] Ag Ibragimov wrote:
> 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).
>
I am not sure how far this can go but perhaps you can use shr.el to
render the table with a monospace font (seems to be necessary) with the
table character changed appropriately. However, as shr inserts space
character with appropriately calculated space display properties, you
need to end up doing post processing to change the display properties
into actual space characters.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-10-12 21:05 ASCII Tables with row and colspans Ag Ibragimov
2023-10-13 12:02 ` Ihor Radchenko
2023-10-19 6:46 ` Visuwesh
@ 2023-11-03 10:20 ` Jean Louis
2023-11-03 16:09 ` Emanuel Berg
2 siblings, 1 reply; 12+ messages in thread
From: Jean Louis @ 2023-11-03 10:20 UTC (permalink / raw)
To: Ag Ibragimov; +Cc: emacs-devel
This may not be what you want, but is probably related:
Emacs Lisp: rcd-box.el package for table drawings:
https://hyperscope.link/7/3/9/8/1/Emacs-Lisp-rcd-box-el-package-for-table-drawings-73981.html
(rcd-box-table '(("NAME" "PHONE")
("John" "+4412334566"))) ➜ "
╔══════╦═════════════╗
║ NAME ║ PHONE ║
╠══════╬═════════════╣
║ John ║ +4412334566 ║
╚══════╩═════════════╝
"
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-11-03 10:20 ` Jean Louis
@ 2023-11-03 16:09 ` Emanuel Berg
2023-11-03 19:12 ` [External] : " Drew Adams
2023-11-08 6:13 ` Jean Louis
0 siblings, 2 replies; 12+ messages in thread
From: Emanuel Berg @ 2023-11-03 16:09 UTC (permalink / raw)
To: emacs-devel
Jean Louis wrote:
> This may not be what you want, but is probably related:
>
> Emacs Lisp: rcd-box.el package for table drawings:
> https://hyperscope.link/7/3/9/8/1/Emacs-Lisp-rcd-box-el-package-for-table-drawings-73981.html
>
> (rcd-box-table '(("NAME" "PHONE")
> ("John" "+4412334566"))) → "
> ╔══════╦═════════════╗
> ║ NAME ║ PHONE ║
> ╠══════╬═════════════╣
> ║ John ║ +4412334566 ║
> ╚══════╩═════════════╝
Pretty table!
But international phone numbers are written like this
+49 69 11651
Don't believe me? Just check ITU-T E.123
https://www.itu.int/rec/T-REC-E.123-200102-I
:)
PS. +44 is the UK BTW, so John is a good example indeed.
+49 is Germany - Heinrich.
PPS. Again, see if this does what the OP wants:
https://github.com/lassik/emacs-ascii-table
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [External] : Re: ASCII Tables with row and colspans
2023-11-03 16:09 ` Emanuel Berg
@ 2023-11-03 19:12 ` Drew Adams
2023-11-03 19:27 ` Emanuel Berg
2023-11-08 6:13 ` Jean Louis
1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2023-11-03 19:12 UTC (permalink / raw)
To: Emanuel Berg, emacs-devel@gnu.org
> But international phone numbers are written like this
>
> +49 69 11651
>
> Don't believe me? Just check ITU-T E.123
> https://www.itu.int/rec/T-REC-E.123-200102-I
Interesting. But I don't see that format there.
I see these instead: +49 691 1651, +49 6 91 16 51.
Maybe the space chars aren't part of the format
specification?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Re: ASCII Tables with row and colspans
2023-11-03 19:12 ` [External] : " Drew Adams
@ 2023-11-03 19:27 ` Emanuel Berg
2023-11-04 15:17 ` Eric S Fraga
0 siblings, 1 reply; 12+ messages in thread
From: Emanuel Berg @ 2023-11-03 19:27 UTC (permalink / raw)
To: emacs-devel
Drew Adams wrote:
>> But international phone numbers are written like this
>>
>> +49 69 11651
>>
>> Don't believe me? Just check ITU-T E.123
>> https://www.itu.int/rec/T-REC-E.123-200102-I
>
> Interesting. But I don't see that format there.
> I see these instead: +49 691 1651, +49 6 91 16 51.
Weird, + (or 00) is the international prefix, 49 is the
country (Germany), 69 is the national destination (Frankfurt)
and 11651 the individual subscriber.
> Maybe the space chars aren't part of the
> format specification?
But without the spaces they are just a bunch of numbers
in sequence.
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Re: ASCII Tables with row and colspans
2023-11-03 19:27 ` Emanuel Berg
@ 2023-11-04 15:17 ` Eric S Fraga
2023-11-05 15:53 ` Emanuel Berg
0 siblings, 1 reply; 12+ messages in thread
From: Eric S Fraga @ 2023-11-04 15:17 UTC (permalink / raw)
To: emacs-devel
On Friday, 3 Nov 2023 at 20:27, Emanuel Berg wrote:
> Weird, + (or 00) is the international prefix, 49 is the
> country (Germany), 69 is the national destination (Frankfurt)
> and 11651 the individual subscriber.
In the UK, the "national destination" can be anything from 2 digits to 4
digits yet all phone numbers are the same length overall (10 digits).
--
Eric S Fraga via gnus (Emacs 30.0.50 2023-09-14) on Debian 12.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [External] : Re: ASCII Tables with row and colspans
2023-11-04 15:17 ` Eric S Fraga
@ 2023-11-05 15:53 ` Emanuel Berg
0 siblings, 0 replies; 12+ messages in thread
From: Emanuel Berg @ 2023-11-05 15:53 UTC (permalink / raw)
To: emacs-devel
Eric S Fraga wrote:
>> Weird, + (or 00) is the international prefix, 49 is the
>> country (Germany), 69 is the national destination
>> (Frankfurt) and 11651 the individual subscriber.
>
> In the UK, the "national destination" can be anything from 2
> digits to 4 digits yet all phone numbers are the same length
> overall (10 digits).
Bloody clever system!
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: ASCII Tables with row and colspans
2023-11-03 16:09 ` Emanuel Berg
2023-11-03 19:12 ` [External] : " Drew Adams
@ 2023-11-08 6:13 ` Jean Louis
1 sibling, 0 replies; 12+ messages in thread
From: Jean Louis @ 2023-11-08 6:13 UTC (permalink / raw)
To: emacs-devel
* Emanuel Berg <incal@dataswamp.org> [2023-11-03 21:41]:
> Jean Louis wrote:
>
> > This may not be what you want, but is probably related:
> >
> > Emacs Lisp: rcd-box.el package for table drawings:
> > https://hyperscope.link/7/3/9/8/1/Emacs-Lisp-rcd-box-el-package-for-table-drawings-73981.html
> >
> > (rcd-box-table '(("NAME" "PHONE")
> > ("John" "+4412334566"))) → "
> > ╔══════╦═════════════╗
> > ║ NAME ║ PHONE ║
> > ╠══════╬═════════════╣
> > ║ John ║ +4412334566 ║
> > ╚══════╩═════════════╝
>
> Pretty table!
>
> But international phone numbers are written like this
>
> +49 69 11651
>
> Don't believe me? Just check ITU-T E.123
>
> https://www.itu.int/rec/T-REC-E.123-200102-I
Just fee the `rcd-box-table' how you wish.
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-11-08 6:13 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-12 21:05 ASCII Tables with row and colspans Ag Ibragimov
2023-10-13 12:02 ` Ihor Radchenko
2023-10-19 2:13 ` Ag Ibragimov
2023-10-19 3:21 ` Emanuel Berg
2023-10-19 6:46 ` Visuwesh
2023-11-03 10:20 ` Jean Louis
2023-11-03 16:09 ` Emanuel Berg
2023-11-03 19:12 ` [External] : " Drew Adams
2023-11-03 19:27 ` Emanuel Berg
2023-11-04 15:17 ` Eric S Fraga
2023-11-05 15:53 ` Emanuel Berg
2023-11-08 6:13 ` Jean Louis
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).