2017-07-01 07:47:41 +00:00
|
|
|
extern crate tera;
|
|
|
|
extern crate syntect;
|
|
|
|
extern crate pulldown_cmark;
|
|
|
|
extern crate slug;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate serde;
|
2018-05-03 18:50:30 +00:00
|
|
|
extern crate pest;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate pest_derive;
|
|
|
|
|
2018-05-06 20:58:39 +00:00
|
|
|
#[macro_use]
|
2017-07-01 07:47:41 +00:00
|
|
|
extern crate errors;
|
|
|
|
extern crate front_matter;
|
2017-10-30 20:55:14 +00:00
|
|
|
extern crate highlighting;
|
2017-07-01 07:47:41 +00:00
|
|
|
extern crate utils;
|
2018-05-03 18:50:30 +00:00
|
|
|
extern crate config;
|
2017-07-01 07:47:41 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
extern crate templates;
|
|
|
|
|
|
|
|
mod context;
|
|
|
|
mod markdown;
|
|
|
|
mod table_of_contents;
|
2018-05-03 18:50:30 +00:00
|
|
|
mod shortcode;
|
2017-07-01 07:47:41 +00:00
|
|
|
|
2018-05-06 20:58:39 +00:00
|
|
|
use errors::Result;
|
|
|
|
|
|
|
|
use markdown::markdown_to_html;
|
2017-07-01 07:47:41 +00:00
|
|
|
pub use table_of_contents::Header;
|
2018-05-03 18:50:30 +00:00
|
|
|
pub use shortcode::render_shortcodes;
|
2018-05-06 20:58:39 +00:00
|
|
|
pub use context::RenderContext;
|
|
|
|
|
|
|
|
pub fn render_content(content: &str, context: &RenderContext) -> Result<(String, Vec<Header>)> {
|
|
|
|
// Don't do anything if there is nothing like a shortcode in the content
|
|
|
|
if content.contains("{{") || content.contains("{%") {
|
|
|
|
let rendered = render_shortcodes(content, context.tera, context.config)?;
|
|
|
|
return markdown_to_html(&rendered, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
markdown_to_html(&content, context)
|
|
|
|
}
|