TEIC / Stylesheets

TEI XSL Stylesheets
234 stars 125 forks source link

Add permalink for examples #471

Closed hcayless closed 3 years ago

hcayless commented 4 years ago

See TEIC/TEI#1931.

We want to add a link on each example making it easy to obtain a URL directly to that example. Examples already have IDs, making that straightforward. The links should point at a particular version of the GLs rather than "current".

Also see #470, so that if someone bookmarks one of these links and visits it, they see a message alerting them that they have visited an older version.

martindholmes commented 3 years ago

@npcole @sydb and I discussed this, and we think the best approach is:

  1. Use the existing ids generated as part of the HTML build process to create a pilcrow anchor.
  2. In the processing, check whether the <egXML> already has an @xml:id, and if it does, use that instead, so that if a policy of adding stable @xml:ids to all <egXMLs> is instituted, the processing will make appropriate use of them.
  3. Shelve the idea of checking whether you're looking at an old version or not; that can best be accomplished by JS checking the access URL, and is nice-to-have but not essential at this stage.
  4. Consider instituting the same process for <eg>s.
sydb commented 3 years ago

The relevant code that generates ¶ links for sections of the Guidelines, and thus we would probably want to copy-and-modify or make a subroutine out of, is in guidelines.xsl, starting at line ~678:

      <span class="bookmarklink">
        <a class="bookmarklink" href="#{$ident}">
          <xsl:attribute name="title">
            <xsl:text>link to this section </xsl:text>
          </xsl:attribute>
          <span class="invisible">
            <xsl:text>TEI: </xsl:text>
            <xsl:value-of select="tei:head[1]"/>
          </span>
          <span class="pilcrow">
            <xsl:text>¶</xsl:text>
          </span>
        </a>
      </span>
martindholmes commented 3 years ago

Stylesheets group today implemented this for most examples (prose and spec pages), but we still have to make it happen in the examples pages ("Show all"). We also need to look at egXMLEndHook, where the link text "bibliography" is hard-coded, when it should actually be an i18n call. This will be the subject of a second ticket.