Added template variable documentHTMLWithComments. Fixes #310
This commit is contained in:
parent
f9322ffee7
commit
5a79f568fa
@ -234,8 +234,9 @@ define([
|
|||||||
html += elt.innerHTML;
|
html += elt.innerHTML;
|
||||||
});
|
});
|
||||||
html = html.replace(/^<div class="se-section-delimiter"><\/div>\n\n/gm, '');
|
html = html.replace(/^<div class="se-section-delimiter"><\/div>\n\n/gm, '');
|
||||||
html = html.replace(/ <span class="comment label label-danger">.*<\/span> /g, '');
|
var htmlWithComments = utils.trim(html);
|
||||||
onPreviewFinished(utils.trim(html));
|
var htmlWithoutComments = htmlWithComments.replace(/ <span class="comment label label-danger">.*?<\/span> /g, '');
|
||||||
|
onPreviewFinished(htmlWithComments, htmlWithoutComments);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
callback(function() {
|
callback(function() {
|
||||||
|
@ -36,13 +36,14 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var textareaElt;
|
var textareaElt;
|
||||||
buttonHtmlCode.onPreviewFinished = function(html) {
|
buttonHtmlCode.onPreviewFinished = function(htmlWithComments, htmlWithoutComments) {
|
||||||
try {
|
try {
|
||||||
var htmlCode = _.template(buttonHtmlCode.config.template, {
|
var htmlCode = _.template(buttonHtmlCode.config.template, {
|
||||||
documentTitle: selectedFileDesc.title,
|
documentTitle: selectedFileDesc.title,
|
||||||
documentMarkdown: selectedFileDesc.content,
|
documentMarkdown: selectedFileDesc.content,
|
||||||
strippedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0),
|
strippedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0),
|
||||||
documentHTML: html,
|
documentHTML: htmlWithoutComments,
|
||||||
|
documentHTMLWithComments: htmlWithComments,
|
||||||
frontMatter: selectedFileDesc.frontMatter,
|
frontMatter: selectedFileDesc.frontMatter,
|
||||||
publishAttributes: undefined,
|
publishAttributes: undefined,
|
||||||
});
|
});
|
||||||
|
@ -9,6 +9,8 @@ Available variables:
|
|||||||
<b>strippedDocumentMarkdown</b>: document without front matter</li>
|
<b>strippedDocumentMarkdown</b>: document without front matter</li>
|
||||||
<li>
|
<li>
|
||||||
<b>documentHTML</b>: document in HTML format</li>
|
<b>documentHTML</b>: document in HTML format</li>
|
||||||
|
<li>
|
||||||
|
<b>documentHTMLWithComments</b>: HTML format with comments</li>
|
||||||
<li>
|
<li>
|
||||||
<b>frontMatter</b>: YAML front matter object (undefined if not present)</li>
|
<b>frontMatter</b>: YAML front matter object (undefined if not present)</li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -67,7 +67,8 @@ define([
|
|||||||
documentTitle: fileDesc.title,
|
documentTitle: fileDesc.title,
|
||||||
documentMarkdown: fileDesc.content,
|
documentMarkdown: fileDesc.content,
|
||||||
strippedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0),
|
strippedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0),
|
||||||
documentHTML: html,
|
documentHTML: html.withoutComments,
|
||||||
|
documentHTMLWithComments: html.withComments,
|
||||||
frontMatter: fileDesc.frontMatter,
|
frontMatter: fileDesc.frontMatter,
|
||||||
publishAttributes: publishAttributes
|
publishAttributes: publishAttributes
|
||||||
});
|
});
|
||||||
@ -90,7 +91,7 @@ define([
|
|||||||
return fileDesc.content;
|
return fileDesc.content;
|
||||||
}
|
}
|
||||||
else if(publishAttributes.format == "html") {
|
else if(publishAttributes.format == "html") {
|
||||||
return html;
|
return html.withoutComments;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return publisher.applyTemplate(fileDesc, publishAttributes, html);
|
return publisher.applyTemplate(fileDesc, publishAttributes, html);
|
||||||
@ -134,9 +135,12 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the html from the onPreviewFinished callback
|
// Get the html from the onPreviewFinished callback
|
||||||
var previewHtml;
|
var currentHTML;
|
||||||
eventMgr.addListener("onPreviewFinished", function(html) {
|
eventMgr.addListener("onPreviewFinished", function(htmlWithComments, htmlWithoutComments) {
|
||||||
previewHtml = html;
|
currentHTML = {
|
||||||
|
withComments: htmlWithComments,
|
||||||
|
withoutComments: htmlWithoutComments
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to offline status changes
|
// Listen to offline status changes
|
||||||
@ -155,7 +159,7 @@ define([
|
|||||||
publishRunning = true;
|
publishRunning = true;
|
||||||
eventMgr.onPublishRunning(true);
|
eventMgr.onPublishRunning(true);
|
||||||
publishFileDesc = fileMgr.currentFile;
|
publishFileDesc = fileMgr.currentFile;
|
||||||
publishHTML = previewHtml;
|
publishHTML = currentHTML;
|
||||||
publishAttributesList = _.values(publishFileDesc.publishLocations);
|
publishAttributesList = _.values(publishFileDesc.publishLocations);
|
||||||
publishLocation(function(errorFlag) {
|
publishLocation(function(errorFlag) {
|
||||||
publishRunning = false;
|
publishRunning = false;
|
||||||
@ -224,8 +228,7 @@ define([
|
|||||||
|
|
||||||
// Perform provider's publishing
|
// Perform provider's publishing
|
||||||
var fileDesc = fileMgr.currentFile;
|
var fileDesc = fileMgr.currentFile;
|
||||||
var html = previewHtml;
|
var content = getPublishContent(fileDesc, publishAttributes, currentHTML);
|
||||||
var content = getPublishContent(fileDesc, publishAttributes, html);
|
|
||||||
var title = (fileDesc.frontMatter && fileDesc.frontMatter.title) || fileDesc.title;
|
var title = (fileDesc.frontMatter && fileDesc.frontMatter.title) || fileDesc.title;
|
||||||
provider.publish(publishAttributes, fileDesc.frontMatter, title, content, function(error) {
|
provider.publish(publishAttributes, fileDesc.frontMatter, title, content, function(error) {
|
||||||
if(error === undefined) {
|
if(error === undefined) {
|
||||||
@ -311,18 +314,18 @@ define([
|
|||||||
});
|
});
|
||||||
$(".action-download-html").click(function() {
|
$(".action-download-html").click(function() {
|
||||||
var title = fileMgr.currentFile.title;
|
var title = fileMgr.currentFile.title;
|
||||||
utils.saveAs(previewHtml, title + ".html");
|
utils.saveAs(currentHTML.withoutComments, title + ".html");
|
||||||
});
|
});
|
||||||
$(".action-download-template").click(function() {
|
$(".action-download-template").click(function() {
|
||||||
var fileDesc = fileMgr.currentFile;
|
var fileDesc = fileMgr.currentFile;
|
||||||
var content = publisher.applyTemplate(fileDesc, undefined, previewHtml);
|
var content = publisher.applyTemplate(fileDesc, undefined, currentHTML);
|
||||||
utils.saveAs(content, fileDesc.title + (settings.template.indexOf("documentHTML") === -1 ? ".md" : ".html"));
|
utils.saveAs(content, fileDesc.title + (settings.template.indexOf("documentHTML") === -1 ? ".md" : ".html"));
|
||||||
});
|
});
|
||||||
$(".action-download-pdf").click(function() {
|
$(".action-download-pdf").click(function() {
|
||||||
var fileDesc = fileMgr.currentFile;
|
var fileDesc = fileMgr.currentFile;
|
||||||
var content = publisher.applyTemplate(fileDesc, {
|
var content = publisher.applyTemplate(fileDesc, {
|
||||||
customTmpl: settings.pdfTemplate
|
customTmpl: settings.pdfTemplate
|
||||||
}, previewHtml);
|
}, currentHTML);
|
||||||
var task = new AsyncTask();
|
var task = new AsyncTask();
|
||||||
var pdf;
|
var pdf;
|
||||||
task.onRun(function() {
|
task.onRun(function() {
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
@modal-footer-border-color: @secondary-border-color-light;
|
@modal-footer-border-color: @secondary-border-color-light;
|
||||||
@modal-content-separator-color: @secondary-border-color-lighter;
|
@modal-content-separator-color: @secondary-border-color-lighter;
|
||||||
@modal-backdrop-bg: desaturate(@tertiary, 90%);
|
@modal-backdrop-bg: desaturate(@tertiary, 90%);
|
||||||
@tooltip-max-width: 240px;
|
@tooltip-max-width: 250px;
|
||||||
@close-color: @secondary-color-darkest;
|
@close-color: @secondary-color-darkest;
|
||||||
@popover-bg: @secondary-bg;
|
@popover-bg: @secondary-bg;
|
||||||
@popover-border-color: @secondary-border-color;
|
@popover-border-color: @secondary-border-color;
|
||||||
|
Loading…
Reference in New Issue
Block a user