Added trimmedMarkdownDocument as template variable
This commit is contained in:
parent
a4caa0e216
commit
a4938d80cd
@ -41,6 +41,7 @@ define([
|
||||
var htmlCode = _.template(buttonHtmlCode.config.template, {
|
||||
documentTitle: selectedFileDesc.title,
|
||||
documentMarkdown: selectedFileDesc.content,
|
||||
trimmedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0),
|
||||
documentHTML: html,
|
||||
frontMatter: selectedFileDesc.frontMatter,
|
||||
publishAttributes: undefined,
|
||||
|
@ -15,18 +15,19 @@ define([
|
||||
fileDesc = fileDescParam;
|
||||
};
|
||||
|
||||
var regex = /^(\s*-{3}\s*\n([\w\W]+?)\n\s*-{3}\s*\n)?([\w\W]*)/;
|
||||
var regex = /^(\s*-{3}\s*\n([\w\W]+?)\n\s*-{3}\s*\n)?([\w\W]*)$/;
|
||||
yamlFrontMatterParser.onPagedownConfigure = function(editor) {
|
||||
var converter = editor.getConverter();
|
||||
converter.hooks.chain("preConversion", function(text) {
|
||||
var results = regex.exec(text),
|
||||
yaml;
|
||||
var results = regex.exec(text);
|
||||
var yaml = results[2];
|
||||
|
||||
if ((yaml = results[2]) && (!fileDesc.frontMatter || fileDesc.frontMatter._yaml != yaml)) {
|
||||
if (yaml && (!fileDesc.frontMatter || fileDesc.frontMatter._yaml != yaml)) {
|
||||
fileDesc.frontMatter = undefined;
|
||||
try {
|
||||
fileDesc.frontMatter = YAML.parse(yaml);
|
||||
fileDesc.frontMatter._yaml = yaml;
|
||||
fileDesc.frontMatter._frontMatter = results[1];
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ define([
|
||||
return _.template(template, {
|
||||
documentTitle: fileDesc.title,
|
||||
documentMarkdown: fileDesc.content,
|
||||
trimmedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0),
|
||||
documentHTML: html,
|
||||
frontMatter: fileDesc.frontMatter,
|
||||
publishAttributes: publishAttributes
|
||||
|
Loading…
Reference in New Issue
Block a user