From 34a2b75b89c44037ed12173b60eb660b674b9175 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 5 Jan 2016 15:35:20 +0100 Subject: [PATCH] Include tags in rendered output --- src/module/notes/mod.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/module/notes/mod.rs b/src/module/notes/mod.rs index cd86f118..93386907 100644 --- a/src/module/notes/mod.rs +++ b/src/module/notes/mod.rs @@ -131,6 +131,7 @@ impl<'a> Notes<'a> { use open; use self::header::get_name_from_header; + use self::header::get_tags_from_header; use ui::external::get_tempfile; use module::helpers::content::markdown::MarkdownParser; @@ -159,10 +160,19 @@ impl<'a> Notes<'a> { let tmpcontent = files.fold(String::new(), |acc, file| { let heading = { let name = get_name_from_header(file.deref().borrow().header()); + let tagsstr = { + let tags = get_tags_from_header(file.deref().borrow().header()); + if tags.len() != 0 { + format!(" ({})", tags.join(", ")) + } else { + format!(" (No Tags)") + } + }; if name.len() == 0 { - format!("# {}", file.deref().borrow().id) + format!("

{}

{}", file.deref().borrow().id, tagsstr) } else { - format!("# {} ({})", name, file.deref().borrow().id()) + format!("

{}

({}){}", + name, file.deref().borrow().id(), tagsstr) } }; @@ -191,8 +201,18 @@ impl<'a> Notes<'a> { } }; - let content = format!("# {}\n\n{}", + let tagsstr = { + let tags = get_tags_from_header(file.deref().borrow().header()); + if tags.len() != 0 { + format!(" ({})", tags.join(", ")) + } else { + format!(" (No Tags)") + } + }; + + let content = format!("

{}

{}\n\n{}", get_name_from_header(file.deref().borrow().header()), + tagsstr, file.deref().borrow().data()); let html = MarkdownParser::new(&content).to_html_page();