@@ -6,6 +6,7 @@ use eyre::{bail, eyre, Context, Result};
6
6
use indoc:: formatdoc;
7
7
use inquire:: Text ;
8
8
use regex:: Regex ;
9
+ use titlecase:: titlecase;
9
10
use tracing:: { debug, info, instrument, warn} ;
10
11
use whoami:: username;
11
12
@@ -71,9 +72,11 @@ fn generate_content_title(base_path: &Path, full_path: &Path) -> String {
71
72
. iter ( )
72
73
. filter ( |c| * c != "index.norg" )
73
74
. map ( |c| {
74
- c. to_string_lossy ( )
75
- . trim_end_matches ( ".norg" )
76
- . replace ( [ '-' , '_' ] , " " )
75
+ titlecase (
76
+ & c. to_string_lossy ( )
77
+ . trim_end_matches ( ".norg" )
78
+ . replace ( [ '-' , '_' ] , " " ) ,
79
+ )
77
80
} )
78
81
. collect :: < Vec < _ > > ( ) ;
79
82
@@ -98,7 +101,7 @@ fn generate_content_title(base_path: &Path, full_path: &Path) -> String {
98
101
#[ instrument( level = "debug" , skip( path, title) ) ]
99
102
async fn create_norg_document ( path : & Path , title : & str ) -> Result < ( ) > {
100
103
debug ! ( "Creating new norg document: {}" , path. display( ) ) ;
101
- let re = Regex :: new ( ", ? ") ?;
104
+ let re = Regex :: new ( r"[,\s+?]+ ") ?;
102
105
let creation_date = Local :: now ( ) . to_rfc3339_opts ( SecondsFormat :: Secs , false ) ;
103
106
104
107
// Prompt norg file metadata
@@ -145,8 +148,8 @@ async fn create_norg_document(path: &Path, title: &str) -> Result<()> {
145
148
* {title}
146
149
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
147
150
labore et dolore magna aliqua. Lobortis scelerisque fermentum dui faucibus in ornare."# ,
148
- re. replace ( & authors, "\n " ) ,
149
- re. replace ( & categories, "\n " ) ,
151
+ re. replace_all ( & authors, "\n " ) ,
152
+ re. replace_all ( & categories, "\n " ) ,
150
153
) ;
151
154
tokio:: fs:: write ( path, content)
152
155
. await
0 commit comments