From 0053545444bd68262262302e2383118ee05d252e Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Sat, 7 Nov 2020 17:58:33 -0500 Subject: [PATCH] Correctly hyphenate "X-year-old" --- lib/convert-worker.js | 5 +++++ 1 file changed, 5 insertions(+) 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");