Repository navigation
feat(reader): render Markdown in a WebView with the desktop app's renderer - #62
Merged
Merged
Conversation
The viewer's rendered path was Markwon building spans; it is now the document renderer shared with the desktop app, running in a WebView. `ReaderContent` gains `Markdown(source)` in place of `Html`. The renderer is JavaScript inside the page, so Kotlin never holds rendered markup and could only produce it by growing a second Markdown implementation -- what crosses the bridge is source, and the page renders it. Source code reaches the same variant by being fenced into a code block, which is what gives it real highlight.js grammars: the Prism approximations that stood in for rust, ruby and toml are gone, and the standalone Prism renderer with them. That fencing belongs in the renderer rather than here, and says so. The document is decoded once. The host could read it itself, but the viewer already had, so a text-carrying `showDocument` sits beside the path-based one. Editor previews keep Markwon through a temporary `loadEditorPreview`, since that pane is still a TextView. Chrome inset crosses into the page as document padding rather than being applied to the WebView from outside: the chrome collapses on scroll, and an outer inset leaves a dead band behind when it goes. Search and the table of contents index text this side holds, so both are hidden while a document is drawn by the renderer. Raw mode keeps them. Rebuilding them in the page is planned. Reader preferences map across, with two gaps recorded rather than papered over: the renderer has no sepia or amoled palette, and the bundled fonts live in resources the WebView cannot load.
…ot start A WebView too old to run the shared renderer showed a blank page: no error, no timeout, nothing to act on. Confirmed on an API 24 emulator, whose WebView is Chromium 52 -- below the engine our own modules need, since they use optional chaining throughout. The reader now falls back to the document source with a warning naming the WebView version. Raw mode already exists and needs no WebView, which is why it is the fallback rather than a second native renderer kept alive for the purpose; keeping one would mean Markwon could never be deleted. Detection is behavioural rather than a version comparison. The page reports ready only once its whole module graph has resolved and executed, so the absence of that covers every cause at once -- an engine too old for the syntax, an asset that failed to load, a policy that refused a module -- and does not go stale when the renderer adopts newer syntax. It will: the floor moved to optional chaining without anyone noticing. The version is read only to make the message specific, never to decide anything. The mode chip said "Rendered mode" while showing source, which is the same untruth the format-name chip already guards against, and the raw/rendered toggle offered a switch between two identical views. The three decisions behind all of this move out of the composable into pure functions, because their deciding input is unreachable without an old WebView: left inline they would be verified once and then rot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reader now renders Markdown in a WebView, using the same renderer as MarkReader Desktop, in place of Markwon. Its built files are vendored into
app/src/main/assets/renderer/.SourceCodeRendereris gone.ReaderRendererSettings. Two gaps remain: there is no sepia or amoled theme, and the bundled fonts don't reach the page yet.ViewerChoicesas pure functions with tests.Not yet: search and the outline are hidden while the renderer draws the page, and raw mode keeps both. The editor preview still uses Markwon.
Closes #17, closes #29, closes #30