From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1567040-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A3B91158089 for <garchives@archives.gentoo.org>; Tue, 31 Oct 2023 20:03:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 80D632BC163; Tue, 31 Oct 2023 20:03:18 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5F4A82BC163 for <gentoo-commits@lists.gentoo.org>; Tue, 31 Oct 2023 20:03:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 44D59335D0A for <gentoo-commits@lists.gentoo.org>; Tue, 31 Oct 2023 20:03:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E65A5130A for <gentoo-commits@lists.gentoo.org>; Tue, 31 Oct 2023 20:03:15 +0000 (UTC) From: "Ulrich Müller" <ulm@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" <ulm@gentoo.org> Message-ID: <1698782516.75aab18b528a3b76355da6fc6b36e4c6635375b8.ulm@gentoo> Subject: [gentoo-commits] proj/devmanual:master commit in: / X-VCS-Repository: proj/devmanual X-VCS-Files: devbook.xsl X-VCS-Directories: / X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 75aab18b528a3b76355da6fc6b36e4c6635375b8 X-VCS-Branch: master Date: Tue, 31 Oct 2023 20:03:15 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 179387a1-7159-4e08-aac0-ebbb5d3f750f X-Archives-Hash: d1de180575382b85782850f1a79d7b7d commit: 75aab18b528a3b76355da6fc6b36e4c6635375b8 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Mon Oct 30 16:13:38 2023 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Tue Oct 31 20:01:56 2023 +0000 URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=75aab18b devbook.xsl: Update the findNext template for relative links Create relative links with correct depth. Some other simplifications. Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> devbook.xsl | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/devbook.xsl b/devbook.xsl index 8d4e1df..668fa01 100644 --- a/devbook.xsl +++ b/devbook.xsl @@ -774,28 +774,16 @@ <!-- If we have an item after us, or we are at the root node (termination condition) we need to not recurse any further... --> <xsl:when test="$parentItem_lookup != '' or document(concat($self, '../text.xml'))/guide/@root"> - <xsl:variable name="parentItem_actual"> - <xsl:choose> - <xsl:when test="$parentItem_next = ''"></xsl:when> - <xsl:otherwise><xsl:value-of select="$parentItem_next"/></xsl:otherwise> - </xsl:choose> - </xsl:variable> - <!-- This is where we do a little trickery. To count how many levels - we need to go down, we count how far up we currently are - (remember that the absolute link we get is relative to /...) - and hence we can build a relative link... --> - <xsl:variable name="relative_path" select="$parentItem_actual"/> - <xsl:variable name="relative_path_depth" - select="string-length(/guide/@self) - string-length(translate(/guide/@self, '/' , ''))"/> - <xsl:variable name="relative_path_depth_recursion"> - <xsl:call-template name="str:repeatString"> - <xsl:with-param name="count" select="$relative_path_depth"/> - <xsl:with-param name="append">../</xsl:with-param> + <!-- Compute a relative path for the link. --> + <xsl:variable name="path_rel"> + <xsl:call-template name="relative-path"> + <xsl:with-param name="path" select="$parentItem_next"/> + <xsl:with-param name="self" select="/guide/@self"/> </xsl:call-template> </xsl:variable> - <a class="w-250 text-center" href="{concat($relative_path_depth_recursion, $relative_path, 'index.html')}"> + <a class="w-250 text-center" href="{concat($path_rel, 'index.html')}"> <span class="truncated-text d-inline-block max-w-200 mr-2"> - <xsl:value-of select="document(concat($parentItem_actual, 'text.xml'))/guide/chapter[1]/title"/> + <xsl:value-of select="document(concat($parentItem_next, 'text.xml'))/guide/chapter[1]/title"/> </span> <span class="fa fa-arrow-right"/> </a> @@ -803,11 +791,9 @@ <xsl:otherwise> <!-- We need to recurse downwards; so we need to strip off a directory element off our absolute path to feed into the next iteration... --> - <xsl:variable name="relative_path_depth" - select="string-length($self) - string-length(translate($self, '/' , ''))"/> <xsl:variable name="relative_path_fixed"> - <xsl:for-each select="str:tokenize_plasmaroo($self, '/')[position() < (($relative_path_depth - 1)*2 + 1)]"> - <xsl:value-of select="."/> + <xsl:for-each select="str:tokenize($self, '/')[position() < last()]"> + <xsl:value-of select="concat(., '/')"/> </xsl:for-each> </xsl:variable> <xsl:call-template name="findNext">