webbook icon indicating copy to clipboard operation
webbook copied to clipboard

Is the ToC really a flat ordered list of resources?

Open frivoal opened this issue 8 years ago • 1 comments

The spec says the Table of Contents is build out of non hidden hyperlinks under <nav role=doc-toc>. But what is it exactly, and what is it used for. the spec says this:

User Agents can use the Table of Contents for example to provide the user with an ordered collection of resources he/she can directly navigate to on demand.

That seems a little too simple, as Table of Contents often have structure and hierarchy, and this definition forgoes that.

<nav role=doc-toc>
<ol>
  <li><a href="...">Tome 1</a>
    <ol>
      <li><a href="...">Ch1.1</a>
      <li><a href="...">Ch1.2</a>
  </ol>
  <li><a href="...">Tome 2</a>
    <ol>
      <li><a href="...">Ch2.1</a>
      <li><a href="...">Ch2.2</a>
  </ol>
</ol>
</nav>

This would be turned into a linear list: Tome 1, Ch1.1, Ch1.2, Tome 2, Ch2.1, Ch2.2. In this example, the list is short and the names reflect the hierarchy, so it is not too bad, but for a larger document it would not be very usable.

So, I think the ToC should not be a list, but it should be a tree. That way, the UA could still present a flat list if it wanted to by flattening the tree depth first, but it could also (and probably should) present it as a hierarchy, possibly with some UI to collapse sub-levels...

For example, here is a screenshot from a long & structured PDF I happen to be reading. A WebBook UA should be able to do a similar rendering of the ToC.

screenshot 2018-01-18 16 51 53

For this to be possible and interoperable given arbitrary markup, we need to define the precise algorithm to go from the DOM to the ToC tree.

I'm happy to write this in precises language if we agree on the general approach. As a general approach, I suggest:

  1. <ol>, <ul>, <dl> increase the level of nesting, nothing else does
  2. within one level of nesting all non hidden links go in document order

Possible alternative to 1: <ol>, <ul>, <dl> and sectioning content elements (article aside nav section) increase the level of nesting, nothing else does. I don't think I like this alternative, but I thought I'd just put it there for the sake of the discussion.

frivoal avatar Jan 18 '18 07:01 frivoal

This clearly collide with issue #7 and my comment there.

therealglazou avatar Jan 18 '18 09:01 therealglazou