1
0
mirror of https://github.com/aureliendavid/rsspreview.git synced 2025-08-29 14:55:45 +00:00

reparse xhtml content to display properly

This commit is contained in:
Aurelien David 2019-02-10 11:03:22 +01:00
parent 99c56f041b
commit d98a57aa24

View File

@ -72,14 +72,16 @@
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 { try {
let html_txt = ''; let html_txt = '';
if (tohtml[i].getAttribute('desctype') == 'text/plain') { if (tohtml[i].getAttribute('desctype') == 'text/plain') {
html_txt = '<div class="feedEntryContent" style="white-space: pre-wrap;" >' + tohtml[i].innerHTML + '</div>'; html_txt = '<div class="feedEntryContent" style="white-space: pre-wrap;" >' + tohtml[i].innerHTML + '</div>';
} }
else if (tohtml[i].getAttribute('desctype') == 'xhtml') {
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerHTML + '</div>';
}
else { else {
html_txt = '<div class="feedEntryContent">' + tohtml[i].innerText + '</div>'; html_txt = '<div class="feedEntryContent">' + tohtml[i].innerText + '</div>';
} }
@ -95,15 +97,12 @@
console.error(e); console.error(e);
console.log(tohtml[i].innerHTML); 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');
} }
}); });
} }