W3C home > Mailing lists > Public > public-digipub@w3.org > August 2015

Re: Cross-References in GCPM (was: CSS Pages and Pagination)

From: Håkon Wium Lie <howcome@opera.com>
Date: Sun, 9 Aug 2015 13:50:47 +0200
Message-ID: <21959.16023.203232.247103@mail.wiumlie.no>
To: Sanders Kleinfeld <sanders@oreilly.com>
Cc: Daniel Glazman <daniel.glazman@disruptive-innovations.com>, public-digipub <public-digipub@w3.org>
Sanders Kleinfeld wrote:

 > Re: cross-references, the main use case I would love to see covered is
 > the ability to automatically customize the text content based on the
 > type of element that is being linked to. So for example, if we had
 > markup like the following:
 > 
 > <section>
 >   <h1 id="a_section">The First section title</h1>
 >   <p>Some text here</p>
 >    <figure id="a_figure">
 >       <figcaption>An interesting icon</figcaption>
 >       <img src="icon.gif"/>
 >    </figure>
 > 
 >    <p>In <a href="#a_section"/>, we have some cross references.</p>
 >    <p>In <a href="#a_figure"/>, we have an icon image</p>
 > </section>
 > 
 > We might want the cross-reference to the section heading (#a_section)
 > to contain the text "Section 1.1", and the cross-reference to the
 > figure caption to contain the text "Figure 1.1".

You could this by adding a class to the <a> element, e.g.:

  <a class=figref href=...>

Combined with something like:

  a.figref:before { content: "Figure: " }

But I guess you're looking for a solution where you only insert simple
<a> elements that transform themselves?

Sometimes this could lead to errors. E.g:

  See figure 2.3 on page 56. 
  Figure 2.3 on page 56 illustrates this.

That is, the spelling of figure/Figure changes, this would be tough to
adjust automatically.

Still if you want an all-automatic solution, I'd probably base it on
named strings. First, I would set a named string with:

  h1[id] { string-set: ref "Section " counter(sec) }
  figure[id] { string-set: ref "Figure " counter(fig) }

Then I would refer to it with:

  a { content: target-string(ref, attr(href url)) }

The 'target-string' function doesn't exist, yet. But I think it could work, no?

Cheers,

-h&kon
              Håkon Wium Lie                          CTO °þe®ª
howcome@opera.com                  http://people.opera.com/howcome
Received on Sunday, 9 August 2015 11:51:18 UTC

This archive was generated by hypermail 2.3.1 : Sunday, 9 August 2015 11:51:19 UTC