From 4b0bda88b82da78c8c6b4558a1c99b1b4b5e8592 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 14 Jan 2022 16:26:28 -0500 Subject: [PATCH] Prevent tables from overflowing --- Reader.xcodeproj/project.pbxproj | 4 ++++ Reader/Screens/Read/ReadViewController.swift | 2 ++ Reader/read.css | 4 ++++ Reader/read.js | 6 ++++++ 4 files changed, 16 insertions(+) create mode 100644 Reader/read.js diff --git a/Reader.xcodeproj/project.pbxproj b/Reader.xcodeproj/project.pbxproj index fa2c8d9..5e5f16d 100644 --- a/Reader.xcodeproj/project.pbxproj +++ b/Reader.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ D65B18BE275051A1004A9448 /* LocalData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65B18BD275051A1004A9448 /* LocalData.swift */; }; D65B18C127505348004A9448 /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D65B18C027505348004A9448 /* HomeViewController.swift */; }; D68B303627907D9200E8B3FA /* ExcerptGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D68B303527907D9200E8B3FA /* ExcerptGenerator.swift */; }; + D68B303D2792204B00E8B3FA /* read.js in Resources */ = {isa = PBXBuildFile; fileRef = D68B303C2792204B00E8B3FA /* read.js */; }; D6A8A33427766C2800CCEC72 /* PersistentContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6A8A33327766C2800CCEC72 /* PersistentContainer.swift */; }; D6C687EC272CD27600874C10 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C687EB272CD27600874C10 /* AppDelegate.swift */; }; D6C687EE272CD27600874C10 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C687ED272CD27600874C10 /* SceneDelegate.swift */; }; @@ -101,6 +102,7 @@ D68B3032278FDD1A00E8B3FA /* Reader-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Reader-Bridging-Header.h"; sourceTree = ""; }; D68B303527907D9200E8B3FA /* ExcerptGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExcerptGenerator.swift; sourceTree = ""; }; D68B3037279099FD00E8B3FA /* liblolhtml.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = liblolhtml.a; path = "lol-html/c-api/target/aarch64-apple-ios-sim/release/liblolhtml.a"; sourceTree = ""; }; + D68B303C2792204B00E8B3FA /* read.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = read.js; sourceTree = ""; }; D6A8A33327766C2800CCEC72 /* PersistentContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentContainer.swift; sourceTree = ""; }; D6C687E8272CD27600874C10 /* Reader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Reader.app; sourceTree = BUILT_PRODUCTS_DIR; }; D6C687EB272CD27600874C10 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -264,6 +266,7 @@ D6C687F9272CD27700874C10 /* LaunchScreen.storyboard */, D6C687FC272CD27700874C10 /* Info.plist */, D6E24372278BE2B80005E546 /* read.css */, + D68B303C2792204B00E8B3FA /* read.js */, ); path = Reader; sourceTree = ""; @@ -469,6 +472,7 @@ files = ( D6C687FB272CD27700874C10 /* LaunchScreen.storyboard in Resources */, D6C687F8272CD27700874C10 /* Assets.xcassets in Resources */, + D68B303D2792204B00E8B3FA /* read.js in Resources */, D6E24373278BE2B80005E546 /* read.css in Resources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Reader/Screens/Read/ReadViewController.swift b/Reader/Screens/Read/ReadViewController.swift index 8dd546f..f1da8f1 100644 --- a/Reader/Screens/Read/ReadViewController.swift +++ b/Reader/Screens/Read/ReadViewController.swift @@ -71,6 +71,7 @@ class ReadViewController: UIViewController { } private static let css = try! String(contentsOf: Bundle.main.url(forResource: "read", withExtension: "css")!) + private static let js = try! String(contentsOf: Bundle.main.url(forResource: "read", withExtension: "js")!) private func itemContentHTML() -> String? { guard let content = item.content else { @@ -105,6 +106,7 @@ class ReadViewController: UIViewController { +
diff --git a/Reader/read.css b/Reader/read.css index aa1f06a..c5ba103 100644 --- a/Reader/read.css +++ b/Reader/read.css @@ -55,6 +55,10 @@ blockquote { font-style: italic; } +.item-content-table { + overflow-x: scroll; +} + #item-info { margin-bottom: 1em; } diff --git a/Reader/read.js b/Reader/read.js new file mode 100644 index 0000000..d7e8c6a --- /dev/null +++ b/Reader/read.js @@ -0,0 +1,6 @@ +document.addEventListener("DOMContentLoaded", () => { + for (const table of document.querySelectorAll("table")) { + // wrap tables in divs to which we can apply overflow-x: scroll; + table.outerHTML = `
${table.outerHTML}
`; + } +});