From cbbb46a77664d9b591132595740015890eafc2a4 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Sat, 28 Dec 2019 00:05:16 -0600 Subject: [PATCH] Wrap tables in an overflow-x: auto; div --- Shared/Article Rendering/main.js | 14 ++++++++++++++ iOS/Resources/styleSheet.css | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index 4ecf8eb5f..187043d2f 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -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() { var image = document.getElementById("nnwImageIcon"); image.src = "nnwImageIcon://"; @@ -39,6 +52,7 @@ function render(data, scrollY) { wrapFrames() stripStyles() convertImgSrc() + wrapTables() postRenderProcessing() } diff --git a/iOS/Resources/styleSheet.css b/iOS/Resources/styleSheet.css index b90edd69e..157fcfea5 100644 --- a/iOS/Resources/styleSheet.css +++ b/iOS/Resources/styleSheet.css @@ -131,6 +131,12 @@ pre { word-break: normal; -webkit-hyphens: none; } +.nnw-overflow { + overflow-x: auto; +} +td > pre { + overflow-x: hidden; +} code, pre { font-family: "SF Mono", Menlo, "Courier New", Courier, monospace; font-size: 14px;