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
993B

  1. extern crate pulldown_cmark;
  2. extern crate slug;
  3. extern crate syntect;
  4. extern crate tera;
  5. #[macro_use]
  6. extern crate serde_derive;
  7. extern crate pest;
  8. extern crate serde;
  9. #[macro_use]
  10. extern crate pest_derive;
  11. #[macro_use]
  12. extern crate errors;
  13. extern crate config;
  14. extern crate front_matter;
  15. extern crate link_checker;
  16. extern crate utils;
  17. #[cfg(test)]
  18. extern crate templates;
  19. mod context;
  20. mod markdown;
  21. mod shortcode;
  22. mod table_of_contents;
  23. use errors::Result;
  24. pub use context::RenderContext;
  25. use markdown::markdown_to_html;
  26. pub use shortcode::render_shortcodes;
  27. pub use table_of_contents::Header;
  28. pub fn render_content(content: &str, context: &RenderContext) -> Result<markdown::Rendered> {
  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)?;
  32. return markdown_to_html(&rendered, context);
  33. }
  34. markdown_to_html(&content, context)
  35. }