Commit 95fc377e authored by Wendell Piez's avatar Wendell Piez
Browse files

Adding inline markup to supplement paragraph-level styling, addressing issue #3

parent b4769a21
......@@ -56,6 +56,39 @@
<xsl:comment> implicit </xsl:comment>
</note>
</xsl:template>
<!-- target element types are -after- mapping of inlines as elsewhere in this XSLT
i -> em, b -> strong etc. -->
<xsl:variable as="element()+" name="mapped-styles">
<em>font-style: italic</em>
<strong>font-weight: bold</strong>
<i>text-decoration: underline</i>
</xsl:variable>
<xsl:template match="p">
<xsl:variable name="signals" select="xsw:style-propertyValues(.)[.=$mapped-styles]"/>
<xsl:variable name="me" select="."/>
<xsl:variable name="mine">
<xsl:apply-templates/>
</xsl:variable>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:iterate select="$mapped-styles[. = $signals]">
<xsl:param name="contents" select="$mine"/>
<xsl:on-completion>
<xsl:sequence select="$contents"/>
</xsl:on-completion>
<xsl:next-iteration>
<xsl:with-param name="contents">
<xsl:element name="{name(.)}" namespace="http://www.w3.org/1999/xhtml">
<xsl:sequence select="$contents"/>
</xsl:element>
</xsl:with-param>
</xsl:next-iteration>
</xsl:iterate>
</xsl:copy>
</xsl:template>
<!-- Any 'i' element becomes an 'em' element; its attributes are copied. -->
<!-- (Unwanted attributes can be removed in a subsquent step.) -->
......@@ -108,4 +141,14 @@
</extract>
</xsl:template>
<xsl:function name="xsw:style-propertyValues" as="xs:string*">
<!-- Returns 'font-family: Helvetica','font-size: 10pt' whatever
properties are defined on @style -->
<xsl:param name="e" as="element()"/>
<xsl:sequence select="tokenize($e/@style/normalize-space(.),'\s*;\s*')"/>
</xsl:function>
<xsl:key name="elements-by-propertyValue" match="*[matches(@style,'\S')]" use="xsw:style-propertyValues(.)"/>
</xsl:stylesheet>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment