update risp
This commit is contained in:
16
src/main.rs
16
src/main.rs
@ -6,13 +6,13 @@ fn print_content(content: Content) -> String {
|
||||
let mut ret = String::new();
|
||||
|
||||
match content {
|
||||
Content::Text(t) => ret.push_str(&format!("<div class='content text'>{t}</div>")),
|
||||
Content::Text(t) => ret.push_str(&format!("<li>{t}</li>")),
|
||||
Content::Item(l) | Content::List(l) => {
|
||||
ret.push_str("<span class='content list'>");
|
||||
ret.push_str("<ul class='content list'>");
|
||||
for item in l {
|
||||
ret.push_str(&print_content(item));
|
||||
}
|
||||
ret.push_str("</span>");
|
||||
ret.push_str("</ul>");
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,15 +68,15 @@ fn print_header(header: Heading, level: usize) -> String {
|
||||
ret
|
||||
}
|
||||
|
||||
fn get_content(config_path: &str) -> String {
|
||||
fn get_content(config_path: &str) -> (String, String) {
|
||||
let law = Law::from_config(config_path).unwrap();
|
||||
let lawname = law.name;
|
||||
|
||||
let mut ret = String::new();
|
||||
for h in law.header {
|
||||
ret.push_str(&print_header(h, 0));
|
||||
}
|
||||
|
||||
ret
|
||||
(lawname, ret)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -89,12 +89,12 @@ fn main() {
|
||||
let law_name = filename.replace(".toml", "");
|
||||
|
||||
let path = format!("{}", config.path().display());
|
||||
let content = get_content(&path);
|
||||
let (lawname, content) = get_content(&path);
|
||||
|
||||
let template = fs::read_to_string("templates/index.html").unwrap();
|
||||
let site = template
|
||||
.replace("{{content}}", &content)
|
||||
.replace("{{title}}", &law_name);
|
||||
.replace("{{title}}", &lawname);
|
||||
|
||||
fs::write(&format!("output/{law_name}.html"), &site).expect("Unable to write file");
|
||||
}
|
||||
|
Reference in New Issue
Block a user