Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KBViewer

KBViewer

A ~150 KB native Markdown viewer built for fast reading and auditing.

Native C++ / Win32 / GDI · No Electron · No WebView · No browser runtime


KBViewer is an ultra-lightweight native viewer designed specifically for reading and auditing Markdown. It starts almost instantly, uses very little memory, and is completely decoupled from your editor. Opening a file means exactly that: opening it for inspection, without launching an IDE, editor, browser engine, or heavyweight application framework. Click here to give it a try.


Markdown Is Extremely AI-Friendly, but Most Tools Are Heavy and Editor-Coupled

In the AI era, Markdown is evolving from "the format developers use for README files" into one of the primary interchange formats for chat, agents, code generation, knowledge distribution, and human-machine collaboration. Compared with DOCX and Word documents, Markdown is transparent, diff-friendly, and naturally suited to version control. Compared with LaTeX, it is lighter, faster to generate, and easier to consume with ordinary text tooling. Compared with rich-text formats, it is exceptionally well suited to both LLM input and output.

The problem is that many Markdown viewers available today are not really viewers. They often couple viewing and editing in a single application. To inspect a .md file that already exists in a project, you have to launch a complete editor. Other applications rely on heavyweight technology stacks such as Electron, browser engines, WebView, or WebView-based architectures such as Rust + Tauri.

The result is disproportionate: opening a 1 KB Markdown file may involve starting tens or hundreds of megabytes of browser runtime, JavaScript infrastructure, UI framework code, and layout machinery.

For one-off reading, inspection, and auditing, that cost is unnecessary.

Viewing is not editing, and auditing should not require launching a complete editing environment.

So why don't we have a lightning-fast, low-memory Markdown auditing tool?


KBViewer's ~150 KB Design

KBViewer is a native Markdown viewer with a binary size of roughly 150 KB.

That size is not achieved by hiding web technology somewhere else. It comes from deliberately avoiding browser runtimes, general-purpose UI frameworks, and redundant in-memory representations of the document.

The design principle is simple:

Pay only for what is actually required to view Markdown.

Three architectural decisions matter most.

1. Native Win32 + GDI: No Browser, No WebView

KBViewer is built directly on:

C++17
Win32
GDI

It creates its own windows, measures text, and draws Markdown directly.

There is no:

Electron
Chromium
WebView2
Tauri WebView
Qt
WPF
WinUI
full-document RichEdit control

Markdown is not converted to HTML and handed to a browser for layout.

Instead, parsed Markdown flows directly into the native GDI rendering path. Startup does not require initializing a browser process, JavaScript VM, DOM, CSS layout engine, or web runtime.

That is the foundation of KBViewer's small size, low overhead, and fast startup.

2. Memory-Mapped UTF-8 + Compact Indexes: No Full-Document Copy

KBViewer maps Markdown source files directly using:

CreateFileMappingW
MapViewOfFile

It does not permanently construct a second full UTF-16 document, an HTML DOM, a RichEdit text buffer, or a per-character layout database.

Its central indexes remain deliberately compact:

Block     = 16 bytes
TableMeta = 16 bytes

Line-number tracking also avoids storing an offset for every source line. KBViewer keeps only the total physical line count plus a small sequential lookup cache.

As documents become larger, the primary cost therefore remains:

mapped source file
+
compact block index

rather than several simultaneous copies of the same document.

3. Incremental UI: Update Only What Actually Changed

Scrolling uses:

ScrollWindowEx
+
dirty-strip repaint
+
Block Y binary search

Pixels that are already visible are moved directly. KBViewer redraws only the newly exposed portion of the document rather than repainting the entire window on every scroll event.

External file monitoring follows the same principle:

only the currently visible tab is watched

Inactive tabs are not continuously polled. When you switch to a tab, KBViewer checks that file at that moment and reloads it if it changed while inactive.

When the active file is modified by an external editor or AI tool, KBViewer compares the old and new versions and attempts to map the current reading position into the updated document.

This allows KBViewer to act as an independent live review window without being tied to any particular editor.

Likewise, Ctrl+Shift+F formatting uses streaming output instead of creating a second complete formatted document in memory.


Interface & Features

KBViewer intentionally keeps its interface simple:

┌──────────────────────────────────────────────────────┐
│ Tab 1        Tab 2        Tab 3                 +    │
├──────────────────────────────────────────────────────┤
│                                                      │
│  # Markdown                                          │
│                                                      │
│  Rendered document                                   │
│                                                      │
│  - lists                                             │
│  - [x] tasks                                         │
│  - tables                                            │
│  - links                                             │
│                                                      │
├──────────────────────────────────────────────────────┤
│ Find: query                                       ×  │  ← shown with Ctrl+F
├──────────────────────────────────────────────────────┤
│ status / file path          Line 42 / 318      27%   │
└──────────────────────────────────────────────────────┘

The status bar is always anchored to the bottom of the window and shows:

source line of the first visible block
total physical source lines
current scroll percentage

It is also used for:

full current file path
formatting results
external file update notifications
error messages

Markdown Rendering

KBViewer currently supports a bounded, audit-oriented CommonMark/GFM subset, including:

  • Paragraphs
  • ATX headings: # through ######
  • Strong
  • Emphasis
  • Inline code
  • Links and autolinks
  • .md document links
  • Unordered lists
  • Ordered lists
  • Task lists
  • Nested lists
  • Blockquotes
  • Fenced code blocks
  • Indented code blocks
  • Thematic rules
  • GFM-style pipe tables

KBViewer does not render HTML. Raw HTML is displayed as ordinary text.

It currently does not include:

  • Math
  • Mermaid
  • Markdown image rendering
  • Syntax highlighting
  • Full CommonMark/GFM conformance
  • A general-purpose Markdown editor

KBViewer remains viewer/auditor first.

File & Document

Action Shortcut
Open Markdown file Ctrl + O
Reload current file F5
Show full file path in the status bar Ctrl + L
Format supported Markdown structures and write back Ctrl + Shift + F

Ctrl + Shift + F is an explicit write operation.

KBViewer normalizes Markdown structures that it understands and can safely rewrite, including headings, lists, tasks, blockquotes, thematic rules, and pipe tables. Ordinary paragraph and inline content, as well as code blocks, are preserved as conservatively as possible.

Find & Text Selection

Action Shortcut
Find Ctrl + F
Find next Enter / F3
Find previous Shift + Enter / Shift + F3
Close Find Esc / click ×
Select all rendered text Ctrl + A
Copy rendered text Ctrl + C

Text selection operates directly on the rendered GDI text.

Copying returns what you see, rather than the original Markdown syntax.

For example:

**bold** and [Example](https://example.com)

copies as:

bold and Example

rather than including the ** markers or the hidden URL target.

Tabs & Navigation

Action Shortcut
New tab Ctrl + T
Close tab Ctrl + W / Ctrl + F4
Reopen closed tab Ctrl + Shift + T
Next tab Ctrl + Tab / Ctrl + PageDown
Previous tab Ctrl + Shift + Tab / Ctrl + PageUp
Select tab 1–8 Ctrl + 1Ctrl + 8
Select last tab Ctrl + 9
Close window Ctrl + Shift + W

KBViewer supports up to 16 tabs, including:

  • Middle-click to close a tab
  • Multi-file drag and drop
  • Independent document state, scroll position, and file state for each tab

Reading & Links

Action Shortcut / Gesture
Scroll Mouse wheel / scrollbar / arrow keys
Page up / down PageUp / PageDown
Jump to top / bottom Home / End
Open rendered link Ctrl + Click

Automatic File Updates

KBViewer is decoupled from your editor, but it can continuously reflect the editor's latest saved result.

For the currently visible tab:

external editor / AI agent saves Markdown
                    ↓
             KBViewer detects it
                    ↓
              document reloads
                    ↓
        reading position is preserved

Inactive tabs are not continuously scanned in the background. When you switch to another tab, KBViewer immediately checks whether its file changed while it was inactive.

This makes KBViewer useful as:

  • An independent review window for AI/agent output
  • A read-only Markdown companion next to an editor
  • A fast project-document viewer
  • The reading side of a Markdown diff/audit workflow
  • A lightweight browser for knowledge bases and generated documentation

Opening Markdown should feel like opening a text file, not like launching a browser.

About

A KB-level Markdown viewer

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages