]> Lady’s Gitweb - Shushe/commitdiff
Improve asset transforms
authorLady <redacted>
Mon, 1 Jan 2024 19:00:12 +0000 (14:00 -0500)
committerLady <redacted>
Tue, 2 Jan 2024 18:26:59 +0000 (13:26 -0500)
This commit converts `audio/*`, `image/*` and `video/*` embeds to their
appropriate H·T·M·L element, enables inline `<html:style>`s, and
improves the handling of `text/css` embeds.

README.markdown
transforms/asset.xslt
transforms/metadata.xslt

index 893ac2c47230e55c4e2b59e93f31553dc25d5145..5b5b84c458c5103e9e748ae29a362255fa84a224 100644 (file)
@@ -277,13 +277,10 @@ Transforms are used to convert X·M·L files into their final output,
 ⛩️📰 书社 comes with some transforms; namely :⁠—
 
 - **`transforms/asset.xslt`:**
-  Converts `<html:object type="text/css">` elements into corresponding
-    `<html:link rel="stylesheet">` elements and
-    `<html:object type="text/javascript">` elements into corresponding
-    `<html:script>` elements.
-  This transform enables embedding of `text/css` and `text/javascript`
-    files, which ordinarily are considered assets (as they lack
-    associated parsers).
+  Converts `<html:object>` elements which correspond to recognized
+    media types into the appropriate H·T·M·L elements, and deletes
+    `<html:style>` elements from the body of the document and moves
+    them to the head.
 
 - **`transforms/metadata.xslt`:**
   Provides basic `<html:head>` metadata.
index 90c8dbd0b420f93fc48bfbe28ac80f928d2c88cc..0242f435a688f567af665e6761f792a0e36c6db9 100644 (file)
@@ -9,22 +9,33 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
 -->
 <transform
        xmlns="http://www.w3.org/1999/XSL/Transform"
+       xmlns:exsl="http://exslt.org/common"
        xmlns:html="http://www.w3.org/1999/xhtml"
+       xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
-       exclude-result-prefixes="书社"
+       exclude-result-prefixes="exsl"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:asset.xslt</书社:id>
-       <template match="html:object[@type='text/css']">
-               <comment>
-                       <text>[书社:CSS] </text>
-                       <value-of select="@data"/>
-               </comment>
-       </template>
-       <template match="comment()[starts-with(., '[书社:CSS] ')]" mode="书社:metadata">
-               <html:link rel="stylesheet" type="text/css" href="{substring-after(., '[书社:CSS] ')}"/>
-       </template>
+       <template match="html:style|html:object[@type='text/css']"/>
        <template match="html:object[@type='text/javascript']">
                <html:script type="{@type}" src="{@data}"/>
        </template>
+       <template match="html:object[starts-with(@type, 'audio/')]">
+               <html:audio controls="" src="{@data}"/>
+       </template>
+       <template match="html:object[starts-with(@type, 'image/') and not(@type='image/svg+xml')]">
+               <html:img src="{@data}"/>
+       </template>
+       <template match="html:object[starts-with(@type, 'video/')]">
+               <html:video controls="" src="{@data}"/>
+       </template>
+       <template match="xslt:include[@书社:id='urn:fdc:ladys.computer:20231231:Shu1She4:asset.xslt']" mode="书社:metadata">
+               <for-each select="exsl:node-set($书社:expansion)//html:object[@type='text/css']">
+                       <html:link rel="stylesheet" type="text/css" href="{@data}"/>
+               </for-each>
+               <for-each select="exsl:node-set($书社:expansion)//html:style">
+                       <copy-of select="."/>
+               </for-each>
+       </template>
 </transform>
index b5f180fef3391af1d00a2947afa524856229a9af..ac618fd613fc164f1e8e966eea0067857a976b13 100644 (file)
@@ -15,7 +15,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        xmlns="http://www.w3.org/1999/XSL/Transform"
        xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
-       exclude-result-prefixes="书社"
        version="1.0"
 >
        <书社:id>urn:fdc:ladys.computer:20231231:Shu1She4:metadata.xslt</书社:id>
This page took 0.029746 seconds and 4 git commands to generate.