From 7d8237c6b9d3e9ad580cad19830ef72623b58f4f Mon Sep 17 00:00:00 2001 From: mehbark Date: Sat, 30 Dec 2023 02:44:39 -0500 Subject: [PATCH] jekyll: DONE AWESOME --- html/read-more.tsx | 89 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 11 deletions(-) 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---"} + );