You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1018B

  1. extern crate tera;
  2. extern crate syntect;
  3. extern crate pulldown_cmark;
  4. extern crate slug;
  5. #[macro_use]
  6. extern crate serde_derive;
  7. extern crate serde;
  8. extern crate pest;
  9. #[macro_use]
  10. extern crate pest_derive;
  11. #[macro_use]
  12. extern crate errors;
  13. extern crate front_matter;
  14. extern crate highlighting;
  15. extern crate utils;
  16. extern crate config;
  17. #[cfg(test)]
  18. extern crate templates;
  19. mod context;
  20. mod markdown;
  21. mod table_of_contents;
  22. mod shortcode;
  23. use errors::Result;
  24. use markdown::markdown_to_html;
  25. pub use table_of_contents::Header;
  26. pub use shortcode::render_shortcodes;
  27. pub use context::RenderContext;
  28. pub fn render_content(content: &str, context: &RenderContext) -> Result<(String, Vec<Header>)> {
  29. // Don't do anything if there is nothing like a shortcode in the content
  30. if content.contains("{{") || content.contains("{%") {
  31. let rendered = render_shortcodes(content, context.tera, context.config)?;
  32. return markdown_to_html(&rendered, context);
  33. }
  34. markdown_to_html(&content, context)
  35. }