From a4e722ddea2ee461dc404e9e04016df9ed4ab7c9 Mon Sep 17 00:00:00 2001
From: Domenic Denicola
Date: Wed, 20 May 2015 21:51:06 -0400
Subject: [PATCH] Fix [single non-letter character]
Move -fixing before most others so that subsequent quote-fixing can apply.
---
lib/convert.js | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/convert.js b/lib/convert.js
index 761e9fe..43419c5 100644
--- a/lib/convert.js
+++ b/lib/convert.js
@@ -142,6 +142,17 @@ function getBodyXml(chapter, contentEl) {
// Fix recurring strange pattern of extra
in ......
\n
xml = xml.replace(/
\s*<\/em><\/p>/g, "
");
+ // There are way too many nonbreaking spaces where they don't belong.
+ // If they show up three in a row, then let them live. Otherwise, they die.
+ xml = xml.replace(/([^\xA0])\xA0\xA0?([^\xA0])/g, "$1 $2");
+
+ // Fix recurring broken-up or erroneous s
+ xml = xml.replace(/<\/em>‘s/g, "’s")
+ xml = xml.replace(/<\/em>/g, "");
+ xml = xml.replace(/([^A-Za-z])<\/em>/g, "$1");
+ xml = xml.replace(/<\/em>\. /g, ". ");
+ xml = xml.replace(/“([^>]+)<\/em>(!|\?|\.)”/g, "“$1$2<\/em>”");
+
// Fix recurring poor closing quotes
xml = xml.replace(/“<\/p>/g, "”");
xml = xml.replace(/‘<\/p>/g, "’");
@@ -149,10 +160,6 @@ function getBodyXml(chapter, contentEl) {
// Fix use of ′ instead of closing single quote
xml = xml.replace(/′/g, "’");
- // There are way too many nonbreaking spaces where they don't belong.
- // If they show up three in a row, then let them live. Otherwise, they die.
- xml = xml.replace(/([^\xA0])\xA0\xA0?([^\xA0])/g, "$1 $2");
-
// Fixes dashes
xml = xml.replace(/ – /g, "—");
xml = xml.replace(/“-/g, "“—");
@@ -165,12 +172,6 @@ function getBodyXml(chapter, contentEl) {
xml = xml.replace(/-\s\s?/g, "—");
xml = xml.replace(/\s?\s-/g, "—");
- // Fix recurring broken-up s
- xml = xml.replace(/<\/em>‘s/g, "’s")
- xml = xml.replace(/<\/em>/g, "");
- xml = xml.replace(/<\/em>\. /g, ". ");
- xml = xml.replace(/“([^>]+)<\/em>(!|\?|\.)”/g, "“$1$2<\/em>”");
-
// Fix recurring miscapitalization with questions
xml = xml.replace(/\?”\s\s?She asked/g, "?” she asked");
xml = xml.replace(/\?”\s\s?He asked/g, "?” he asked");