@@ -74,10 +74,10 @@ public function getCategoryFolder(Folder $notesFolder, string $category) {
74
74
* @param string $title the filename which should be used
75
75
* @param string $suffix the suffix (incl. dot) which should be used
76
76
* @param int $id the id of the note for which the title should be generated
77
- * used to see if the file itself has the title and not a different file for
78
- * checking for filename collisions
77
+ * used to see if the file itself has the title and not a different file for
78
+ * checking for filename collisions
79
79
* @return string the resolved filename to prevent overwriting different
80
- * files with the same title
80
+ * files with the same title
81
81
*/
82
82
public function generateFileName (Folder $ folder , string $ title , string $ suffix , int $ id ) : string {
83
83
$ title = $ this ->getSafeTitle ($ title );
@@ -91,7 +91,7 @@ public function generateFileName(Folder $folder, string $title, string $suffix,
91
91
// increments name (2) to name (3)
92
92
$ match = preg_match ('/\s\((?P<id>\d+)\)$/u ' , $ title , $ matches );
93
93
if ($ match ) {
94
- $ newId = ((int ) $ matches ['id ' ]) + 1 ;
94
+ $ newId = ((int )$ matches ['id ' ]) + 1 ;
95
95
$ baseTitle = preg_replace ('/\s\(\d+\)$/u ' , '' , $ title );
96
96
$ idSuffix = ' ( ' . $ newId . ') ' ;
97
97
} else {
@@ -100,7 +100,7 @@ public function generateFileName(Folder $folder, string $title, string $suffix,
100
100
}
101
101
// make sure there's enough room for the ID suffix before appending or it will be
102
102
// trimmed by getSafeTitle() and could cause infinite recursion
103
- $ newTitle = mb_substr ($ baseTitle , 0 , self ::MAX_TITLE_LENGTH - mb_strlen ($ idSuffix ), " UTF-8 " ) . $ idSuffix ;
103
+ $ newTitle = mb_substr ($ baseTitle , 0 , self ::MAX_TITLE_LENGTH - mb_strlen ($ idSuffix ), ' UTF-8 ' ) . $ idSuffix ;
104
104
return $ this ->generateFileName ($ folder , $ newTitle , $ suffix , $ id );
105
105
}
106
106
}
@@ -117,7 +117,7 @@ public function getSafeTitle(string $content) : string {
117
117
$ title = preg_replace ('/\s/u ' , ' ' , $ title );
118
118
119
119
// using a maximum of 100 chars should be enough
120
- $ title = mb_substr ($ title , 0 , self ::MAX_TITLE_LENGTH , " UTF-8 " );
120
+ $ title = mb_substr ($ title , 0 , self ::MAX_TITLE_LENGTH , ' UTF-8 ' );
121
121
122
122
// ensure that title is not empty
123
123
if (empty ($ title )) {
@@ -151,10 +151,10 @@ private function sanitisePath(string $str) : string {
151
151
152
152
public function stripMarkdown (string $ str ) : string {
153
153
// prepare content: remove markdown characters and empty spaces
154
- $ str = preg_replace ("/^\s*[*+-]\s+/mu " , "" , $ str ); // list item
155
- $ str = preg_replace ("/^#+\s+(.*?)\s*#*$/mu " , " $1 " , $ str ); // headline
156
- $ str = preg_replace (" /^(=+|-+)$/mu " , "" , $ str ); // separate line for headline
157
- $ str = preg_replace ("/(\*+|_+)(.*?) \\1/mu " , " $2 " , $ str ); // emphasis
154
+ $ str = preg_replace ("/^\s*[*+-]\s+/mu " , '' , $ str ); // list item
155
+ $ str = preg_replace ("/^#+\s+(.*?)\s*#*$/mu " , ' $1 ' , $ str ); // headline
156
+ $ str = preg_replace (' /^(=+|-+)$/mu ' , '' , $ str ); // separate line for headline
157
+ $ str = preg_replace ("/(\*+|_+)(.*?) \\1/mu " , ' $2 ' , $ str ); // emphasis
158
158
return $ str ;
159
159
}
160
160
0 commit comments