MacDownApp / MacDownApp/macdown
Support incremental rendering
- Dominant language
- Rich Text Format
- Stars
- 9.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
By using incremental rendering (HTML diff & patch), image cache is not required any more because those image tags are not destroyed and created again.
You can use the following js library to do incremental rendering: https://github.com/fiduswriter/diffDOM
Because syntax highlighting modifies HTML, a simple approach of diff may be: diff "previous HTML after highlighting" and "current HTML after highlighting". Notice that this method only prevent page reloading and it still calls highlighting procedure every time user modifies the content even when code blocks are not changed.
A more complex approach may be:
1. diff "HTML from markdown renderer" and "HTML after highlighting" to get those changed nodes (denote as node_HIGHLIGHT) during highlighting (and other kinds of post-rendering).
2. when user changes contents, diff "previous HTML from markdown renderer" and "current HTML from markdown renderer" to get those changed nodes from user modification (denote as node_USER)
3. apply patch from node_HIGHLIGHT to "current HTML from markdown renderer" if such node is not in node_USER: if user didn't changed those content, just copy post-render results from previous rendering
4. apply highlighting (and other kinds of post-rendering)
In this way, syntax highlighting or other post-rendering will not be called if user did not change relevant contents so that its performance is acceptable even if post-rendering is complex and cost notable time.
Contributor guide
Research direction
No files, tests, or rendering entry points are identified in the issue. Start by locating MacDown’s markdown rendering, syntax-highlighting, and image-cache paths, then evaluate diffDOM for incremental updates; done means rendering changes without recreating unchanged image tags and avoids unnecessary post-rendering where content is unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- desktop, frontend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100