File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -323,14 +323,16 @@ export default class MediaDbPlugin extends Plugin {
323323 fileContent = `---\n${ this . settings . useCustomYamlStringifier ? YAMLConverter . toYaml ( fileMetadata ) : stringifyYaml ( fileMetadata ) } ---\n` + fileContent ;
324324 return fileContent ;
325325 } else {
326- const parts = template . split ( ' ---' ) ;
326+ const frontMatterRegex = / ^ - - - * \n ( [ \s \S ] * ? ) \n - - - \h * / ;
327327
328- if ( parts . length < 3 ) {
328+ const match = template . match ( frontMatterRegex ) ;
329+
330+ if ( ! match || match . length !== 2 ) {
329331 throw new Error ( 'Cannot find YAML front matter for template.' ) ;
330332 }
331333
332- let frontMatter = parseYaml ( parts [ 1 ] ) ;
333- let fileContent : string = parts [ 2 ] ;
334+ let frontMatter = parseYaml ( match [ 1 ] ) ;
335+ let fileContent : string = template . replace ( frontMatterRegex , '' ) ;
334336
335337 // Updating a previous file
336338 if ( options . attachFile ) {
You can’t perform that action at this time.
0 commit comments