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.

46 lines
1.0KB

  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. extern crate regex;
  12. #[macro_use]
  13. extern crate lazy_static;
  14. #[macro_use]
  15. extern crate errors;
  16. extern crate config;
  17. extern crate front_matter;
  18. extern crate link_checker;
  19. extern crate utils;
  20. #[cfg(test)]
  21. extern crate templates;
  22. mod context;
  23. mod markdown;
  24. mod shortcode;
  25. mod table_of_contents;
  26. use errors::Result;
  27. pub use context::RenderContext;
  28. use markdown::markdown_to_html;
  29. pub use shortcode::render_shortcodes;
  30. pub use table_of_contents::Heading;
  31. pub fn render_content(content: &str, context: &RenderContext) -> Result<markdown::Rendered> {
  32. // Don't do shortcodes if there is nothing like a shortcode in the content
  33. if content.contains("{{") || content.contains("{%") {
  34. let rendered = render_shortcodes(content, context)?;
  35. return markdown_to_html(&rendered, context);
  36. }
  37. markdown_to_html(&content, context)
  38. }