Wrap tables in an overflow-x: auto; div

This commit is contained in:
Nate Weaver 2019-12-28 00:05:16 -06:00
parent 8a85b18d09
commit cbbb46a776
2 changed files with 20 additions and 0 deletions

View File

@ -21,6 +21,19 @@ function convertImgSrc() {
}); });
} }
// Wrap tables in an overflow-x: auto; div
function wrapTables() {
var tables = document.querySelectorAll("div.articleBody")[0].getElementsByTagName("table");
for (table of tables) {
var wrapper = document.createElement("div");
wrapper.className = "nnw-overflow";
var tableCopy = table.cloneNode(true);
wrapper.appendChild(tableCopy);
table.parentNode.replaceChild(wrapper, table);
}
}
function reloadArticleImage() { function reloadArticleImage() {
var image = document.getElementById("nnwImageIcon"); var image = document.getElementById("nnwImageIcon");
image.src = "nnwImageIcon://"; image.src = "nnwImageIcon://";
@ -39,6 +52,7 @@ function render(data, scrollY) {
wrapFrames() wrapFrames()
stripStyles() stripStyles()
convertImgSrc() convertImgSrc()
wrapTables()
postRenderProcessing() postRenderProcessing()
} }

View File

@ -131,6 +131,12 @@ pre {
word-break: normal; word-break: normal;
-webkit-hyphens: none; -webkit-hyphens: none;
} }
.nnw-overflow {
overflow-x: auto;
}
td > pre {
overflow-x: hidden;
}
code, pre { code, pre {
font-family: "SF Mono", Menlo, "Courier New", Courier, monospace; font-family: "SF Mono", Menlo, "Courier New", Courier, monospace;
font-size: 14px; font-size: 14px;