 	func articleExtractionDidFail(with: Error) {
 		stopArticleExtractor()
 		articleExtractorButtonState = .error
-		reloadHTML()
+		renderPage()
 	}
 
 	func articleExtractionDidComplete(extractedArticle: ExtractedArticle) {

				startArticleExtractor()
			}
			if article != oldValue {
				reloadHTML()
			}
		}
	}


private extension WebViewController {

	func reloadHTML() {
		let url = Bundle.main.url(forResource: "page", withExtension: "html")!
		webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
		renderingTracker = 0
	}

	func renderPage() {
		guard let webView = webView else { return }
		 
		// It looks like we need to clean up the webview every once in a while by reloading it from scratch
		// Otherwise it will stop responding or cause rendering artifacts.  This typically only comes into
		// play on the iPad where we aren't constantly pushing and popping this controller.
		if (renderingTracker > 10) {
			reloadHTML()
		}
		renderingTracker += 1
		
		let style = ArticleStylesManager.shared.currentStyle
		let rendering: ArticleRenderer.Rendering

		if let articleExtractor = articleExtractor, articleExtractor.state == .processing {
			rendering = ArticleRenderer.loadingHTML(style: style)
		} else if let articleExtractor = articleExtractor, articleExtractor.state == .failedToParse, let article = article {
			rendering = ArticleRenderer.articleHTML(article: article, style: style, useImageIcon: true)
		} else if let article = article, let extractedArticle = extractedArticle {
			if isShowingExtractedArticle {
				rendering = ArticleRenderer.articleHTML(article: article, extractedArticle: extractedArticle, style: style, useImageIcon: true)
			} else {
				rendering = ArticleRenderer.articleHTML(article: article, style: style, useImageIcon: true)
			}
		} else if let article = article {
			rendering = ArticleRenderer.articleHTML(article: article, style: style, useImageIcon: true)
		} else {
			rendering = ArticleRenderer.noSelectionHTML(style: style)
		}
		
		let templateData = TemplateData(style: rendering.style, body: rendering.html)
		
		let encoder = JSONEncoder()
		var render = "error();"
		if let data = try? encoder.encode(templateData) {
			let json = String(data: data, encoding: .utf8)!
			render = "render(\(json), \(restoreOffset));"
		}

		restoreOffset = 0
		
		WebViewProvider.shared.articleIconSchemeHandler.currentArticle = article
		webView.scrollView.setZoomScale(1.0, animated: false)
		webView.evaluateJavaScript(render)
		
	}
	
	func finalScrollPosition() -> CGFloat {
		return webView.scrollView.contentSize.height - webView.scrollView.bounds.height + webView.scrollView.safeAreaInsets.bottom
	}
