jekyll: DONE AWESOME
This commit is contained in:
parent
22e0b3b967
commit
7d8237c6b9
1 changed files with 78 additions and 11 deletions
|
@ -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());
|
||||
render_and_copy(
|
||||
<div>
|
||||
{text
|
||||
.split(/CHAPTER|Epilogue/)
|
||||
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 => (
|
||||
.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
|
||||
.split("\r\n\r\n")
|
||||
.map(p => <p>{p.replaceAll("\r\n", " ")}</p>)}
|
||||
<div
|
||||
class="main"
|
||||
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>
|
||||
{"\n\n---"}
|
||||
</>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue