Function tpnote_lib::workflow::render_exporter_html
source · Expand description
Returns the HTML rendition of the note file located in
context.path with the template TMPL_HTML_VIEWER (can be replaced
at runtime).
use tpnote_lib::config::TMPL_VAR_NOTE_JS;
use tpnote_lib::content::Content;
use tpnote_lib::content::ContentString;
use tpnote_lib::context::Context;
use tpnote_lib::workflow::render_exporter_html;
use std::env::temp_dir;
use std::fs;
use std::path::Path;
// Prepare test: create existing note file.
let raw = String::from(r#"---
title: "My day"
subtitle: "Note"
---
Body text
"#);
// Start test
let mut context = Context::from(Path::new("/path/to/note.md"));
// The exporter template does not inject any JavaScript.
// Render.
let html = render_exporter_html::<ContentString>(context, raw.into())
.unwrap();
// Check the HTML rendition.
assert!(html.starts_with("<!DOCTYPE html>\n<html"))