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.

45 lines
1.0KB

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