diff --git a/public/js/extra.js b/public/js/extra.js index 412a73e2..b731770f 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -430,10 +430,7 @@ function postProcess(code) { return result; } -//extract markdown body to html and compile to template -function exportToHTML(view) { - var title = renderTitle(ui.area.markdown); - var filename = renderFilename(ui.area.markdown) + '.html'; +function generateCleanHTML(view) { var src = view.clone(); var eles = src.find('*'); //remove syncscroll parts @@ -469,6 +466,25 @@ function exportToHTML(view) { $(value).html(iframe); } }); + return src; +} + +function exportToRawHTML(view) { + var filename = renderFilename(ui.area.markdown) + '.html'; + var src = generateCleanHTML(view); + $(src).find('a.anchor').remove(); + var html = src[0].outerHTML; + var blob = new Blob([html], { + type: "text/html;charset=utf-8" + }); + saveAs(blob, filename); +} + +//extract markdown body to html and compile to template +function exportToHTML(view) { + var title = renderTitle(ui.area.markdown); + var filename = renderFilename(ui.area.markdown) + '.html'; + var src = generateCleanHTML(view); //generate toc var toc = $('#toc').clone(); toc.find('*').removeClass('active'); diff --git a/public/js/index.js b/public/js/index.js index 27a3398b..2da07b5d 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -505,7 +505,8 @@ var ui = { publish: $(".ui-publish"), download: { markdown: $(".ui-download-markdown"), - html: $(".ui-download-html") + html: $(".ui-download-html"), + rawhtml: $(".ui-download-raw-html") }, export: { dropbox: $(".ui-save-dropbox"), @@ -1174,6 +1175,12 @@ ui.toolbar.download.html.click(function (e) { e.stopPropagation(); exportToHTML(ui.area.markdown); }); +// raw html +ui.toolbar.download.rawhtml.click(function (e) { + e.preventDefault(); + e.stopPropagation(); + exportToRawHTML(ui.area.markdown); +}); //export to dropbox ui.toolbar.export.dropbox.click(function () { var filename = renderFilename(ui.area.markdown) + '.md'; diff --git a/public/views/header.ejs b/public/views/header.ejs index b00c2db5..739b37ad 100644 --- a/public/views/header.ejs +++ b/public/views/header.ejs @@ -68,6 +68,8 @@
  • HTML
  • +
  • Raw HTML +
  • Help
  • @@ -163,6 +165,8 @@
  • HTML
  • +
  • Raw HTML +