diff --git a/scripts/build_site.py b/scripts/build_site.py
index b14499c4..b9545651 100644
--- a/scripts/build_site.py
+++ b/scripts/build_site.py
@@ -587,6 +587,23 @@ def mark_drop_cap(paragraph):
raise ValueError("editorial opening paragraph has no visible letter")
+def mark_inline_phi(body):
+ """Identify backticked Phi in prose without styling paths or labels."""
+ def mark_code(match):
+ code = html_module.unescape(match.group(1)).strip()
+ if not re.fullmatch(r"[a-z]+(?: [a-z]+)*[.]?", code):
+ return match.group(0)
+ words = code.removesuffix(".").split()
+ if not words or any(word not in ALL_WORDS for word in words):
+ return match.group(0)
+ return f'{match.group(1)}'
+
+ def mark_paragraph(match):
+ return re.sub(r"([^<]+)", mark_code, match.group(0))
+
+ return re.sub(r"
]*)?>.*?
", mark_paragraph, body, flags=re.S) + + def apply_book_editorial(body, source, repo_path, treatment): """Generate the chapter furniture named in site/editorial.json.""" chapter_match = re.match(r"book/([0-9]+)_", repo_path) @@ -612,6 +629,7 @@ def apply_book_editorial(body, source, repo_path, treatment): + f'{marked_lede}
' + body[lede_match.end():] ) + body = mark_inline_phi(body) paragraph_matches = list(re.finditer(r".*?
", body, flags=re.S)) insertions = {} @@ -630,10 +648,10 @@ def apply_book_editorial(body, source, repo_path, treatment): f"editorial pull quote did not survive rendering in {repo_path}: {quote!r}" ) aside = ( - '\n" + '\n" ) - insertions.setdefault(containing[0].end(), []).append(aside) + insertions.setdefault(containing[0].start(), []).append(aside) for position in sorted(insertions, reverse=True): body = body[:position] + "".join(insertions[position]) + body[position:] return body diff --git a/site/style.css b/site/style.css index 17ec8471..e65360dd 100644 --- a/site/style.css +++ b/site/style.css @@ -52,6 +52,7 @@ --sage: #7a8b6f; --gold: #b0975b; --hairline: #ddd6c6; + --phi-inline-bg: #e1e6db; --serif: "Fraunces", georgia, serif; --sans: "Source Sans 3", system-ui, sans-serif; --ipa: "Gentium Plus", "Charis SIL", serif; @@ -404,26 +405,36 @@ footer a { color: var(--sage); } font-family: var(--serif); font-size: 1.3rem; line-height: 1.42; - margin: .55rem -12.5rem 1.5rem 2rem; + margin: .55rem 0 1.2rem 1.6rem; padding: .8rem 0; - width: 10.5rem; + width: 14rem; } .book-editorial .chapter-pullquote p { margin: 0; } .book-editorial .chapnav { clear: both; } - -@media (max-width: 62rem) { - .book-editorial main { max-width: 38rem; } - .book-editorial .chapter-pullquote { - float: none; - margin: 1.8rem 0; - width: auto; - } +.book-editorial code.phi-inline { + -webkit-box-decoration-break: clone; + background: var(--phi-inline-bg); + border-radius: 5px; + box-decoration-break: clone; + color: var(--ink); + font-family: ui-monospace, "SFMono-Regular", consolas, monospace; + font-size: 1em; + letter-spacing: 0; + line-height: 1; + padding: .12em .34em .16em; + white-space: normal; } +.book-editorial p code:not(.phi-inline) { overflow-wrap: anywhere; } @media (max-width: 560px) { .book-editorial h1 { font-size: 2.15rem; } .book-editorial .chapter-lede { font-size: 1.08rem; } .book-editorial .drop-cap { font-size: 3.55rem; } + .book-editorial .chapter-pullquote { + float: none; + margin: 1.6rem 0 1rem; + width: auto; + } } @media print { @@ -483,6 +494,7 @@ html[data-theme="dark"] { --sage: #a3b795; --gold: #c9b078; --hairline: #3a443a; + --phi-inline-bg: #3a443a; } html[data-theme="dark"] body { background: var(--paper); color: var(--ink); }