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.

34 lines
914B

  1. use std::collections::HashMap;
  2. use tera::Tera;
  3. use config::Config;
  4. use front_matter::InsertAnchor;
  5. /// All the information from the gutenberg site that is needed to render HTML from markdown
  6. #[derive(Debug)]
  7. pub struct Context<'a> {
  8. pub tera: &'a Tera,
  9. pub highlight_code: bool,
  10. pub highlight_theme: String,
  11. pub permalinks: &'a HashMap<String, String>,
  12. pub insert_anchor: InsertAnchor,
  13. }
  14. impl<'a> Context<'a> {
  15. pub fn new(tera: &'a Tera, config: &'a Config, permalinks: &'a HashMap<String, String>, insert_anchor: InsertAnchor) -> Context<'a> {
  16. Context {
  17. tera,
  18. permalinks,
  19. insert_anchor,
  20. highlight_code: config.highlight_code.unwrap(),
  21. highlight_theme: config.highlight_theme.clone().unwrap(),
  22. }
  23. }
  24. pub fn should_insert_anchor(&self) -> bool {
  25. self.insert_anchor != InsertAnchor::None
  26. }
  27. }