diff --git a/html/read-more.tsx b/html/read-more.tsx index bb7dbf9..4f2de32 100644 --- a/html/read-more.tsx +++ b/html/read-more.tsx @@ -1,19 +1,86 @@ import { render_and_copy } from "./common.tsx"; -const DICK_URL = "https://www.gutenberg.org/files/2701/old/moby10b.txt"; +const URL = + "https://dn790009.ca.archive.org/0/items/thestrangecaseof00043gut/43.txt"; -const text = await fetch(DICK_URL).then(r => r.text()); +const text = (await fetch(URL).then(r => r.text())).replaceAll("\r", ""); +const chapters: [string, string[]][] = text + .replaceAll("`", "‘") + .replaceAll("'", "’") + .replaceAll("--", "—") + .split("\n\n\n\n\n") + .slice(1) + .map(c => c.split("\n\n\n")) + .filter(c => c.length == 2) + .map(c => [c[0], c[1].split("\n\n")]); +const make_chapter_id = (title: string) => + title + .toLowerCase() + .split(" ") + .map(w => w.split(/[^a-z]/).join("")) + .join("-"); + +console.log(chapters); render_and_copy( -
- {text - .split(/CHAPTER|Epilogue/) - .slice(1) - .map(c => ( + <> +
+ + massive thanks to project gutenberg for the book + +
+ + JUMP TO END + +
+
+

Table of Contents (clickable!)

+
    + {...chapters.map(([title, _]) => ( +
  1. + + {title} + +
  2. + ))} +
+
+
+ {...chapters.map(([title, content]) => ( <> - {...c - .split("\r\n\r\n") - .map(p =>

{p.replaceAll("\r\n", " ")}

)} + + {title} + + {...content.map(p =>

{p}

)} ))} -
+ + THE END + +
+ {"\n\n---"} + );