Added trimmedMarkdownDocument as template variable

This commit is contained in:
benweet 2013-10-22 23:14:26 +01:00
parent a4caa0e216
commit a4938d80cd
3 changed files with 7 additions and 4 deletions

View File

@ -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,

View File

@ -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) {}
}

View File

@ -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