Don't save the HTML in the struct, add a to_html method instead
This commit is contained in:
parent
5862a89357
commit
c67ff0a78a
|
@ -14,6 +14,11 @@ pub struct List {
|
|||
}
|
||||
|
||||
impl List {
|
||||
pub fn to_html(&self) -> String {
|
||||
comrak::markdown_to_html(&self.data,
|
||||
&comrak::ComrakOptions::default())
|
||||
}
|
||||
|
||||
pub fn load_all() -> Vec<Self> {
|
||||
let mut lists : Vec<List> = vec![];
|
||||
for entry in glob("lists/*.list").unwrap().filter_map(Result::ok) {
|
||||
|
@ -28,11 +33,9 @@ impl List {
|
|||
file.read_to_string(&mut data)
|
||||
.expect(&format!("Cannot read list file {}", file_name));
|
||||
|
||||
let html = comrak::markdown_to_html(&data,
|
||||
&comrak::ComrakOptions::default());
|
||||
let list = List {
|
||||
id: String::from(name),
|
||||
data: data,
|
||||
html: html,
|
||||
name: String::from(name).to_title_case(),
|
||||
path: entry.clone()
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue