summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-06-17 16:17:37 +0800
committerCheng-Han, Wu2016-06-17 16:17:37 +0800
commitcb1e00d1d149c7a331e9d37cc73927a6aa5c7cf6 (patch)
tree18180fd111bd2db2969ed594e80823f52ec9880b
parent4d244763164eb88638aec85d85529ea49feb0f94 (diff)
Add support of exporting raw html
-rw-r--r--public/js/extra.js24
-rw-r--r--public/js/index.js9
-rw-r--r--public/views/header.ejs4
3 files changed, 32 insertions, 5 deletions
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 @@
</li>
<li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
</li>
+ <li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> Raw HTML</a>
+ </li>
<li class="divider"></li>
<li role="presentation"><a role="menuitem" class="ui-help" href="#" data-toggle="modal" data-target=".help-modal"><i class="fa fa-question-circle fa-fw"></i> Help</a>
</li>
@@ -163,6 +165,8 @@
</li>
<li role="presentation"><a role="menuitem" class="ui-download-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> HTML</a>
</li>
+ <li role="presentation"><a role="menuitem" class="ui-download-raw-html" tabindex="-1" href="#" target="_self"><i class="fa fa-file-code-o fa-fw"></i> Raw HTML</a>
+ </li>
</ul>
</li>
</ul>