help-texinfo
[Top][All Lists]
Advanced

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

Re: Relating multiple index entries to one table item


From: Arsen Arsenović
Subject: Re: Relating multiple index entries to one table item
Date: Wed, 23 Nov 2022 23:00:29 +0100

Hi,

Gavin Smith <gavinsmith0123@gmail.com> writes:

> I've been working on this, and with my current code I have, with the
> following input:
>
>     @table @asis
>     @item AAA
>     @itemx BBB
>     @vindex index1
>     @vindex index2
>     @vindex index3
>     Hello
>     
>     @end table
>
> the following output:
>
>    <dl class="table">
>    <dt id='index-index1'><span>AAA<br>BBB<a class="index-entry-id" 
> id="index-index2"></a>
>    <a class="index-entry-id" id="index-index3"></a>
>    <a class="copiable-link" href='#index-index1'> &para;</a></span></dt>
>    <dd><p>Hello
>    </p>
>    </dd>
>    </dl>
>
> (I have not sent my work-in-progress code because I doubt anybody wants to
> see it.)
>
> I think this works well, apart from the treatment of @itemx, which is no
> longer its own <dt> element, which is questionable.  There may be
> better ways than simply separating the @item and @itemx output with <br>.
> I couldn't easily find documentation of the HTML <dl> that said it was
> okay to have two <dt> elements following each other.

From the MDN (emphasis mine):

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dl

  Either: Zero or more groups each consisting of *ONE OR MORE* <dt>
  elements followed by one or more <dd> elements, optionally intermixed
  with <script> and <template> elements.
  
  Or: (in WHATWG HTML, W3C HTML 5.2 and later) One or more <div>
  elements, optionally intermixed with <script> and <template> elements.

The W3C validator appears to agree too.

> For reference, the output before this change was
>
> <dl class="table">
> <dt>AAA</dt>
> <dt>BBB</dt>
> <dd><a class="index-entry-id" id="index-index1"></a>
> <a class="index-entry-id" id="index-index2"></a>
> <a class="index-entry-id" id="index-index3"></a>
> <p>Hello
> </p>
> </dd>
> </dl>
>
> which doesn't have the copiable link (which may be a good thing, if
> the document author doesn't want this), but the anchors will scroll
> the page to after the <dt> headings, leaving them not visible.

This seems like a large improvement already to the existing usage
patterns already, thank you!

> I made this change by adding a new conversion for the 'table_term' type
> in HTML.pm, which outputs the <dt>, so that everything inside the
> 'table_term' (@item, @itemx and @?index) is output inside the <dt>.
>
> This might be the wrong way of approaching this (hence my not sharing the
> code).  If both @item and @itemx should produce their own <dt>, but they
> are both children of the same 'table_term', then something else would need
> to be done to get the index entries inside one of the <dt> elements.

Maybe it'd be appropriate to "bubble up" all indices that immediately
follow an @item[x] to an item?  Though, I'm a bit worried that'd confuse
the parser if a solution that involves @XXindex abc \n @item abc \n was
added (and I do think a generalized version of the high-quality output
that @vtable/@ftable produce would be very valuable).

Thanks.
-- 
Arsen Arsenović

Attachment: signature.asc
Description: PGP signature


reply via email to

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