mirror of
https://github.com/aureliendavid/rsspreview.git
synced 2025-08-29 06:45:37 +00:00
reparse xhtml content to display properly
This commit is contained in:
parent
99c56f041b
commit
d98a57aa24
@ -72,38 +72,37 @@
|
|||||||
let tohtml = el.getElementsByClassName('feedRawContent');
|
let tohtml = el.getElementsByClassName('feedRawContent');
|
||||||
|
|
||||||
for (let i = 0; i < tohtml.length; i++) {
|
for (let i = 0; i < tohtml.length; i++) {
|
||||||
// in case of xhtml the content is already parsed
|
|
||||||
if (tohtml[i].getAttribute('desctype') != 'xhtml') {
|
|
||||||
try {
|
|
||||||
|
|
||||||
let html_txt = '';
|
try {
|
||||||
if (tohtml[i].getAttribute('desctype') == 'text/plain') {
|
|
||||||
html_txt = '<div class="feedEntryContent" style="white-space: pre-wrap;" >' + tohtml[i].innerHTML + '</div>';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerText + '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
let html_desc = html_parser.parseFromString(html_txt, 'text/html');
|
let html_txt = '';
|
||||||
let xml_desc = xml_parser.serializeToString(
|
if (tohtml[i].getAttribute('desctype') == 'text/plain') {
|
||||||
html_desc.body.firstChild
|
html_txt = '<div class="feedEntryContent" style="white-space: pre-wrap;" >' + tohtml[i].innerHTML + '</div>';
|
||||||
);
|
|
||||||
|
|
||||||
tohtml[i].insertAdjacentHTML('afterend', xml_desc);
|
|
||||||
tohtml[i].setAttribute('todel', 1);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
console.log(tohtml[i].innerHTML);
|
|
||||||
}
|
}
|
||||||
|
else if (tohtml[i].getAttribute('desctype') == 'xhtml') {
|
||||||
|
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerHTML + '</div>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerText + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
let html_desc = html_parser.parseFromString(html_txt, 'text/html');
|
||||||
|
let xml_desc = xml_parser.serializeToString(
|
||||||
|
html_desc.body.firstChild
|
||||||
|
);
|
||||||
|
|
||||||
|
tohtml[i].insertAdjacentHTML('afterend', xml_desc);
|
||||||
|
tohtml[i].setAttribute('todel', 1);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
console.log(tohtml[i].innerHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
el.querySelectorAll('.feedRawContent').forEach(a => {
|
el.querySelectorAll('.feedRawContent').forEach(a => {
|
||||||
if (a.getAttribute('todel') == '1') {
|
if (a.getAttribute('todel') == '1') {
|
||||||
a.remove();
|
a.remove();
|
||||||
} else if (a.getAttribute('desctype') == 'xhtml') {
|
|
||||||
a.classList.add('feedEntryContent');
|
|
||||||
a.classList.remove('feedRawContent');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user