]> git.draconx.ca Git - homepage.git/blobdiff - layouts/embed-svg.xsl
Make archive file icon shadows visible in dark mode.
[homepage.git] / layouts / embed-svg.xsl
index 2b3f8e2a7dcd187d0fcab8c9d188927468049226..0aee04d9dcc7ef7ee7b0156b125eda24b1f7cdab 100644 (file)
@@ -2,7 +2,7 @@
 <!--
   Nick's web site: SVG embedding.
 
-  Copyright © 2021 Nick Bowler
+  Copyright © 2021-2022 Nick Bowler
 
   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
         <xsl:value-of select='concat("es-", generate-id($idnode))' />
       </xsl:attribute>
     </xsl:if>
-    <xsl:apply-templates mode='embed-svg' select='@*[local-name()!="id"]' />
+    <xsl:choose>
+      <xsl:when test='$idnode/@src and not(parent::*)'>
+        <!-- remove .svg suffix -->
+        <xsl:variable name='raw'
+          select='substring($idnode/@src, 1, string-length($idnode/@src)-4)' />
+
+        <xsl:attribute name='class'>
+          <xsl:value-of select='normalize-space(concat(@class, " embed ",
+            translate($raw, "/", " ")))' />
+        </xsl:attribute>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates mode='embed-svg' select='@class' />
+      </xsl:otherwise>
+    </xsl:if>
+    <xsl:apply-templates mode='embed-svg'
+      select='@*[local-name()!="id" and local-name()!="class"]' />
     <xsl:apply-templates mode='embed-svg' select='node()'>
       <xsl:sort select='-count(self::svg:metadata)' data-type='number' />
     </xsl:apply-templates>