pub fn render_exporter_html<T: Content>(
    context: Context,
    content: T
) -> Result<String, NoteError>
Expand description

Returns the HTML rendition of a ContentString. The markup rendition engine is determined, by the file extension of the variable context.path. The resulting HTML and other HTML template variables originating from context are inserted into the TMPL_HTML_EXPORTER template (which can be replaced at runtime) before being returned. This function is stateless.

use tpnote_lib::config::TMPL_HTML_VAR_VIEWER_DOC_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 insert 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"))