Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the way the %p xrefstyle is formatted #551

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 59 additions & 45 deletions src/guide/xml/ch02.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ and unnumbered sections have? The mechanisms for changing this generated text ar
described in <xref linkend="gentext"/>. These mechanisms control the formatting
of cross references.</para>

<para>But it’s sometimes desirable to be able to change the format of a
<para>But it’s sometimes useful to be able to change the format of a
cross reference on an individual basis (that is, on the basis of the
context in which the <emphasis>reference</emphasis> occurs, not the
nature of what is <emphasis>referenced</emphasis>). You might, for
Expand All @@ -1080,19 +1080,20 @@ linkend="table.template-letter-substitutions"/> in
<code>xrefstyle</code>. There is also an additional
<code>%label</code> for <emphasis>the full Label</emphasis>, which is
the component`s name and number. The use of these percent-values is
explained in the following table, where all cross references target
the next section called <xref linkend="syntax-highlighting"
xrefstyle="%c"/>.</para>
explained in the following table. The result column shows how a
cross references to the section below entitled
<xref linkend="syntax-highlighting" xrefstyle="%c"/> would appear
in each <att>xrefstyle</att>.</para>

<informaltable frame="all">
<tgroup cols="3" rowsep="1" colsep="1">
<colspec colname="c1" colwidth="2*" rowsep="1"/>
<colspec colname="c1" colwidth="1*" rowsep="1"/>
<colspec colname="c2" colwidth="1*" rowsep="1"/>
<colspec colname="c3" colwidth="2*" rowsep="1"/>

<thead valign="top">
<row>
<entry>Value of <code>xref/@xrefstyle</code></entry>
<entry>Value of <att>xrefstyle</att> attribute on <tag>xref</tag></entry>
<entry>Result</entry>
<entry>Remark</entry>
</row>
Expand All @@ -1112,31 +1113,29 @@ xrefstyle="%c"/>.</para>
<row>
<entry><code>%l</code></entry>
<entry><xref linkend="syntax-highlighting" xrefstyle="%l"/></entry>
<entry>Label, ususally the targets number.</entry>
<entry>Label, usually the target’s number.</entry>
</row>
<row>
<entry><code>%label</code></entry>
<entry><xref linkend="syntax-highlighting" xrefstyle="%label"/></entry>
<entry>The full Label, ususally the targets number and name.</entry>
<entry>The full Label, usually the target’s number and name.</entry>
</row>
<row>
<entry><code>%p</code></entry>
<entry><phrase outputformat="print"><xref linkend="syntax-highlighting" xrefstyle="%p"/></phrase></entry>
<entry>Page number. Intended for print output (PDF). Displayed as <emphasis>"#"</emphasis> in HTML,
unless you differentiate between the output formats for print and online. See <xref
linkend="using-pagenumber-in-crossreferences" xrefstyle="%label"/> for a possible
solution.</entry>
<entry><xref linkend="syntax-highlighting" xrefstyle="%p"/></entry>
<entry>Page number in print output (PDF). Displays as “#” in HTML.</entry>
</row>
<row>
<entry><code>%label (%c)</code></entry>
<entry><xref linkend="syntax-highlighting" xrefstyle="%label (%c)"/></entry>
<entry>You can use different %-letters and combine with text</entry>
<entry>You can combine %-letters with text</entry>
</row>
</tbody>
</tgroup>
</informaltable>

<bridgehead>Legacy values for xrefstyle</bridgehead>
<simplesect>
<title>Legacy values for xrefstyle</title>

<para>In order to support migration from XSLT 1.0 Stylesheets, xslTNG supports the
<code>template:</code> Syntax which is explained in
Expand All @@ -1149,13 +1148,13 @@ xrefstyle="%c"/>.</para>

<informaltable frame="all">
<tgroup cols="3" colsep="1" rowsep="1">
<colspec colname="c1" colwidth="2*" rowsep="1"/>
<colspec colname="c1" colwidth="1*" rowsep="1"/>
<colspec colname="c2" colwidth="1*" rowsep="1"/>
<colspec colname="c3" colwidth="2*" rowsep="1"/>

<thead valign="top">
<row>
<entry>Value of <code>xref/@xrefstyle</code></entry>
<entry>Value of <att>xrefstyle</att> attribute on <tag>xref</tag></entry>
<entry>Result</entry>
<entry>Remark</entry>
</row>
Expand All @@ -1177,36 +1176,51 @@ xrefstyle="%c"/>.</para>
</tbody>
</tgroup>
</informaltable>
</simplesect>

<section xml:id="using-pagenumber-in-crossreferences">
<simplesect xml:id="using-pagenumber-in-crossreferences">
<title>Using pagenumber in cross-references</title>
<para>The <code>%p</code> makes little sense in HTML output, since there are no page numbers.
If you use it anyway, it will be displayed as <emphasis>"#"</emphasis>, which can be
confusing for readers. A possible solution for this problem is the use of the
<code>outputformat</code> attribute, that was intoduced in <xref linkend="profiling"/> and
<xref linkend="table.effectivity-attributes" xrefstyle="%label"/><phrase
outputformat="print"> on page <xref linkend="table.effectivity-attributes" xrefstyle="%p"
/></phrase>.</para>

<para><emphasis>This</emphasis> cross reference to <xref linkend="syntax-highlighting"
xrefstyle="%label"/>
<phrase outputformat="print"> on <xref linkend="syntax-highlighting" xrefstyle="page %p"
/></phrase> will include the target`s page number only when the
<code>@profile.outputformat</code> parameter is <emphasis>"print"</emphasis>, but without
the annoying <emphasis>#</emphasis> in HTML.</para>

<example>
<title>Use outputformat to deal with page numbers in cross references</title>
<programlisting>This cross reference to
&lt;xref linkend=&quot;syntax-highlighting&quot; xrefstyle="%label/&gt;
&lt;phrase outputformat=&quot;print&quot;&gt;
on &lt;xref linkend=&quot;syntax-highlighting&quot; xrefstyle=&quot;page %p&quot;/&gt;
&lt;/phrase&gt;
will reference the page number only when the
@profile.outputformat parameter is print, but
without the annoying # in HTML.</programlisting>
</example>
</section>

<para>The <code>%p</code> value in <tag class="attribute">xrefstyle</tag> makes
little sense in HTML output, since there are no page numbers. If you use it
anyway, it will be displayed as
“<phrase outputformat="online"
><xref linkend="using-pagenumber-in-crossreferences" xrefstyle="%p"
/></phrase><phrase outputformat="print"
><link linkend="using-pagenumber-in-crossreferences">#</link></phrase>”.
This may be confusing for readers. A possible solution for this problem is the use of
the <code>outputformat</code> attribute. For example:</para>

<informalexample>
<blockquote>
<para>The <code>outputformat</code> attribute was intoduced in
<xref linkend="profiling"/> and
<xref linkend="table.effectivity-attributes" xrefstyle="%label"
/><phrase outputformat="print"> on page
<xref linkend="table.effectivity-attributes" xrefstyle="%p"
/></phrase>.
</para>
</blockquote>
</informalexample>

<para>The paragraph markup in that example is:</para>

<example>
<title>Use outputformat to deal with page numbers in cross references</title>
<programlisting><![CDATA[<para>The <code>outputformat</code> attribute was intoduced in
<xref linkend="profiling"/> and
<xref linkend="table.effectivity-attributes" xrefstyle="%label"
/><phrase outputformat="print"> on page
<xref linkend="table.effectivity-attributes" xrefstyle="%p"
/></phrase>.
</para>]]></programlisting>
</example>

<para>Where the page number appears in the print version, but not in the HTML version.
Note that some care has been taken with line breaks and spaces around markup
to avoid extraneous whitespace in either version.
</para>
</simplesect>
</section>

<section xml:id="syntax-highlighting">
Expand Down
5 changes: 0 additions & 5 deletions src/main/scss/media-all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,6 @@ a.pmuj {
font-style: italic;
}

.xref-pagenum {
content: target-counter(attr(href), page);
font-style:normal;
}

.xref-area,
.xref-areaset,
.xref-co,
Expand Down
7 changes: 7 additions & 0 deletions src/main/scss/media-paged.scss
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ span.footnote p {
padding-top: 0;
margin-top: 0;
}

/* xref with pagenumber ====================================== */

.xref-pagenum::after {
content: target-counter(attr(href), page);
font-style:normal;
}
7 changes: 7 additions & 0 deletions src/main/scss/media-screen.scss
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ nav.top div {

/* ============================================================ */

@media screen {
.xref-pagenum::after {
content: "#";
font-style:normal;
}
}

@media screen and (max-width: 1199px) {
nav.top div {
padding-left: 2rem;
Expand Down
2 changes: 1 addition & 1 deletion src/main/xslt/modules/links.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
group-adjacent=". instance of node() and local-name() = ('pagenum')">
<xsl:choose>
<xsl:when test="boolean(current-grouping-key())">
<a href="#{f:id($target)}" class="xref xref-{local-name($target)} xref-{local-name(.)}">#</a>
<a href="#{f:id($target)}" class="xref xref-{local-name($target)} xref-{local-name(.)}"/>
</xsl:when>
<xsl:otherwise>
<a href="#{f:id($target)}" class="xref xref-{local-name($target)}">
Expand Down
Loading
Loading