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.

101 lines
3.0KB

  1. #![feature(test)]
  2. extern crate test;
  3. extern crate tera;
  4. extern crate rendering;
  5. extern crate front_matter;
  6. use std::collections::HashMap;
  7. use tera::Tera;
  8. use rendering::{Context, markdown_to_html};
  9. use front_matter::InsertAnchor;
  10. static CONTENT: &'static str = r#"
  11. # Modus cognitius profanam ne duae virtutis mundi
  12. ## Ut vita
  13. Lorem markdownum litora, care ponto nomina, et ut aspicit gelidas sui et
  14. purpureo genuit. Tamen colla venientis [delphina](http://nil-sol.com/ecquis)
  15. Tusci et temptata citaeque curam isto ubi vult vulnere reppulit.
  16. - Seque vidit flendoque de quodam
  17. - Dabit minimos deiecto caputque noctis pluma
  18. - Leti coniunx est Helicen
  19. - Illius pulvereumque Icare inpositos
  20. - Vivunt pereo pluvio tot ramos Olenios gelidis
  21. - Quater teretes natura inde
  22. ### A subsection
  23. Protinus dicunt, breve per, et vivacis genus Orphei munere. Me terram [dimittere
  24. casside](http://corpus.org/) pervenit saxo primoque frequentat genuum sorori
  25. praeferre causas Libys. Illud in serpit adsuetam utrimque nunc haberent,
  26. **terrae si** veni! Hectoreis potes sumite [Mavortis retusa](http://tua.org/)
  27. granum captantur potuisse Minervae, frugum.
  28. > Clivo sub inprovisoque nostrum minus fama est, discordia patrem petebat precatur
  29. absumitur, poena per sit. Foramina *tamen cupidine* memor supplex tollentes
  30. dictum unam orbem, Anubis caecae. Viderat formosior tegebat satis, Aethiopasque
  31. sit submisso coniuge tristis ubi!
  32. ## Praeceps Corinthus totidem quem crus vultum cape
  33. ```rs
  34. #[derive(Debug)]
  35. pub struct Site {
  36. /// The base path of the gutenberg site
  37. pub base_path: PathBuf,
  38. /// The parsed config for the site
  39. pub config: Config,
  40. pub pages: HashMap<PathBuf, Page>,
  41. pub sections: HashMap<PathBuf, Section>,
  42. pub tera: Tera,
  43. live_reload: bool,
  44. output_path: PathBuf,
  45. static_path: PathBuf,
  46. pub tags: Option<Taxonomy>,
  47. pub categories: Option<Taxonomy>,
  48. /// A map of all .md files (section and pages) and their permalink
  49. /// We need that if there are relative links in the content that need to be resolved
  50. pub permalinks: HashMap<String, String>,
  51. }
  52. ```
  53. ## More stuff
  54. And a shortcode:
  55. {{ youtube(id="my_youtube_id") }}
  56. ### Another subsection
  57. Gotta make the toc do a little bit of work
  58. # A big title
  59. - hello
  60. - world
  61. - !
  62. ```py
  63. if __name__ == "__main__":
  64. gen_site("basic-blog", [""], 250, paginate=True)
  65. ```
  66. "#;
  67. #[bench]
  68. fn bench_markdown_to_html_with_highlighting(b: &mut test::Bencher) {
  69. let tera_ctx = Tera::default();
  70. let permalinks_ctx = HashMap::new();
  71. let context = Context::new(&tera_ctx, true, "base16-ocean-dark".to_string(), "", &permalinks_ctx, InsertAnchor::None);
  72. b.iter(|| markdown_to_html(CONTENT, &context));
  73. }
  74. #[bench]
  75. fn bench_markdown_to_html_without_highlighting(b: &mut test::Bencher) {
  76. let tera_ctx = Tera::default();
  77. let permalinks_ctx = HashMap::new();
  78. let context = Context::new(&tera_ctx, false, "base16-ocean-dark".to_string(), "", &permalinks_ctx, InsertAnchor::None);
  79. b.iter(|| markdown_to_html(CONTENT, &context));
  80. }