File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ function toLinkText(link: string) {
14
14
return cleanedLink [ 0 ] . toUpperCase ( ) + cleanedLink . slice ( 1 ) ;
15
15
}
16
16
17
+ function toFileText ( link : string ) {
18
+ const cleanedLink = link . trim ( ) . replace ( / / g, '_' ) ;
19
+ return cleanedLink [ 0 ] . toUpperCase ( ) + cleanedLink . slice ( 1 ) ;
20
+ }
21
+
17
22
function parseDimensions ( dimStr : string ) {
18
23
const regex = / ( \d * ) (?: x ( \d * ) ) ? p x / ;
19
24
const match = dimStr . match ( regex ) ;
@@ -267,12 +272,12 @@ export function parse(data: string, config: Config = {}): Result {
267
272
. replace ( re ( r `(?<!{) {{ \s* ([^#{}|]+?) \s* (\|[^{}]+)? }} (?!})` ) , ( _ , title , params = '' ) => {
268
273
if ( params . includes ( '{{' ) ) return _ ;
269
274
270
- const templateFile = title . trim ( ) . replace ( / / g , '_' ) ;
275
+ const templateFile = toFileText ( title ) ;
271
276
const page : string = paths . join ( templatesFolder , templateFile ) ;
272
277
let content = '' ;
273
278
// Try retrieve template content
274
279
try {
275
- content = fs . readFileSync ( toLinkText ( page ) + '.wiki' , { encoding : 'utf8' } )
280
+ content = fs . readFileSync ( page + '.wiki' , { encoding : 'utf8' } )
276
281
}
277
282
catch {
278
283
// Return redlink if template doesn't exist
You can’t perform that action at this time.
0 commit comments