// The reading view: the song's book of the Odyssey (Butcher & Lang, which keeps the Greek names), opened at // the first paragraph naming one of the song's keywords, with the paragraphs before it folded away. import type { AlbumSong } from "../../data/album"; import { keywordRe, loadBook, passageStart, roman, stripFootnotes } from "../content"; import { esc } from "./util"; /** `readAll` shows the whole book from the start, keeping the passage marker. */ export function readingView(song: AlbumSong, readAll: boolean): HTMLElement { const o = song.odyssey!; const el = document.createElement("div"); el.className = "reading"; el.innerHTML = `
The Odyssey · Book ${roman(o.book)} · tr. Butcher & Lang
Opening Book ${roman(o.book)}…
Book ${roman(o.book)} could not be loaded from the content folder. Read it on Project Gutenberg.
`; return; } const at = passageStart(book, o.keywords); const re = keywordRe(o.keywords); const para = (t: string) => { let h = esc(stripFootnotes(t)); if (re) h = h.replace(re, "$1"); return `${h}
`; }; const from = readAll ? 0 : at.index; const marker = `${at.word ? `The passage for ${esc(song.title)} begins here · first mention of “${esc(at.word)}”` : `No keyword for ${esc(song.title)} found · Book ${roman(o.book)} from the start`}
`; body.innerHTML = `${esc(book.summary)}
` : ""} ${from > 0 ? `` : ""} ${book.paragraphs.slice(from).map((t, i) => (from + i === at.index ? marker : "") + para(t)).join("")}End of Book ${roman(o.book)} · Project Gutenberg #1728
`; if (readAll) el.querySelector