jekyll: DONE AWESOME

This commit is contained in:
mehbark 2023-12-30 02:44:39 -05:00
parent 22e0b3b967
commit 7d8237c6b9

View file

@ -1,19 +1,86 @@
import { render_and_copy } from "./common.tsx"; 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", "");
render_and_copy( const chapters: [string, string[]][] = text
<div> .replaceAll("`", "")
{text .replaceAll("'", "")
.split(/CHAPTER|Epilogue/) .replaceAll("--", "—")
.split("\n\n\n\n\n")
.slice(1) .slice(1)
.map(c => ( .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(
<> <>
{...c <div
.split("\r\n\r\n") class="main"
.map(p => <p>{p.replaceAll("\r\n", " ")}</p>)} style='font-family: "Latin Modern Math", "Computer Modern", "Helvetica", serif;font-weight:bold'
>
<a
href="https://dn790009.ca.archive.org/0/items/thestrangecaseof00043gut/43.txt"
style="display:block;margin:0 auto;width:fit-content;font-size:1.35rem;font-weight:bold"
>
massive thanks to project gutenberg for the book
</a>
<br />
<a
href="#user-content-mehbark-hekyll-end"
id="mehbark-hekyll-jump-to-end"
style="display:block;margin:0 auto;width:fit-content;font-size:1.35rem;font-weight:bold"
>
JUMP TO END
</a>
<br />
<br />
<h3>Table of Contents (clickable!)</h3>
<ol>
{...chapters.map(([title, _]) => (
<li>
<a
href={`#user-content-chapter-${make_chapter_id(
title
)}`}
style="text-decoration:none"
>
{title}
</a>
</li>
))}
</ol>
<br />
<br />
{...chapters.map(([title, content]) => (
<>
<a
href={`#user-content-chapter-${make_chapter_id(title)}`}
id={`chapter-${make_chapter_id(title)}`}
style="text-decoration:none;font-weight:600;font-size:1.25em"
>
{title}
</a>
{...content.map(p => <p>{p}</p>)}
</> </>
))} ))}
<a
href="#user-content-mehbark-hekyll-jump-to-end"
id="mehbark-hekyll-end"
title="this is also a jump to top"
style="margin:0 auto;width:fit-content;font-size:1.75em;font-weight:bold;display:block;text-decoration:none"
>
THE END
</a>
</div> </div>
{"\n\n---"}
</>
); );