From d105ea622d8d59f0871413bbea0ee1b48e962a47 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Mon, 7 Nov 2016 01:20:45 +0800 Subject: [PATCH] Disable the new rendering strategy This has proven to be problematic because we lost many JavaScript hooks. Will need to think how we can test this more rigorously. Fix #693 for now. --- MacDown/Code/Document/MPDocument.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MacDown/Code/Document/MPDocument.m b/MacDown/Code/Document/MPDocument.m index 40a24792..6e9d5238 100644 --- a/MacDown/Code/Document/MPDocument.m +++ b/MacDown/Code/Document/MPDocument.m @@ -952,6 +952,15 @@ - (void)renderer:(MPRenderer *)renderer didProduceHTMLOutput:(NSString *)html self.manualRender = self.preferences.markdownManualRender; +#if 0 + // Unfortunately this DOM-replacing causes a lot of problems... + // 1. MathJax needs to be triggered. + // 2. Prism rendering is lost. + // 3. Potentially more. + // Essentially all JavaScript needs to be run again after we replace + // the DOM. I have no idea how many more problems there are, so we'll have + // to back off from the path for now... :( + // If we're working on the same document, try not to reload. if (self.isPreviewReady && [self.currentBaseUrl isEqualTo:baseUrl]) { @@ -979,9 +988,11 @@ - (void)renderer:(MPRenderer *)renderer didProduceHTMLOutput:(NSString *)html // Replace everything in the old tag. DOMElement *htmlNode = (DOMElement *)[htmlNodes item:0]; htmlNode.innerHTML = html; + return; } } +#endif // Reload the page if there's not valid tree to work with. [self.preview.mainFrame loadHTMLString:html baseURL:baseUrl];