Fixed parsing of non YAML front matter. Fixes #350
This commit is contained in:
parent
865982e707
commit
ca05d89a10
@ -1,7 +1,8 @@
|
|||||||
define([
|
define([
|
||||||
|
"underscore",
|
||||||
"classes/Extension",
|
"classes/Extension",
|
||||||
"yaml-js",
|
"yaml-js",
|
||||||
], function(Extension, YAML) {
|
], function(_, Extension, YAML) {
|
||||||
|
|
||||||
var yamlFrontMatterParser = new Extension("yamlFrontMatterParser", "YAML front matter");
|
var yamlFrontMatterParser = new Extension("yamlFrontMatterParser", "YAML front matter");
|
||||||
|
|
||||||
@ -26,10 +27,16 @@ define([
|
|||||||
fileDesc.frontMatter = undefined;
|
fileDesc.frontMatter = undefined;
|
||||||
try {
|
try {
|
||||||
fileDesc.frontMatter = YAML.parse(yaml);
|
fileDesc.frontMatter = YAML.parse(yaml);
|
||||||
|
if(!_.isObject(fileDesc.frontMatter)) {
|
||||||
|
fileDesc.frontMatter = undefined;
|
||||||
|
}
|
||||||
fileDesc.frontMatter._yaml = yaml;
|
fileDesc.frontMatter._yaml = yaml;
|
||||||
fileDesc.frontMatter._frontMatter = results[1];
|
fileDesc.frontMatter._frontMatter = results[1];
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {
|
||||||
|
eventMgr.onMarkdownTrim(0);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
eventMgr.onMarkdownTrim((results[1] || '').length);
|
eventMgr.onMarkdownTrim((results[1] || '').length);
|
||||||
return results[3];
|
return results[3];
|
||||||
|
Loading…
Reference in New Issue
Block a user