Fix <em>[single non-letter character]</em>

Move <em>-fixing before most others so that subsequent quote-fixing can apply.
This commit is contained in:
Domenic Denicola 2015-05-20 21:51:06 -04:00
commit a4e722ddea

View file

@ -142,6 +142,17 @@ function getBodyXml(chapter, contentEl) {
// Fix recurring strange pattern of extra <br> in <p>...<em>...<br>\n</em></p>
xml = xml.replace(/<br\/>\s*<\/em><\/p>/g, "</em></p>");
// 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 <em>s
xml = xml.replace(/<\/em>s/g, "s</em>")
xml = xml.replace(/<\/em><em>/g, "");
xml = xml.replace(/<em>([^A-Za-z])<\/em>/g, "$1");
xml = xml.replace(/<\/em>\. <em>/g, ". ");
xml = xml.replace(/“<em>([^>]+)<\/em>(!|\?|\.)”/g, "“<em>$1$2<\/em>”");
// Fix recurring poor closing quotes
xml = xml.replace(/“<\/p>/g, "”</p>");
xml = xml.replace(/<\/p>/g, "</p>");
@ -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 <em>s
xml = xml.replace(/<\/em>s/g, "s</em>")
xml = xml.replace(/<\/em><em>/g, "");
xml = xml.replace(/<\/em>\. <em>/g, ". ");
xml = xml.replace(/“<em>([^>]+)<\/em>(!|\?|\.)”/g, "“<em>$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");