fix: gemtext tags

This commit is contained in:
Artemy Egorov 2024-08-04 15:42:45 +03:00
parent 104968f95e
commit 8fb4f31ece
3 changed files with 9 additions and 9 deletions

2
Cargo.lock generated
View file

@ -151,7 +151,7 @@ dependencies = [
[[package]] [[package]]
name = "dalet" name = "dalet"
version = "1.0.0-pre7" version = "1.0.0-pre8"
dependencies = [ dependencies = [
"bincode", "bincode",
"clap", "clap",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "dalet" name = "dalet"
version = "1.0.0-pre7" version = "1.0.0-pre8"
edition = "2021" edition = "2021"
authors = ["artegoser"] authors = ["artegoser"]
license = "MIT" license = "MIT"

View file

@ -1,5 +1,5 @@
use crate::typed::{ use crate::typed::{
Body, Hl, Body, Hl, TNArg,
Tag::{self, *}, Tag::{self, *},
}; };
@ -32,10 +32,10 @@ pub fn parse_gemtext(s: &str) -> Result<Vec<Tag>, GemTextParseError> {
let url = body.next().ok_or(GemTextParseError::InvalidLink)?.trim(); let url = body.next().ok_or(GemTextParseError::InvalidLink)?.trim();
match body.next() { match body.next() {
Some(label) => { Some(label) => page.push(P(
page.push(P(vec![Btn(label.trim().into(), url.into()).into()].into())) vec![Navlink(label.trim().into(), url.into()).into()].into()
} )),
None => page.push(P(vec![Btn(Body::Null, url.into())].into())), None => page.push(P(vec![Navlink(Body::Null, url.into())].into())),
}; };
} else if line.starts_with("# ") { } else if line.starts_with("# ") {
let body = line.split_off(2); let body = line.split_off(2);
@ -47,15 +47,15 @@ pub fn parse_gemtext(s: &str) -> Result<Vec<Tag>, GemTextParseError> {
let body = line.split_off(4); let body = line.split_off(4);
page.push(H(body.trim().into(), Hl::Three)); page.push(H(body.trim().into(), Hl::Three));
} else if line.starts_with("* ") { } else if line.starts_with("* ") {
list_before = true;
let body = line.split_off(2); let body = line.split_off(2);
list.push(El(body.into())); list.push(El(body.into()));
list_before = true;
} else if line.starts_with("> ") { } else if line.starts_with("> ") {
let body = line.split_off(2); let body = line.split_off(2);
page.push(Bq(body.into())); page.push(Bq(body.into()));
} else if line.starts_with("```") { } else if line.starts_with("```") {
if preformatted { if preformatted {
page.push(Pre(preformatted_text.join("\n"))); page.push(Code(preformatted_text.join("\n"), TNArg::Null));
preformatted_text.clear(); preformatted_text.clear();
} }