File 0716-erl_docgen-Fix-highlight-js-bug-on-pages-with-id-exp.patch of Package erlang

From a1c2c28f4ebbcbbdbe3403527990465901c927ea Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 10 Nov 2021 15:42:29 +0100
Subject: [PATCH 1/3] erl_docgen: Fix highlight js bug on pages with id=export

Due to a quirk in JS (where it creates global variables
containing the object that the id points to) the hljs
crashed when starting which caused some pages to be
rendered without syntax highlighting. For example
erl_error.
---
 lib/erl_docgen/priv/xsl/db_html.xsl | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lib/erl_docgen/priv/xsl/db_html.xsl b/lib/erl_docgen/priv/xsl/db_html.xsl
index 730c5d1447..b77fe98318 100644
--- a/lib/erl_docgen/priv/xsl/db_html.xsl
+++ b/lib/erl_docgen/priv/xsl/db_html.xsl
@@ -90,7 +90,20 @@
 
   <func:function name="erl:to-link">
     <xsl:param name="text"/>
-    <func:result select="translate(erl:lower-case($text),'?: /()&quot;&#10;','--------')"/>
+    <xsl:variable name="link" select="translate(erl:lower-case($text),'?: /()&quot;&#10;','--------')"/>
+    <func:result>
+        <xsl:choose>
+            <!-- Stupid JS does not want us to have html elements with id="exports".
+                 If we do, then highlight.js breaks because it uses the 'exports'
+                 variable to do JS module things. See:
+                 https://github.com/googlearchive/observe-js/issues/81
+                 for more details on this very frustrating issue... -->
+            <xsl:when test="$link = 'exports'">export</xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="$link"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </func:result>
   </func:function>
 
   <!-- Used from template menu.funcs to sort a module's functions for the lefthand index list,
-- 
2.31.1

openSUSE Build Service is sponsored by