diff --git a/www/pad/export.js b/www/pad/export.js
index aac4ae4aa..a4bda9599 100644
--- a/www/pad/export.js
+++ b/www/pad/export.js
@@ -94,6 +94,18 @@ define([
return void cb(blob);
}
if (ext === ".md") {
+ let strikethrough = {
+ filter: ['s', 'del', 'strike'],
+ replacement: function (content) {
+ return '~' + content + '~';
+ }
+ };
+ let underline = {
+ filter: ['u'],
+ replacement: function (content) {
+ return '' + content + '';
+ }
+ };
var md = Turndown({
headingStyle: 'atx'
}).addRule('table', {
@@ -111,29 +123,15 @@ define([
for (var i =0; i < rowLength; i++) {
var cell = rowContent[i];
var cellContent = Array.from(cell.childNodes);
- if (cellContent.length > 1) {
- var cellString = '';
- cellContent.forEach(function(string) {
- var stringContent = string.childNodes.length ? string.innerHTML : string.textContent;
- if (string.nodeType === 3) {
- cellString += stringContent;
- } else if (string.nodeName === "BR") {
- cellString += '
';
- } else if (string.nodeName === "EM") {
- cellString += '' + stringContent + '';
- } else if (string.nodeName === "STRONG") {
- cellString += '' + stringContent + '';
- } else if (string.nodeName === "U") {
- cellString += '' + stringContent + '';
- } else if (string.nodeName === "S") {
- cellString += '~' + stringContent + '~';
- }
- });
- row += cellString + ' |';
- } else if (cellContent[0].nodeName === "BR") {
- row += '| |';
- } else {
- row += cellContent[0].innerHTML + ' |';
+ if ((cellContent.length === 1 && cellContent[0].nodeName === "BR") || !cellContent.length) {
+ row += '|';
+ } else if (cellContent.length >= 1) {
+ row += Turndown({
+ headingStyle: 'atx'
+ }).addRule('strikethrough', strikethrough)
+ .addRule('underline', underline)
+ .turndown(cell.innerHTML).replaceAll('\n', '
');
+ row += '|';
}
}
var newRow = row.concat('\n');
@@ -146,17 +144,8 @@ define([
});
});
return table;
- }}).addRule('strikethrough', {
- filter: ['s', 'del', 'strike'],
- replacement: function (content) {
- return '~' + content + '~';
- }
- }).addRule('strikethrough', {
- filter: ['u'],
- replacement: function (content) {
- return '' + content + '';
- }
- })
+ }}).addRule('strikethrough', strikethrough)
+ .addRule('underline', underline)
.turndown(toExport);
var mdBlob = new Blob([md], {
type: 'text/markdown;charset=utf-8'