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, {
|
var htmlCode = _.template(buttonHtmlCode.config.template, {
|
||||||
documentTitle: selectedFileDesc.title,
|
documentTitle: selectedFileDesc.title,
|
||||||
documentMarkdown: selectedFileDesc.content,
|
documentMarkdown: selectedFileDesc.content,
|
||||||
|
trimmedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0),
|
||||||
documentHTML: html,
|
documentHTML: html,
|
||||||
frontMatter: selectedFileDesc.frontMatter,
|
frontMatter: selectedFileDesc.frontMatter,
|
||||||
publishAttributes: undefined,
|
publishAttributes: undefined,
|
||||||
|
@ -15,18 +15,19 @@ define([
|
|||||||
fileDesc = fileDescParam;
|
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) {
|
yamlFrontMatterParser.onPagedownConfigure = function(editor) {
|
||||||
var converter = editor.getConverter();
|
var converter = editor.getConverter();
|
||||||
converter.hooks.chain("preConversion", function(text) {
|
converter.hooks.chain("preConversion", function(text) {
|
||||||
var results = regex.exec(text),
|
var results = regex.exec(text);
|
||||||
yaml;
|
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;
|
fileDesc.frontMatter = undefined;
|
||||||
try {
|
try {
|
||||||
fileDesc.frontMatter = YAML.parse(yaml);
|
fileDesc.frontMatter = YAML.parse(yaml);
|
||||||
fileDesc.frontMatter._yaml = yaml;
|
fileDesc.frontMatter._yaml = yaml;
|
||||||
|
fileDesc.frontMatter._frontMatter = results[1];
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ define([
|
|||||||
return _.template(template, {
|
return _.template(template, {
|
||||||
documentTitle: fileDesc.title,
|
documentTitle: fileDesc.title,
|
||||||
documentMarkdown: fileDesc.content,
|
documentMarkdown: fileDesc.content,
|
||||||
|
trimmedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0),
|
||||||
documentHTML: html,
|
documentHTML: html,
|
||||||
frontMatter: fileDesc.frontMatter,
|
frontMatter: fileDesc.frontMatter,
|
||||||
publishAttributes: publishAttributes
|
publishAttributes: publishAttributes
|
||||||
|
Loading…
Reference in New Issue
Block a user