2017-07-01 07:47:41 +00:00
|
|
|
extern crate pulldown_cmark;
|
|
|
|
extern crate slug;
|
2018-10-31 07:18:57 +00:00
|
|
|
extern crate syntect;
|
|
|
|
extern crate tera;
|
2017-07-01 07:47:41 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
2018-05-03 18:50:30 +00:00
|
|
|
extern crate pest;
|
2018-10-31 07:18:57 +00:00
|
|
|
extern crate serde;
|
2018-05-03 18:50:30 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate pest_derive;
|
2018-11-16 17:19:38 +00:00
|
|
|
extern crate regex;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
2018-05-03 18:50:30 +00:00
|
|
|
|
2018-05-06 20:58:39 +00:00
|
|
|
#[macro_use]
|
2017-07-01 07:47:41 +00:00
|
|
|
extern crate errors;
|
2018-05-03 18:50:30 +00:00
|
|
|
extern crate config;
|
2018-10-31 07:18:57 +00:00
|
|
|
extern crate front_matter;
|
2018-07-16 19:13:00 +00:00
|
|
|
extern crate link_checker;
|
2018-10-31 07:18:57 +00:00
|
|
|
extern crate utils;
|
2017-07-01 07:47:41 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
extern crate templates;
|
|
|
|
|
|
|
|
mod context;
|
|
|
|
mod markdown;
|
2018-05-03 18:50:30 +00:00
|
|
|
mod shortcode;
|
2018-10-31 07:18:57 +00:00
|
|
|
mod table_of_contents;
|
2017-07-01 07:47:41 +00:00
|
|
|
|
2018-05-06 20:58:39 +00:00
|
|
|
use errors::Result;
|
|
|
|
|
2018-10-31 07:18:57 +00:00
|
|
|
pub use context::RenderContext;
|
2018-05-06 20:58:39 +00:00
|
|
|
use markdown::markdown_to_html;
|
2018-05-03 18:50:30 +00:00
|
|
|
pub use shortcode::render_shortcodes;
|
2019-09-06 21:36:30 +00:00
|
|
|
pub use table_of_contents::Heading;
|
2018-05-06 20:58:39 +00:00
|
|
|
|
2018-08-22 16:34:32 +00:00
|
|
|
pub fn render_content(content: &str, context: &RenderContext) -> Result<markdown::Rendered> {
|
2018-11-16 17:19:38 +00:00
|
|
|
// Don't do shortcodes if there is nothing like a shortcode in the content
|
2018-05-06 20:58:39 +00:00
|
|
|
if content.contains("{{") || content.contains("{%") {
|
2018-02-02 20:35:04 +00:00
|
|
|
let rendered = render_shortcodes(content, context)?;
|
2018-05-06 20:58:39 +00:00
|
|
|
return markdown_to_html(&rendered, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
markdown_to_html(&content, context)
|
|
|
|
}
|