Add reader view and document text zoom - #26
Conversation
Greptile SummaryOmawrite adds a selectable rich-text reader view, independent document zoom, and stateful fenced-code presentation.
Confidence Score: 4/5The fence recognizer should be aligned with the reader’s Markdown dialect before merging so valid documents cannot receive inconsistent code styling and caret behavior. The new editor state machine blindly toggles on lines matching an approximate three-backtick regex, causing valid GitHub-flavored fence forms and delimiter-length cases to be interpreted differently between editing and reader views. Files Needing Attention: src/markdownhighlighter.cpp, src/Main.qml, tests/tst_omawrite.cpp
|
| Filename | Overview |
|---|---|
| src/Main.qml | Adds reader mode, document zoom, independent scroll state, rich-text selection, and mode-aware focus and keyboard behavior. |
| src/backend.cpp | Adds Markdown-to-HTML rendering, theme-aware reader formatting, remote-image removal, and fenced-block caret integration. |
| src/backend.h | Exposes the new Markdown rendering method through the QML-facing backend API. |
| src/markdownhighlighter.cpp | Adds theme-derived code backgrounds and stateful fenced-code highlighting, but its fence recognizer diverges from the reader dialect. |
| src/markdownhighlighter.h | Adds shared code-color calculation and persistent fenced-block states. |
| tests/tst_omawrite.cpp | Expands coverage for reader rendering, sanitization, copy behavior, zoom, navigation, spacing, and basic backtick fences, but omits alternate and mismatched fence forms. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Source[Markdown editor] -->|text changes| Backend[Backend renderMarkdown]
Backend -->|sanitized themed HTML| Reader[Reader TextEdit]
Source --> Highlighter[MarkdownHighlighter]
Highlighter -->|block state and formats| Source
Toggle[Reader/Edit toggle] --> Source
Toggle --> Reader
Zoom[Document zoom] --> Source
Zoom --> Backend
Zoom --> Reader
Reviews (1): Last reviewed commit: "Add reader view and document text zoom" | Re-trigger Greptile
| bool MarkdownHighlighter::isFence(const QString &text) { | ||
| static const QRegularExpression fenceRe(QStringLiteral("^\\s*```")); | ||
| return fenceRe.match(text).hasMatch(); |
There was a problem hiding this comment.
Fence state misclassifies Markdown
When a document uses a valid tilde fence, a longer backtick fence containing a shorter backtick run, or an indented code line beginning with three backticks, isFence() disagrees with the GitHub Markdown dialect used by reader view and blindly toggles block state. This styles valid code as prose or surrounding prose as code, and makes editor caret behavior disagree with the rendered document.
Knowledge Base Used:
Summary
Omawrite can now switch between Markdown editing and a formatted, selectable reader view without leaving the document. Document text can be resized independently from desktop scaling, and fenced code is easier to distinguish in both views.
Reader mode keeps separate scroll positions for reading and editing. It renders with the active Omarchy theme, copies selected content as HTML and plain text, and blocks raw Markdown HTML and remote images.
Fenced code remains literal in the editor, so Markdown markers inside code are not hidden or styled as prose. Reader typography uses explicit line height and block spacing so headings, paragraphs, and lists remain readable.
Validation
./bin/test— 17 tests passed./bin/buildbd-hiring-plan.mdin both views