]>
Commit | Line | Data |
---|---|---|
8d4fac52 | 1 | mod gemini_parser; |
1e2d00b6 RBR |
2 | mod file_finder; |
3 | mod file_handler; | |
4 | ||
4fd89b80 | 5 | use std::io::Result; |
1e2d00b6 | 6 | use std::env::current_dir; |
ea529736 | 7 | use std::fs::{create_dir_all, remove_dir_all}; |
8d4fac52 RBR |
8 | |
9 | use crate::gemini_parser::parse; | |
1e2d00b6 | 10 | use crate::file_finder::find_files; |
4fd89b80 | 11 | use crate::file_handler::FileHandler; |
8d4fac52 | 12 | |
4fd89b80 | 13 | fn main() -> Result<()> { |
8d4fac52 RBR |
14 | let gemini_source = "# Test\n## 2nd H\na line\n another line\n```\npreformat\n=> preformat\n```\n=> http://lol.com\n=> http://lol.com lol\n* lol\nbla\n* lol\n* lmao\n> blabla\n> blabla"; |
15 | let html = parse(gemini_source); | |
1e2d00b6 RBR |
16 | println!("{}", html); |
17 | ||
4fd89b80 RBR |
18 | let source = current_dir()?; |
19 | let source_name = source.file_name().unwrap().to_string_lossy(); | |
20 | let parent = source.parent().unwrap(); | |
21 | let destination_name = format!("{}_html", source_name); | |
22 | let destination = parent.join(destination_name); | |
23 | ||
24 | // Step 1. Identify the files | |
25 | let files = find_files(&source); | |
26 | ||
27 | // Step 2. Prepare the target priority | |
ea529736 RBR |
28 | match remove_dir_all(&destination) { |
29 | _ => {} | |
30 | }; | |
4fd89b80 RBR |
31 | create_dir_all(&destination)?; |
32 | ||
1e2d00b6 | 33 | println!("Found {} files", files.len()); |
4fd89b80 RBR |
34 | |
35 | // Step 3. Load the layout | |
36 | let mut file_handler = FileHandler::default(); | |
37 | file_handler.get_layout_or_panic(&files); | |
38 | ||
39 | // Step 4. Process all files | |
40 | file_handler.handle_all(&source, &destination, &files); | |
41 | Ok(()) | |
8d4fac52 | 42 | } |