Commit 6d4cc2b9 authored by Wendell Piez's avatar Wendell Piez
Browse files

Latest adjustments for quotation handling

parent c02a9b11
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY lsquo "&#x2018;" >
<!ENTITY rsquo "&#x2019;" >
<!ENTITY ldquo "&#x201c;" >
<!ENTITY rdquo "&#x201d;" >
]>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
......@@ -18,8 +25,7 @@
<!-- Output: A copy of the input, with text munges and other "tuning" -->
<!-- Limitation: Doesn't discriminate between ws that is "safe to munge" (eg paragraph content) and "significant" ws (eg code blocks or ASCII art): this will treat all text indiscriminately. -->
<xsl:output method="xml" omit-xml-declaration="yes"
encoding="us-ascii"/>
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:mode on-no-match="shallow-copy"/>
......@@ -152,6 +158,18 @@
</xsl:apply-templates>
</xsl:template>
<!--<xsl:template match="body//text()">
<text>
<i><xsl:value-of select="."/></i>
<o>
<xsl:apply-templates select="$operations">
<xsl:with-param name="original" select="."/>
</xsl:apply-templates>
</o>
</text>
</xsl:template>-->
<!-- passing through ws-only -->
<xsl:template match="text()[not(matches(.,'\S'))]" priority="10">
<xsl:value-of select="."/>
......@@ -332,16 +350,17 @@
</xsl:choose>
</xsl:template>
<xsl:variable name="quot" as="xs:string">"</xsl:variable>
<xsl:variable name="apos" as="xs:string">'</xsl:variable>
<xsl:variable name="quot" as="xs:string">"</xsl:variable>
<xsl:variable name="apos" as="xs:string">'</xsl:variable>
<!--<xsl:variable name="quotapos" as="xs:string">['"]</xsl:variable>-->
<xsl:variable name="quote-operations" as="element(xsw:sequence)" expand-text="true">
<xsw:sequence>
<!-- Insert hair spaces btw pairs of quotation marks -->
<!--<xsw:match replace="&#x2018;&#x200a;&#x201c;">&#x2018;&#x201c;</xsw:match>
<xsw:match replace="&#x201c;&#x200a;&#x2018;">&#x201c;&#x2018;</xsw:match>
<xsw:match replace="&#x2019;&#x200a;&#x201d;">&#x2019;&#x201d;</xsw:match>
<xsw:match replace="&#x2019;&#x200a;&#x201d;">&#x201d;&#x2019;</xsw:match>-->
<!--<xsw:match replace="&lsquo;&#x200a;&ldquo;">&lsquo;&ldquo;</xsw:match>
<xsw:match replace="&ldquo;&#x200a;&lsquo;">&ldquo;&lsquo;</xsw:match>
<xsw:match replace="&ldquo;&#x200a;&rdquo;">&ldquo;&rdquo;</xsw:match>
<xsw:match replace="&ldquo;&#x200a;&rdquo;">&rdquo;&ldquo;</xsw:match>-->
<!-- Alex's sequence - first, reduce all left- and right-facing quotations marks with their 'straight' analog
......@@ -349,9 +368,8 @@
u201c and u201d -> u0022
also ` and `` to their respective u0027 and u0022
-->
<xsw:match replace="{$apos}" >[&#x2018;&#x2019;]</xsw:match>
<xsw:match replace="{$quot}" >[&#x201c;&#x201d;]</xsw:match>
<xsw:match replace="{$quot}" >[&#x201c;&#x201d;]</xsw:match>
<xsw:match replace="{$apos}" >[&lsquo;&rsquo;]</xsw:match>
<xsw:match replace="{$quot}" >[&ldquo;&rdquo;]</xsw:match>
<xsw:match replace="{$quot}" >``</xsw:match>
<xsw:match replace="{$apos}" >`</xsw:match>
......@@ -365,24 +383,26 @@
-->
<xsl:variable name="livechar">[^\s\p{Ps}\p{Pe}"']</xsl:variable>
<xsw:match replace="&#x201c;$1">"(\S)</xsw:match>
<xsw:match when-next="\S" replace="&#x201c;">"</xsw:match>
<xsw:match when-after="\S" replace="&#x201d;">"</xsw:match>
<xsw:match replace="$1&#x201d;">(\S)["&#x201c;]</xsw:match>
<xsw:match replace="&ldquo;$1">"({$livechar})</xsw:match>
<xsw:match replace="$1&rdquo;">({$livechar})"</xsw:match>
<xsw:match replace="$1&rsquo;">({$livechar})'</xsw:match>
<xsw:match replace="&lsquo;$1">'({$livechar})</xsw:match>
<xsw:match replace="&#x2018;$1">'(\S)</xsw:match>
<xsw:match replace="$1&#x2019;">(\S)['&#x2018;]</xsw:match>
<xsl:variable name="singles">['&rsquo;&lsquo;]</xsl:variable>
<xsl:variable name="doubles">["&rdquo;&ldquo;]</xsl:variable>
<xsw:match replace="&#x2014;&#x201c;">&#x2014;&#x201d;</xsw:match>
<xsw:match replace="&#x201d;&#x2014;">&#x201c;&#x2014;</xsw:match>
<!-- now the combinations -->
<xsw:match replace="&ldquo;$1">{$doubles}([&lsquo;&ldquo;])</xsw:match>
<xsw:match replace="$1&rdquo;">([&rsquo;&rdquo;]){$doubles}</xsw:match>
<!-- hair space requirements: between
left single quote+left double quote (u2018+u201c)
left double quote+left single quote (u201c+u2018)
right single quote+right double quote (u2019+u201d)
right double quote+right single quote (u201d+u2019)-->
<!-- Inserting hair spaces between *certain* pairings now -->
<xsw:match replace="&ldquo;&#x200a;&ldquo;">&ldquo;&ldquo;</xsw:match>
<xsw:match replace="&ldquo;&#x200a;&lsquo;">&ldquo;&lsquo;</xsw:match>
<xsw:match replace="&rsquo;&#x200a;&rdquo;">&rsquo;&rdquo;</xsw:match>
<xsw:match replace="&rdquo;&#x200a;&rsquo;">&rdquo;&rsquo;</xsw:match>
<!-- brute s/r (from spec)
......@@ -391,12 +411,10 @@
" 'em" or " ‘em" (space+u0027+"em" or space+u2019+"em") -> " ’em" (space+u2019+"em")
"'n'" or "'n'" (u0027+"n"+u0027 or u2018+"n"+u2018) -> "’n’" (u2019+"n"+u2019)"
" 'tis" (space+u0027+"tis" or space+u2018+"tis") -> " ’tis" (space+u2019+"tis")-->
<xsw:match replace="&#x2019;$1">['&#x2018;](\d)</xsw:match>
<xsw:match replace="&#x2019;em">['&#x2018;]em</xsw:match>
<xsw:match replace="&#x2019;n&#x2019;">['&#x2018;&#x2019;]n['&#x2018;&#x2019;]</xsw:match>
<xsw:match replace="&#x2019;tis">['&#x2018;]tis</xsw:match>
<xsw:match replace="&rsquo;$1">{$singles}(\d)</xsw:match>
<xsw:match replace="&rsquo;em">{$singles}em</xsw:match>
<xsw:match replace="&rsquo;n&rsquo;">{$singles}n{$singles}</xsw:match>
<xsw:match replace="&rsquo;$1">{$singles}([Tt](wa|i)s)</xsw:match>
</xsw:sequence>
</xsl:variable>
......
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