only slightly better visuals

This commit is contained in:
liquidex 2023-08-18 18:26:41 +02:00
parent 30255be018
commit 17b6e54976
4 changed files with 173 additions and 14 deletions

View file

@ -1,6 +1,6 @@
- # treehouse - # treehouse
- welcome to treehouse! - welcome to the treehouse!
- treehouse is a brand new static website generator, inspired by the likes of Jekyll and Hugo, but offering a writing experience more close to Logseq - treehouse is a brand new static website generator, inspired by the likes of Jekyll and Hugo, but offering a writing experience more close to Logseq
@ -47,16 +47,38 @@
- ### heading 3 - ### heading 3
headings lower than this aren't really supported because c'mon who would be this crazy headings lower than this aren't really supported because c'mon who would be this crazy
- <https://liquidev.net> - this is supposed to be **bold** and this is supposed to be _italic_
- here is my favorite fluffy boy ![ralsei with a hat](https://liquidev.net/syf/art/20230723_ralsei_hat.png) - there's a line break<br>
here
- and it's supposed to render correctly
- <https://liquidev.net> also [a link that you have not visited because there is nothing there](https://liquidev.net/nothing-to-see-here-lmfao-did-you-really-expect-me-to-create-such-a-behemoth-of-a-URL)
+ here is my favorite fluffy boy ![ralsei with a hat](https://liquidev.net/syf/art/20230723_ralsei_hat.png)
- without a hat is also nice uwu
- also a block quote - also a block quote
- > Enough You Foolish Children - > Enough You Foolish Children
- yes i will totally abuse you with deltarune references and you cannot stop me - yes i will totally abuse you with Deltarune references and you cannot stop me
- ``` - ```
this is some block of code it looks pretty cool doesn't it this is some block of code it looks pretty cool doesn't it
``` ```
- ```
and here's a multiline code block which also looks cool
many many many lines
```
- and a table because benchmarks use those
-
| weeee | woosh | wa-ho |
| --- | --- | --- |
| yep | that's | a table |
| looks | pretty cool | huh |

View file

@ -3,7 +3,11 @@ use treehouse_format::{ast::Branch, pull::BranchKind};
use super::markdown; use super::markdown;
pub fn branch_to_html(s: &mut String, branch: &Branch, source: &str) { pub fn branch_to_html(s: &mut String, branch: &Branch, source: &str) {
s.push_str("<li>"); s.push_str(if !branch.children.is_empty() {
"<li class=\"branch\">"
} else {
"<li class=\"leaf\">"
});
{ {
if !branch.children.is_empty() { if !branch.children.is_empty() {
s.push_str(match branch.kind { s.push_str(match branch.kind {
@ -15,13 +19,26 @@ pub fn branch_to_html(s: &mut String, branch: &Branch, source: &str) {
let raw_block_content = &source[branch.content.clone()]; let raw_block_content = &source[branch.content.clone()];
let mut unindented_block_content = String::with_capacity(raw_block_content.len()); let mut unindented_block_content = String::with_capacity(raw_block_content.len());
let indent = " ".repeat(branch.indent_level);
for line in raw_block_content.lines() { for line in raw_block_content.lines() {
unindented_block_content.push_str(line.strip_prefix(&indent).unwrap_or(line)); // Bit of a jank way to remove at most branch.indent_level spaces from the front.
let mut space_count = 0;
for i in 0..branch.indent_level {
if line.as_bytes().get(i).copied() == Some(b' ') {
space_count += 1;
} else {
break;
}
}
dbg!(&line[space_count..]);
unindented_block_content.push_str(&line[space_count..]);
unindented_block_content.push('\n'); unindented_block_content.push('\n');
} }
let markdown_parser = pulldown_cmark::Parser::new(&unindented_block_content); let markdown_parser = pulldown_cmark::Parser::new_ext(&unindented_block_content, {
use pulldown_cmark::Options;
Options::ENABLE_STRIKETHROUGH | Options::ENABLE_TABLES
});
markdown::push_html(s, markdown_parser); markdown::push_html(s, markdown_parser);
if !branch.children.is_empty() { if !branch.children.is_empty() {

View file

@ -1,3 +1,11 @@
/* Article-style layout. Center everything and give it a maximum width */
body {
max-width: 1200px;
margin-left: auto;
margin-right: auto;
}
/* Choose more pretty colors than vanilla HTML */ /* Choose more pretty colors than vanilla HTML */
body { body {
@ -5,13 +13,14 @@ body {
color: #333; color: #333;
} }
/* Set up fonts */ /* Set up typography */
body, body,
pre, pre,
code { code {
font-family: 'RecVar', sans-serif; font-family: 'RecVar', sans-serif;
font-size: 14px; font-size: 14px;
line-height: 1.5;
} }
:root { :root {
@ -36,13 +45,92 @@ code {
h1 { h1 {
--recursive-slnt: 0.0; --recursive-slnt: 0.0;
--recursive-casl: 0.0; --recursive-casl: 0.0;
--recursive-crsv: 0.0;
--recursive-wght: 900; --recursive-wght: 900;
font-size: 2.5rem;
}
h2 {
--recursive-slnt: 0.0;
--recursive-casl: 0.5;
--recursive-wght: 800;
font-size: 2rem;
}
h3 {
--recursive-slnt: 0.0;
--recursive-casl: 0.5;
--recursive-wght: 700;
font-size: 1.5rem;
} }
pre, pre,
code { code {
--recursive-mono: 1.0; --recursive-mono: 1.0;
--recursive-casl: 0.0;
--recursive-slnt: 0.0;
}
b,
strong {
--recursive-wght: 700;
}
i,
em {
--recursive-slnt: -16.0;
}
/* Lay out elements a bit more compactly */
p,
pre {
margin: 6px 0;
}
h1,
h2,
h3 {
margin: 12px 0;
}
/* Lay out elements a little less compactly (actually just have some blank space past the end) */
body {
padding-bottom: 10rem;
}
/* Make code examples a little prettier by giving them visual separation from the rest of the page */
pre {
min-width: 70%;
margin-left: 12px;
padding: 8px 12px;
background-color: rgba(0, 0, 0, 5%);
}
/* Also don't let images get out of hand */
img {
max-width: 100%;
}
/* Fix the default blue and ugly purple links normally have */
a {
color: #004ec8;
}
a:visited {
color: #6c2380;
}
/* The tree indents shouldn't be too spaced out */
.tree ul {
padding-left: 24px;
} }
/* Make the tree have + and - instead of the default details/summary arrow */ /* Make the tree have + and - instead of the default details/summary arrow */
@ -56,12 +144,44 @@ code {
list-style: none; list-style: none;
} }
/* Also, lone paragraphs should have a bullet point beside to give you a bit of a visual anchor */
.tree li.leaf>p:first-child::before,
/* Lone paragraphs include <pre> elements */
.tree li.leaf>pre:first-child::before {
content: '·';
opacity: 0.5;
display: inline-block;
height: 0;
margin-left: -1.5rem;
width: 1.5rem;
--recursive-mono: 1.0;
font-size: 14px;
}
/* Dirty hack to make pres render the way I want this to */
.tree li.leaf>pre:first-child::before {
transform: translateX(-8px);
}
pre {
transform: translateX(8px);
border-radius: 6px;
}
.tree details::before { .tree details::before {
content: '+'; content: '+';
opacity: 0.5; opacity: 0.5;
padding-right: 8px; display: inline-block;
vertical-align: text-bottom; margin-left: -1em;
margin-left: -1.5rem;
width: 1.5rem;
vertical-align: middle;
--recursive-mono: 1.0; --recursive-mono: 1.0;
} }
@ -70,6 +190,7 @@ code {
content: '-'; content: '-';
} }
.tree details *:first-child { .tree details>*:first-child,
.tree li.leaf>*:first-child {
display: inline-block; display: inline-block;
} }

View file

@ -3,7 +3,6 @@
// We want to let the user have a selection on collapsible blocks without collapsing them when // We want to let the user have a selection on collapsible blocks without collapsing them when
// the user finishes marking their selection. // the user finishes marking their selection.
document.addEventListener("click", event => { document.addEventListener("click", event => {
console.log(getSelection());
if (getSelection().type == "Range") { if (getSelection().type == "Range") {
event.preventDefault(); event.preventDefault();
} }