markdown_formatter/
lib.rs1pub mod args;
2pub mod formatter;
3use formatter::{
4 character::remove_white_space_around_enclosed_url,
5 markdown::preamble::split_preamble,
6 punctuation::{convert_colon, convert_parenthesis, convert_semicolon},
7};
8
9pub fn format(args: &args::Args, content: String) -> String {
14 let (preamble_content, mut content) = split_preamble(&content);
15
16 if args.flag_colon {
17 content = convert_colon(content, true);
19 }
20
21 if args.flag_strip_enclosed_url {
22 content = remove_white_space_around_enclosed_url(content);
24 }
25
26 if args.flag_semicolon {
27 content = convert_semicolon(content, true);
29 }
30 if args.flag_parenthesis {
31 content = convert_parenthesis(content, true);
33 }
34
35 content = formatter::character::add_space_between_words_and_chinese_symbols(content, true);
36 content = formatter::markdown::markdown_pipeline(content, &args);
37
38 if let Some(preamble_content) = preamble_content {
39 let mut result = String::from(format!("---\n{}\n---\n\n", preamble_content.trim()));
40 result.push_str(content.trim());
41 content = result;
42 } else {
43 content = content.trim().to_string();
44 }
45
46 content
47}