mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-11 09:14:06 +01:00
Strip spans from pre elements inside table cells
Works around a clipping issue.
This commit is contained in:
parent
bb0fffcec2
commit
c2d3e9213d
@ -34,6 +34,40 @@ function wrapTables() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove some children (currently just spans) from pre elements to work around a strange clipping issue
|
||||||
|
var ElementUnwrapper = {
|
||||||
|
unwrapSelector: "span",
|
||||||
|
unwrapElement: function (element) {
|
||||||
|
var parent = element.parentNode;
|
||||||
|
var children = Array.from(element.childNodes);
|
||||||
|
|
||||||
|
for (child of children) {
|
||||||
|
parent.insertBefore(child, element);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent.removeChild(element);
|
||||||
|
},
|
||||||
|
// `elements` can be a selector string, a node, or a list of nodes
|
||||||
|
unwrapAppropriateChildren: function (elements) {
|
||||||
|
if (typeof elements[Symbol.iterator] !== 'function')
|
||||||
|
elements = [elements];
|
||||||
|
else if (typeof elements === "string")
|
||||||
|
elements = document.querySelectorAll(elements);
|
||||||
|
|
||||||
|
for (element of elements) {
|
||||||
|
for (unwrap of element.querySelectorAll(this.unwrapSelector)) {
|
||||||
|
this.unwrapElement(unwrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
element.normalize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function flattenPreElements() {
|
||||||
|
ElementUnwrapper.unwrapAppropriateChildren(".articleBody td > pre");
|
||||||
|
}
|
||||||
|
|
||||||
function reloadArticleImage() {
|
function reloadArticleImage() {
|
||||||
var image = document.getElementById("nnwImageIcon");
|
var image = document.getElementById("nnwImageIcon");
|
||||||
image.src = "nnwImageIcon://";
|
image.src = "nnwImageIcon://";
|
||||||
@ -53,5 +87,7 @@ function render(data, scrollY) {
|
|||||||
wrapTables()
|
wrapTables()
|
||||||
stripStyles()
|
stripStyles()
|
||||||
convertImgSrc()
|
convertImgSrc()
|
||||||
|
flattenPreElements()
|
||||||
|
|
||||||
postRenderProcessing()
|
postRenderProcessing()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user