Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite292270

Browse files
committed
doc: Make HTML ids discoverable
In the HTML output, this decorates section headers and variable listterms with a marker ("#") that is a link to the same section/term.That way, links inside a page can be discovered for easier sharing.The marker only appears when hovering.This now requires that all elements that are candidates for such alink have an id attribute. Otherwise, an error will be generated.All previously missing ids have been added prior to this patch.Author: Brar Piening <brar@gmx.de>Reviewed-by: Karl O. Pinc <kop@karlpinc.com>Discussion:https://www.postgresql.org/message-id/flat/CAB8KJ=jpuQU9QJe4+RgWENrK5g9jhoysMw2nvTN_esoOU0=a_w@mail.gmail.com
1 parenta34901d commite292270

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

‎doc/src/sgml/stylesheet-html-common.xsl‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,131 @@ set toc,title
309309
</xsl:choose>
310310
</xsl:template>
311311

312+
313+
<!-- Add an id link to each section heading.-->
314+
315+
<!-- from html/sections.xsl-->
316+
<xsl:templatename="section.heading">
317+
<xsl:paramname="section"select="."/>
318+
<xsl:paramname="level"select="1"/>
319+
<xsl:paramname="allow-anchors"select="1"/>
320+
<xsl:paramname="title"/>
321+
<xsl:paramname="class"select="'title'"/>
322+
323+
<xsl:variablename="id">
324+
<xsl:choose>
325+
<!-- Make sure the subtitle doesn't get the same id as the title-->
326+
<xsl:whentest="self::subtitle">
327+
<xsl:call-templatename="object.id">
328+
<xsl:with-paramname="object"select="."/>
329+
</xsl:call-template>
330+
</xsl:when>
331+
<!-- if title is in an *info wrapper, get the grandparent-->
332+
<xsl:whentest="contains(local-name(..), 'info')">
333+
<xsl:call-templatename="object.id">
334+
<xsl:with-paramname="object"select="../.."/>
335+
</xsl:call-template>
336+
</xsl:when>
337+
<xsl:otherwise>
338+
<xsl:call-templatename="object.id">
339+
<xsl:with-paramname="object"select=".."/>
340+
</xsl:call-template>
341+
</xsl:otherwise>
342+
</xsl:choose>
343+
</xsl:variable>
344+
345+
<!-- HTML H level is one higher than section level-->
346+
<xsl:variablename="hlevel">
347+
<xsl:choose>
348+
<!-- highest valid HTML H level is H6; so anything nested deeper
349+
than 5 levels down just becomes H6-->
350+
<xsl:whentest="$level&gt; 5">6</xsl:when>
351+
<xsl:otherwise>
352+
<xsl:value-ofselect="$level + 1"/>
353+
</xsl:otherwise>
354+
</xsl:choose>
355+
</xsl:variable>
356+
<xsl:elementname="h{$hlevel}"namespace="http://www.w3.org/1999/xhtml">
357+
<xsl:attributename="class"><xsl:value-ofselect="$class"/></xsl:attribute>
358+
<xsl:iftest="$css.decoration != '0'">
359+
<xsl:iftest="$hlevel&lt;3">
360+
<xsl:attributename="style">clear: both</xsl:attribute>
361+
</xsl:if>
362+
</xsl:if>
363+
<xsl:iftest="$allow-anchors != 0">
364+
<xsl:call-templatename="anchor">
365+
<xsl:with-paramname="node"select="$section"/>
366+
<xsl:with-paramname="conditional"select="0"/>
367+
</xsl:call-template>
368+
</xsl:if>
369+
<xsl:copy-ofselect="$title"/>
370+
<!-- pgsql-docs: begin-->
371+
<xsl:call-templatename="pg.id.link">
372+
<xsl:with-paramname="object"select="$section"/>
373+
</xsl:call-template>
374+
<!-- pgsql-docs: end-->
375+
</xsl:element>
376+
</xsl:template>
377+
378+
379+
<!-- Add an id link after the last term of a varlistentry.-->
380+
381+
<!-- overrides html/lists.xsl-->
382+
<xsl:templatematch="varlistentry/term">
383+
<xsl:apply-imports/>
384+
385+
<!-- Add the link after the last term-->
386+
<xsl:iftest="position() = last()">
387+
<xsl:call-templatename="pg.id.link">
388+
<xsl:with-paramname="object"select="parent::varlistentry"/>
389+
</xsl:call-template>
390+
</xsl:if>
391+
</xsl:template>
392+
393+
394+
<!-- Create a link pointing to an id within the document-->
395+
<xsl:templatename="pg.id.link">
396+
<xsl:paramname="object"select="."/>
397+
<xsl:choose>
398+
<xsl:whentest="$object/@id or $object/@xml:id">
399+
<xsl:text> </xsl:text>
400+
<a>
401+
<xsl:attributename="href">
402+
<xsl:text>#</xsl:text>
403+
<xsl:call-templatename="object.id">
404+
<xsl:with-paramname="object"select="$object"/>
405+
</xsl:call-template>
406+
</xsl:attribute>
407+
<xsl:attributename="class">
408+
<xsl:text>id_link</xsl:text>
409+
</xsl:attribute>
410+
<xsl:text>#</xsl:text>
411+
</a>
412+
</xsl:when>
413+
<xsl:otherwise>
414+
<!-- Only complain about varlistentries if at least one entry in
415+
the list has an id-->
416+
<xsl:iftest="name($object) != 'varlistentry'
417+
or $object/parent::variablelist/varlistentry[@id]">
418+
<xsl:messageterminate="yes">
419+
<xsl:text>ERROR: id attribute missing on&lt;</xsl:text>
420+
<xsl:value-of select ="name($object)"/>
421+
<xsl:text>&gt; element under </xsl:text>
422+
<xsl:for-eachselect="$object/ancestor::*">
423+
<xsl:text>/</xsl:text>
424+
<xsl:value-of select ="name(.)"/>
425+
<xsl:iftest="@id|@xml:id">
426+
<xsl:text>[@</xsl:text>
427+
<xsl:value-of select ="name(@id|@xml:id)"/>
428+
<xsl:text> = '</xsl:text>
429+
<xsl:value-of select ="@id"/>
430+
<xsl:text>']</xsl:text>
431+
</xsl:if>
432+
</xsl:for-each>
433+
</xsl:message>
434+
</xsl:if>
435+
</xsl:otherwise>
436+
</xsl:choose>
437+
</xsl:template>
438+
312439
</xsl:stylesheet>

‎doc/src/sgml/stylesheet.css‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,14 @@ acronym{ font-style: inherit; }
169169
width:75%;
170170
}
171171
}
172+
173+
/* links to ids of headers and definition terms */
174+
175+
a.id_link {
176+
color: inherit;
177+
visibility: hidden;
178+
}
179+
180+
*:hover>a.id_link {
181+
visibility: visible;
182+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp