 ff53bccc0f
			
		
	
	ff53bccc0f
	
	
	
		
			
			* add docsmg tool * moved to the correct scripts directory * removed test files * added install script and readme draft to docsmg * fix install script * fixed issues * Revert "fixed issues" This reverts commita51192025f. * Revert "Revert "fixed issues"" This reverts commitab68918fea. * added dotenv and updated readme * fixed install script * update readme to ensure that new installers of rust have envs loaded * changed docsmg from using .env to docsmg.env * fixed docsmg to fix internal links in file * fixed docsmg migrate not making directories to file * fixed docsmg migrate trying to read pngs to string * did stuff * fix links * fix links 2 * fix links 3 * fix links * fix links * fix links * fix links * fix links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed docsmg migrate replacing links * fixed links * update docsmg fixing links * update docsmg fixing links * update docsmg fixing links * update docsmg removing empty directories * remove changed docs * Revert "remove changed docs" This reverts commit2e21a5bac8. * remove changed docs * fixed readme --------- Signed-off-by: Tana M Berry <tanamarieberry@yahoo.com> Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| use std::{fs::read_to_string, path::PathBuf};
 | |
| 
 | |
| use regex::{Captures, Regex};
 | |
| 
 | |
| use crate::recurse_directory;
 | |
| 
 | |
| pub fn shorten_all_external_links(migrate_path: PathBuf) {
 | |
|     let files = recurse_directory(migrate_path.clone());
 | |
|     for file in files {
 | |
|         let file = migrate_path.join(file);
 | |
|         let absolute_file = file.clone().canonicalize().unwrap();
 | |
|         let contents = if let Ok(x) = read_to_string(file) {
 | |
|             x
 | |
|         } else {
 | |
|             continue;
 | |
|         };
 | |
|         let re = Regex::new(r"\[(?<name>.*)\]\((?<link>.*)\)").unwrap();
 | |
|         let captures: Vec<Captures> = re.captures_iter(&contents).collect();
 | |
|         for capture in captures {
 | |
|             let link = &capture["link"];
 | |
|             let link = PathBuf::from(link);
 | |
|             let absolute_link = absolute_file
 | |
|                 .clone()
 | |
|                 .parent()
 | |
|                 .unwrap()
 | |
|                 .join(link)
 | |
|                 .canonicalize()
 | |
|                 .unwrap();
 | |
|             shorten_link_relative_to(absolute_link.clone(), absolute_file.clone());
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| fn shorten_link_relative_to(link_to_shorten: PathBuf, relative_to: PathBuf) {}
 |