Built from two packages, Polhem.Markdown and Polhem.Chat. Free and open source
This post is based on version 0.1.1. The changes in each release are in the CHANGELOG.
Polhem MD is a Markdown reader and editor for macOS, Windows and Linux. Open a .md file and you can read it with a table of contents, or edit it with a live preview beside it, and ask AI to help revise it. You connect the model yourself: enter your own API key, or point it at a local model running on your computer.
It is put together from the two packages covered in my previous posts, Polhem.Markdown and Polhem.Chat. It is MIT licensed and free, and builds for all three platforms can be downloaded from the product site:
- Product site: https://polhem-dev.github.io/polhem-md/
- Source code: https://github.com/polhem-dev/polhem-md
1️⃣ Packages first, then the app
The Polhem framework I work on has two kinds of front ends, Avalonia (desktop and mobile) and Blazor (web). Several places need to show Markdown replies from AI, and they also need an AI chat view. If each place wrote its own, every copy would end up a little different, and a fix would have to be made in each of them. So I wrote them as two packages:
- Polhem.Markdown: a Markdown viewer and editor
- Polhem.Chat: an AI chat view that works with any model and shows replies with Polhem.Markdown
Once the two packages were done, editing, preview and AI chat were all there, and putting them together made a Markdown editor. That is how Polhem MD came about. The editor, the preview and the chat panel on screen all come from the packages; the app itself mainly handles opening and saving files, the settings, and putting those three pieces together. So it is both a tool you can use as is and a working example of the two packages.
Polhem MD is an editor that works on files: it edits the .md files on your disk, organized in folders. It is not a notes app, so there are no backlinks, no tags and no database of its own; for syncing, use a synced folder such as iCloud Drive, OneDrive or Dropbox. Editing is source plus preview, not WYSIWYG.
2️⃣ Reading
When you only want to read, switch to Preview Only, and the text stays at a comfortable reading width.
- A table of contents rail runs along the edge of the window, with a short line for each heading and the section you are reading marked. Point at it and it opens into the table of contents, which you can also pin beside the text.
- Cmd+F (Ctrl+F on Windows and Linux) searches the preview, with match case, whole word and regular expressions.
- Syntax-highlighted code, tables, task lists, footnotes, math and Mermaid diagrams are rendered the way GitHub renders them, and links to other Markdown files open in the app.
- File > Open URL…, or dropping a URL on the window, opens a document from the web. Given a GitHub or GitLab file page or a gist, it opens the file itself. A web document is read only until you use Save As.
In a web document, images from the same site load right away, while images from other sites show only after you choose to load them. Once an image loads, the other site knows someone is reading the document, so they are not loaded by default.
3️⃣ Writing
With the editor and preview side by side, the preview follows your typing and scrolling. Cmd+1, Cmd+2 and Cmd+3 switch to Editor Only, Editor and Preview, and Preview Only.
- The editor highlights Markdown as you write and keeps the text in a centered column; when the body uses a proportional font, code still uses a monospaced one.
- Open the format bar from the View menu to add bold, headings, lists, links and tables with a click.
- The editor has find and replace.
- The folder sidebar lists the Markdown files in a folder, and you can create new files in it. Changes are saved automatically; if you turn that off, save with Cmd+S.
The interface comes in English, Traditional Chinese, Simplified Chinese and Japanese, and a switch takes effect right away. Themes are light, dark, or following the system.
4️⃣ Writing with AI
For AI editing I set only one rule: the model cannot change the document directly. Every edit is marked in the editor first, and you decide whether to take it.
The chat panel
The chat panel sits beside the document and opens and closes with Cmd+Shift+J. A question can carry the selected text, the whole document, or nothing, switched below the prompt box. Other files in the sidebar can be added with a right click and "Include in AI Chat", and they are sent to the model for reference too.
When you ask the model for changes, its edits are marked right in the editor: the original text is struck through with the new text below it, and you can accept or reject each one, or all of them at once. Until you decide, the document does not change at all, and autosave never writes an edit you have not accepted. After accepting, a single Undo takes it back, and Accept All also counts as one step.
Write a URL in your question and the model reads that page, and the chat shows which URL it read. It reads only the URLs you write, and does not follow links on the page to read other pages.
Edit with AI
Small changes do not need the chat. Select some text, press Cmd+J, and type an instruction or pick one of the built-in commands: Polish, Shorten, Expand, Translate, Fix Grammar and Make a Table. With nothing selected, it works on the paragraph at the cursor.
The result is again marked as an edit, and you choose to accept, retry or discard it.
Instructions you use often can be saved in the settings as your own commands, each with the model it should use. Saved commands come up with Cmd+J, or by typing / in the chat.
Marking AI-written text
Accepted AI text is marked in light violet, and a part goes back to the normal color once you edit it yourself. The marks are kept in the app's own folder, not written into the .md file, so the file is still clean Markdown wherever you open it.
5️⃣ Bring your own model
Polhem MD has no built-in model and no server of its own; requests go straight from your computer to the model you set up.
On the Models page of the settings, you can add any service with an OpenAI-compatible Chat Completions API, and there are templates for OpenAI, OpenRouter, Ollama and LM Studio. A local model running on your own computer needs no key. You can set up several models and switch between them at the bottom of the chat panel.
API keys are kept in the system's credential store, not in the settings file: the Keychain on macOS, Credential Manager on Windows, and Secret Service on Linux. On Linux without a keyring service, a key lasts only for the current session.
I chose to have users bring their own model because if the app hosted the model, the API costs would fall on the developer, and the usage could be neither estimated nor controlled. When users bring their own, they pay the model provider directly, the app itself has no AI costs, and that is what lets every feature be free.
Proposing edits relies on tool calling (the model asking the app, in its reply, to run a function). A model without tool calling can still chat, but it cannot propose edits or read web pages.
6️⃣ Filling the gaps in the packages
Before writing the app, I had Claude compare the app's needs with the two packages' current APIs item by item and list what was already supported and what was missing. The chat panel, streaming, stopping, the approval flow for tool calls, and saving and loading conversations were all there, so the app uses them as they are. For what was missing, I opened issues on the packages:
| What the app needed | What the packages added |
|---|---|
| Sending the selection to AI, and undoing an applied edit in one step | Reading and setting the editor's selection, and replacing one or more ranges as a single undo step |
| Marking AI edits and AI-written text in the editor | Range marks in the editor (background, underline, strikethrough), and where text is on the screen |
| Find and replace while editing | Find and replace in the editor |
| Attaching the selection or the whole document for the model without it showing in the question | Context that goes with a prompt, with the chat bubble showing only a label |
| Calling custom commands from the chat | A / command list in the prompt box |
The gaps were filled by one rule: add APIs that any application can use, and keep the AI logic in the app, out of the packages. For example, the editor only offers "mark this range"; whether the mark is an AI edit or a search result is up to the application using it.
Packages expose many properties, methods and events anyway, to meet the needs of different applications. What was added for Polhem MD can be used by other applications later.
7️⃣ Download
Download the file for your computer from the product site or the Releases page on GitHub. Each file is a single program with .NET included, so there is nothing else to install.
- macOS: unzip and move the app to Applications. It is signed and notarized by Apple, so it opens directly.
- Windows: unzip and run Polhem MD.exe.
- Linux: unzip and run
./polhem-md.
To build from source, install the .NET 10 SDK and run dotnet run --project src/PolhemMd.
✅ Wrapping up
If you often write technical docs, blog posts or READMEs, want AI to help revise them, and want to use your own API key or a local model without being tied to an AI subscription, give Polhem MD a try.
It is not the right fit for everyone, though. The known limitations right now:
- There is no built-in model; you need your own API key, or a local model running on your computer.
- Editing is source plus preview, which may feel awkward if you are used to WYSIWYG.
- It is not a notes app, so there are no backlinks, tags or full-text index.
- It is desktop only, with no mobile version.
The app is at version 0.1. Feel free to try it, and if you find a problem or have a suggestion, open an issue on GitHub, or choose Help > Report an Issue in the app.
Further reading
- Ollama: a tool for running open models on your own computer
- LM Studio: a local model runner with a graphical interface
- OpenRouter: models from many providers through one API key
📘 Original article on HackMD, in Traditional Chinese:
👉 https://hackmd.io/@jeff377/polhem-md
📢 You are welcome to republish this, please credit the source.
📬 Follow for more engineering notes:
Facebook | HackMD | GitHub | NuGet







Top comments (0)