diff --git a/public/res/eventMgr.js b/public/res/eventMgr.js index e8eb6a4d..fe91e5b7 100644 --- a/public/res/eventMgr.js +++ b/public/res/eventMgr.js @@ -234,8 +234,9 @@ define([ html += elt.innerHTML; }); html = html.replace(/^
<\/div>\n\n/gm, ''); - html = html.replace(/ .*<\/span> /g, ''); - onPreviewFinished(utils.trim(html)); + var htmlWithComments = utils.trim(html); + var htmlWithoutComments = htmlWithComments.replace(/ .*?<\/span> /g, ''); + onPreviewFinished(htmlWithComments, htmlWithoutComments); }); }; callback(function() { diff --git a/public/res/extensions/buttonHtmlCode.js b/public/res/extensions/buttonHtmlCode.js index 80723928..9ec660cc 100644 --- a/public/res/extensions/buttonHtmlCode.js +++ b/public/res/extensions/buttonHtmlCode.js @@ -36,13 +36,14 @@ define([ }; var textareaElt; - buttonHtmlCode.onPreviewFinished = function(html) { + buttonHtmlCode.onPreviewFinished = function(htmlWithComments, htmlWithoutComments) { try { var htmlCode = _.template(buttonHtmlCode.config.template, { documentTitle: selectedFileDesc.title, documentMarkdown: selectedFileDesc.content, strippedDocumentMarkdown: selectedFileDesc.content.substring(selectedFileDesc.frontMatter ? selectedFileDesc.frontMatter._frontMatter.length : 0), - documentHTML: html, + documentHTML: htmlWithoutComments, + documentHTMLWithComments: htmlWithComments, frontMatter: selectedFileDesc.frontMatter, publishAttributes: undefined, }); diff --git a/public/res/html/settingsTemplateTooltip.html b/public/res/html/settingsTemplateTooltip.html index 40fb1cbe..1ab144bf 100644 --- a/public/res/html/settingsTemplateTooltip.html +++ b/public/res/html/settingsTemplateTooltip.html @@ -9,6 +9,8 @@ Available variables: strippedDocumentMarkdown: document without front matter
  • documentHTML: document in HTML format
  • +
  • + documentHTMLWithComments: HTML format with comments
  • frontMatter: YAML front matter object (undefined if not present)
  • diff --git a/public/res/publisher.js b/public/res/publisher.js index e2458690..8c8c4971 100644 --- a/public/res/publisher.js +++ b/public/res/publisher.js @@ -67,7 +67,8 @@ define([ documentTitle: fileDesc.title, documentMarkdown: fileDesc.content, strippedDocumentMarkdown: fileDesc.content.substring(fileDesc.frontMatter ? fileDesc.frontMatter._frontMatter.length : 0), - documentHTML: html, + documentHTML: html.withoutComments, + documentHTMLWithComments: html.withComments, frontMatter: fileDesc.frontMatter, publishAttributes: publishAttributes }); @@ -90,7 +91,7 @@ define([ return fileDesc.content; } else if(publishAttributes.format == "html") { - return html; + return html.withoutComments; } else { return publisher.applyTemplate(fileDesc, publishAttributes, html); @@ -134,9 +135,12 @@ define([ } // Get the html from the onPreviewFinished callback - var previewHtml; - eventMgr.addListener("onPreviewFinished", function(html) { - previewHtml = html; + var currentHTML; + eventMgr.addListener("onPreviewFinished", function(htmlWithComments, htmlWithoutComments) { + currentHTML = { + withComments: htmlWithComments, + withoutComments: htmlWithoutComments + }; }); // Listen to offline status changes @@ -155,7 +159,7 @@ define([ publishRunning = true; eventMgr.onPublishRunning(true); publishFileDesc = fileMgr.currentFile; - publishHTML = previewHtml; + publishHTML = currentHTML; publishAttributesList = _.values(publishFileDesc.publishLocations); publishLocation(function(errorFlag) { publishRunning = false; @@ -224,8 +228,7 @@ define([ // Perform provider's publishing var fileDesc = fileMgr.currentFile; - var html = previewHtml; - var content = getPublishContent(fileDesc, publishAttributes, html); + var content = getPublishContent(fileDesc, publishAttributes, currentHTML); var title = (fileDesc.frontMatter && fileDesc.frontMatter.title) || fileDesc.title; provider.publish(publishAttributes, fileDesc.frontMatter, title, content, function(error) { if(error === undefined) { @@ -311,18 +314,18 @@ define([ }); $(".action-download-html").click(function() { var title = fileMgr.currentFile.title; - utils.saveAs(previewHtml, title + ".html"); + utils.saveAs(currentHTML.withoutComments, title + ".html"); }); $(".action-download-template").click(function() { 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")); }); $(".action-download-pdf").click(function() { var fileDesc = fileMgr.currentFile; var content = publisher.applyTemplate(fileDesc, { customTmpl: settings.pdfTemplate - }, previewHtml); + }, currentHTML); var task = new AsyncTask(); var pdf; task.onRun(function() { diff --git a/public/res/styles/main.less b/public/res/styles/main.less index 6f352435..7a87fba5 100644 --- a/public/res/styles/main.less +++ b/public/res/styles/main.less @@ -115,7 +115,7 @@ @modal-footer-border-color: @secondary-border-color-light; @modal-content-separator-color: @secondary-border-color-lighter; @modal-backdrop-bg: desaturate(@tertiary, 90%); -@tooltip-max-width: 240px; +@tooltip-max-width: 250px; @close-color: @secondary-color-darkest; @popover-bg: @secondary-bg; @popover-border-color: @secondary-border-color;