Commit 3d6b727d authored by Wendell Piez's avatar Wendell Piez
Browse files

Now mainly cosmetic

parent 29508d4f
......@@ -52,7 +52,7 @@
<!-- $space is (plain) space and LF, no tab -->
<xsl:variable as="xs:string" name="space">[&#x20;&#xA;]</xsl:variable>
<xsl:variable name="replacements" expand-text="yes" as="element(xsw:sequence)">
<xsl:variable name="operations" expand-text="yes" as="element(xsw:sequence)">
<sequence xmlns="http://coko.foundation/xsweet">
<!-- Two adjacent hyphens become an em dash: "\-\-" (escaped in regex) becomes "—" -->
<match replace="&#x2014;">\-\-</match>
......@@ -106,13 +106,13 @@
<!-- omit whitespace around em dashes -->
<match replace="&#x2014;">\s*&#x2014;\s*</match>
<!-- handle initials - inserting nbsp for runs of spaces -->
<!-- Handling initial letters - inserting nbsp for runs of spaces between punctuated capitals ... -->
<splice replace="&#xA0;">
<prae>[A-Z]\.</prae>
<quid>\s*</quid>
<post>[A-Z]\.</post>
</splice>
<!-- We have to do this twice! to handle multiple runs of initials. -->
<!-- ... We have to do this twice! to handle multiple runs of initials. -->
<splice replace="&#xA0;">
<prae>[A-Z]\.</prae>
<quid>\s*</quid>
......@@ -128,7 +128,7 @@
<match replace="B.C.E.">B\.&#xA0;C\.&#xA0;E\.</match>
<match replace="A.C.E.">A\.&#xA0;C\.&#xA0;E\.</match>
<!-- Punctuation-related cleanup -->
<!-- Punctuation-related cleanup - spaces before certain punctuation signs - -->
<match replace="$1">\s+([,;:!\?\)\]\}}])</match>
<!-- subsequence to perform all quotation mark munging -->
......@@ -147,7 +147,7 @@
</xsl:template>
<xsl:template match="body//text()">
<xsl:apply-templates select="$replacements">
<xsl:apply-templates select="$operations">
<xsl:with-param name="original" select="."/>
</xsl:apply-templates>
</xsl:template>
......@@ -335,31 +335,27 @@
<xsl:variable name="quot" as="xs:string">"</xsl:variable>
<xsl:variable name="apos" as="xs:string">'</xsl:variable>
<xsl:template match="xsw:munge-quotes">
<xsl:param name="original" required="yes" as="text()"/>
<xsl:param name="str" required="yes" as="xs:string"/>
<xsl:variable name="quote-sequence" 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>
<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>-->
<!-- Alex's sequence - first, reduce all left- and right-facing quotations marks with their 'straight' analog
<!-- Alex's sequence - first, reduce all left- and right-facing quotations marks with their 'straight' analog
u2018 and u2019 -> u0027
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="{$quot}" >``</xsw:match>
<xsw:match replace="{$apos}" >`</xsw:match>
<!--
<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="{$quot}" >``</xsw:match>
<xsw:match replace="{$apos}" >`</xsw:match>
<!--
Then apply heuristics to map back again -
apostrophe+alphabetical character (u0027+letter) -> left single quotation mark (u2018+letter)
......@@ -368,44 +364,48 @@
alphabetical character+quotation mark (letter+u0022) -> alphabetical character+right double quotation mark (letter+u201d)
-->
<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="&#x2018;$1">'(\S)</xsw:match>
<xsw:match replace="$1&#x2019;">(\S)['&#x2018;]</xsw:match>
<xsw:match replace="&#x2014;&#x201c;">&#x2014;&#x201d;</xsw:match>
<xsw:match replace="&#x201d;&#x2014;">&#x201c;&#x2014;</xsw:match>
<!-- hair space requirements: between
<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="&#x2018;$1">'(\S)</xsw:match>
<xsw:match replace="$1&#x2019;">(\S)['&#x2018;]</xsw:match>
<xsw:match replace="&#x2014;&#x201c;">&#x2014;&#x201d;</xsw:match>
<xsw:match replace="&#x201d;&#x2014;">&#x201c;&#x2014;</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)-->
<!-- brute s/r (from spec)
<!-- brute s/r (from spec)
em dash+right double quote (u2014+u201d) -> em dash+left double quote (u2014+u201c)
left double quote+em dash (u201c+u2014)-> right double quote+em dash (u201d+u2014)
" '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:sequence>
</xsl:variable>
<xsl:apply-templates select="$quote-sequence">
<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:sequence>
</xsl:variable>
<xsl:template match="xsw:munge-quotes">
<xsl:param name="original" required="yes" as="text()"/>
<xsl:param name="str" required="yes" as="xs:string"/>
<xsl:apply-templates select="$quote-operations">
<xsl:with-param name="starting" select="$str"/>
<xsl:with-param name="original" select="$original"/>
</xsl:apply-templates>
......
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