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.

44 lines
1023B

  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. extern crate link_checker;
  18. #[cfg(test)]
  19. extern crate templates;
  20. mod context;
  21. mod markdown;
  22. mod table_of_contents;
  23. mod shortcode;
  24. use errors::Result;
  25. use markdown::markdown_to_html;
  26. pub use table_of_contents::Header;
  27. pub use shortcode::render_shortcodes;
  28. pub use context::RenderContext;
  29. pub fn render_content(content: &str, context: &RenderContext) -> Result<(String, Vec<Header>)> {
  30. // Don't do anything if there is nothing like a shortcode in the content
  31. if content.contains("{{") || content.contains("{%") {
  32. let rendered = render_shortcodes(content, context)?;
  33. return markdown_to_html(&rendered, context);
  34. }
  35. markdown_to_html(&content, context)
  36. }