Skip to content
Snippets Groups Projects
Commit 5464bbc5 authored by Stephen D's avatar Stephen D
Browse files

allow custom syntaxes

parent a5bd291a
No related branches found
No related tags found
No related merge requests found
......@@ -58,3 +58,10 @@ th, td {
.page-link {
padding-left: 1em;
}
code {
font-size: 87.5%;
color: #e83e8c;
word-break: break-word;
}
......@@ -69,6 +69,8 @@ impl TryFrom<Blog> for RenderedBlog {
fn try_from(mut b: Blog) -> Result<Self, Error> {
let mut pages = HashMap::new();
// TODO throw an error if we attempt to insert the same URL more than once
for p in &b.posts {
let body = dress_page(&p.title, &p.html()?, &b.pages);
......
......@@ -40,18 +40,21 @@ pub struct CustomHtmlHandler {
theme: Theme,
}
impl Default for CustomHtmlHandler {
fn default() -> Self {
impl CustomHtmlHandler {
pub fn new() -> anyhow::Result<Self> {
let mut ts = ThemeSet::load_defaults();
let mut ps = SyntaxSet::load_defaults_newlines().into_builder();
ps.add_from_folder("assets/syntaxes", true)?;
let ps = ps.build();
Self {
Ok(Self {
fallback: Default::default(),
ps: SyntaxSet::load_defaults_newlines(),
ps,
theme: ts
.themes
.remove("base16-eighties.dark")
.expect("Could not load theme"),
}
})
}
}
......
......@@ -82,7 +82,7 @@ impl Loadable for Post {
let url = slugify(&format!("/{slug_prefix}/{file_name}"));
parse(PostParser::new(url), &fs::read_to_string(path)?)
parse(PostParser::new(url)?, &fs::read_to_string(path)?)
}
}
......@@ -113,14 +113,14 @@ struct PostParser {
}
impl PostParser {
fn new(url: String) -> Self {
Self {
fn new(url: String) -> anyhow::Result<Self> {
Ok(Self {
title: None,
date: None,
url,
content: vec![],
handler: CustomHtmlHandler::default(),
}
handler: CustomHtmlHandler::new()?,
})
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment