diff --git a/lib/convert-worker.js b/lib/convert-worker.js index a3a8000..9959711 100644 --- a/lib/convert-worker.js +++ b/lib/convert-worker.js @@ -263,6 +263,11 @@ function getBodyXML(chapter, book, contentEl) { xml = xml.replace(/I-I/g, "I—I"); xml = xml.replace(/I-uh/g, "I—uh"); + // "X-year-old" should use hyphens; all grammar guides agree. The books are very inconsistent but most often omit + // them. + xml = xml.replace(/(\w+)[ -]year[ -]old(s?)(?!\w)/g, "$1-year-old$2"); + xml = xml.replace(/(\w+) or (\w+)-year-old/g, "$1- or $2-year-old"); + // Fix missing spaces after commas xml = xml.replace(/([a-zA-Z]+),([a-zA-Z]+)/g, "$1, $2");