Fixed parsing of non YAML front matter. Fixes #350

This commit is contained in:
benweet 2014-03-14 14:57:22 +00:00
parent 865982e707
commit ca05d89a10

View File

@ -1,7 +1,8 @@
define([
"underscore",
"classes/Extension",
"yaml-js",
], function(Extension, YAML) {
], function(_, Extension, YAML) {
var yamlFrontMatterParser = new Extension("yamlFrontMatterParser", "YAML front matter");
@ -26,10 +27,16 @@ define([
fileDesc.frontMatter = undefined;
try {
fileDesc.frontMatter = YAML.parse(yaml);
if(!_.isObject(fileDesc.frontMatter)) {
fileDesc.frontMatter = undefined;
}
fileDesc.frontMatter._yaml = yaml;
fileDesc.frontMatter._frontMatter = results[1];
}
catch (e) {}
catch (e) {
eventMgr.onMarkdownTrim(0);
return text;
}
}
eventMgr.onMarkdownTrim((results[1] || '').length);
return results[3];