<!-- version: 0.0.3 --> Incremental Markdown Preview is a user script that modifies the Stack Exchange live Markdown preview pane to minimize the number of HTML elements that need to be replace every time the preview is updated. For posts that use a lot of heavyweight features like MathJax, this should provide a significant performance improvement and minimize any flickering of the preview pane. It can also prevent some forms of interactive post content (such as embedded YouTube videos, when used together with [SOUP] on a site that has them enabled) from resetting whenever a different part of the post is edited. Other than that, Incremental Markdown Preview should have no visible effects. It just makes editing work better and faster. This user script is currently in **beta testing** phase: I've used it myself for several months on Chrome and Firefox with no issues, but it still needs more extensive testing on different browsers and on different Stack Exchange sites with different custom features (like MathJax, syntax highlight, Stack Snippets, etc.). I would also like to learn of any incompatibilities with other popular user scripts. After a reasonable period of testing, I'm planning to incorporate Incremental Markdown Preview into my [Stack Overflow Unofficial Patch (SOUP)][SOUP] user script / extension, and also to submit an equivalent patch directly to [Pagedown](https://github.com/StackExchange/pagedown). Installing ---------- To install Incremental Markdown Preview, you will first need to install a user script manager such as [Tampermonkey][TM], [Violentmonkey][VM] or [Greasemonkey][GM]. Once you have a user script manager installed in your browser, clicking the ["download / install"][DL] button below should bring up a dialog asking you if you want to install Incremental Markdown Preview for Stack Exchange. Answer "yes". > ### [<kbd>Download / Install Incremental Markdown Preview</kbd>][DL] > <sup>[View source][source]</sup> Incremental Markdown Preview is hosted as a [Gist](https://gist.github.com/) on [GitHub](https://github.com/). Note that there is [a known bug with Greasemonkey 4 on Firefox](https://github.com/greasemonkey/greasemonkey/issues/2631) that may prevent installation of user scripts from GitHub. Until this bug is fixed, the simplest work-around is to use some other user script manager instead. Feedback -------- As noted above, Incremental Markdown Preview is currently in beta testing phase. If you experience any problems with it, please let me know about them e.g. by posting a comment or an answer below. Reports of successful and problem-free use are also appreciated, especially on browsers which Incremental Markdown Preview has not previously been tested on. When reporting an issue, please include the following information (or as much of it as is applicable): * The browser, OS and user script manager you're using. * The version of Incremental Markdown Preview you have installed. * Any other potentially relevant user scripts or browser extensions that you're using (including any Stack Exchange / Stack Overflow specific scripts, as well as any ad blockers, security extensions and extensions that modify page styling or content). * The Stack Exchange site and page where you experience the issue. Of course, you should also clearly describe the issue itself (i.e. what happened, what was supposed to happen). It's also helpful if you can give an exlicit list of steps to reproduce the issue or, if you cannot reliably reproduce it, a detailed description of what you were doing when it happened. If there are any errors or warnings logged into [your browser's JS console](https://webmasters.stackexchange.com/questions/8525/how-do-i-open-the-javascript-console-in-different-browsers), those would also be helpful. Note that Incremental Markdown Preview currently logs a bunch of diagnostics messages to the console. Those diagnostics messages look something like this: > *incremental markdown preview updated #wmd-preview: skipped 32, inserted 0, deleted 0, replaced 1 and recursed into 1 nodes.* These log messages are useful for analyzing the performance of Incremental Markdown Preview, but are generally not needed when diagnosing errors. On most browsers, there is an option to hide such informational messages in the console. Compatibility ------------- Incremental Markdown Preview is intended to be compatible with all modern browsers that support a Greasemonkey / Tampermonkey style user script manager. It requires no external scripts or resources and does not use the `GM_*` API. In practice, Incremental Markdown Preview has currently been tested on Google Chrome with Tampermonkey and on Mozilla Firefox with Violentmonkey. Incremental Markdown Preview should be compatible with [SOUP], including its [embedded YouTube video preview](https://meta.stackexchange.com/q/299082) implementation. In fact, that feature was the original motivation for implementing Incremental Markdown Preview. Incremental Markdown Preview is also meant to be compatible with all Stack Exchange syntax and editing extensions, including MathJax, code syntax highlight and Stack Snippets. Note that, with Incremental Markdown Preview enabled, changes to "non-local" configuration options like `\newcommand` in MathJax or `<!-- language-all: ... -->` in syntax highlight may not immediately propagate to all affected parts of the post being edited. Normally, editing the affected parts of the post directly should be enough to trigger an update. While reports of any other such delayed propagation issues are welcome, they're more or less unavoidable without adding special-case handling to force a full preview pane refresh when such non-local changes are made, which I'm not planning to add in this version of Incremental Markdown Preview. Stack Snippets have their own HTML caching mechanism that effectively bypasses Incremental Markdown Preview. While this should not cause any actual problems, it does mean that Incremental Markdown Preview provides no real rendering speedup for Stack Snippets, and that all snippets are still reset to their default state whenever the preview pane is updated. Copyright and License --------------------- Incremental Markdown Preview is written by Ilmari Karonen and distributed under the [ISC license](https://opensource.org/licenses/ISC), a permissive BSD-style open source license. [DL]: https://gist.github.com/vyznev/ddb647af6a90964e42d26ba5e0db1815/raw/incremental-markdown-preview.user.js "Install Incremental Markdown Preview for Stack Exchange from GitHub" [source]: https://gist.github.com/vyznev/ddb647af6a90964e42d26ba5e0db1815 "Incremental Markdown Preview for Stack Exchange source code on GitHub" [GM]: https://addons.mozilla.org/firefox/addon/greasemonkey/ "Mozilla add-ons: Greasemonkey" [TM]: https://tampermonkey.net/ "Tampermonkey" [VM]: https://violentmonkey.github.io/about/ "Violentmonkey" [SOUP]: https://stackapps.com/questions/4486/the-stack-overflow-unofficial-patch-soup "The Stack Overflow Unofficial Patch (SOUP)"