mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
fix garbage in markdown output
This commit is contained in:
parent
fc9dd5d743
commit
0214793740
|
@ -85,13 +85,13 @@ function copydom(src, dst, lv) {
|
||||||
|
|
||||||
var rpl = [];
|
var rpl = [];
|
||||||
for (var a = sc.length - 1; a >= 0; a--) {
|
for (var a = sc.length - 1; a >= 0; a--) {
|
||||||
var st = sc[a].tagName,
|
var st = sc[a].tagName || sc[a].nodeType,
|
||||||
dt = dc[a].tagName;
|
dt = dc[a].tagName || dc[a].nodeType;
|
||||||
|
|
||||||
if (st !== dt) {
|
if (st !== dt) {
|
||||||
dbg("replace L%d (%d/%d) type %s/%s", lv, a, sc.length, st, dt);
|
dbg("replace L%d (%d/%d) type %s/%s", lv, a, sc.length, st, dt);
|
||||||
rpl.push(a);
|
dst.innerHTML = src.innerHTML;
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sa = sc[a].attributes || [],
|
var sa = sc[a].attributes || [],
|
||||||
|
@ -140,8 +140,11 @@ function copydom(src, dst, lv) {
|
||||||
// repl is reversed; build top-down
|
// repl is reversed; build top-down
|
||||||
var nbytes = 0;
|
var nbytes = 0;
|
||||||
for (var a = rpl.length - 1; a >= 0; a--) {
|
for (var a = rpl.length - 1; a >= 0; a--) {
|
||||||
var html = sc[rpl[a]].outerHTML;
|
var i = rpl[a],
|
||||||
dc[rpl[a]].outerHTML = html;
|
prop = sc[i].nodeType == 1 ? 'outerHTML' : 'nodeValue';
|
||||||
|
|
||||||
|
var html = sc[i][prop];
|
||||||
|
dc[i][prop] = html;
|
||||||
nbytes += html.length;
|
nbytes += html.length;
|
||||||
}
|
}
|
||||||
if (nbytes > 0)
|
if (nbytes > 0)
|
||||||
|
|
|
@ -222,15 +222,15 @@ if (!String.prototype.endsWith)
|
||||||
return this.substring(this_len - search.length, this_len) === search;
|
return this.substring(this_len - search.length, this_len) === search;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!String.startsWith)
|
if (!String.prototype.startsWith)
|
||||||
String.prototype.startsWith = function (s, i) {
|
String.prototype.startsWith = function (s, i) {
|
||||||
i = i > 0 ? i | 0 : 0;
|
i = i > 0 ? i | 0 : 0;
|
||||||
return this.substring(i, i + s.length) === s;
|
return this.substring(i, i + s.length) === s;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!String.trimEnd)
|
if (!String.prototype.trimEnd)
|
||||||
String.prototype.trimEnd = String.prototype.trimRight = function () {
|
String.prototype.trimEnd = String.prototype.trimRight = function () {
|
||||||
return this.replace(/[ \t\r\n]+$/m, '');
|
return this.replace(/[ \t\r\n]+$/, '');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Element.prototype.matches)
|
if (!Element.prototype.matches)
|
||||||
|
|
Loading…
Reference in a new issue