Re: Relating multiple index entries to one table item

Arsen Arsenović <[email protected]>
Newsgroups gmane.comp.tex.texinfo.general
Message-ID <[email protected]>
Hi,

Gavin Smith <[email protected]> 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ć
signature.asc (application/pgp-signature, 381 B)
-----BEGIN PGP SIGNATURE-----

iOYEARYKAI4WIQT+4rPRE/wAoxYtYGFSwpQwHqLEkwUCY36cbl8UgAAAAAAuAChp
c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0RkVF
MkIzRDExM0ZDMDBBMzE2MkQ2MDYxNTJDMjk0MzAxRUEyQzQ5MxAcYXJzZW5AYWFy
c2VuLm1lAAoJEFLClDAeosST+gQBAKk7FRAkaAOEpzPzdo2mvkX3ir07Hx44hgjb
Gtste9KRAP0R6jmjV8E9dvPLk9aHtCAKiEPTNRG5KAFKI5CqRobMDw==
=+0zD
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.