6 ms·
Show HN: A WYSIWYG word processor in Python
Hi all,
Finding a good data structure for a word processor is a difficult problem. My notebook diaries on the problem go back 25 years when I was frustrated with using Word for my diploma thesis - it was slow and unstable at that time. I ended up getting pretty hooked on the problem.
Right now I’m taking a professional break and decided to finally use the time to push these ideas further, and build MiniWord — a WYSIWYG word processor in Python.
My goal is to have a native, non-HTML-based editor that stays simple, fast, and is hackable. So far I am focusing on getting the fundamentals right. What is working yet is:
- Real WYSIWYG editing (no HTML layer, no embedded browser) with styles, images and tables.
- Clean, simple file format (human-readable, diff-friendly, git-friendly, AI-friendly)
- Markdown support
- Support for Python-plugins
Things that I found:
- B-tree structures are perfect for holding rich text data
- A simple text-based file format is incredibly useful — you can diff documents, version them, and even process them with AI tools quite naturally
What I’d love feedback on:
- Where do you see real use cases for something like this?
- What would be missing for you to take it seriously as a tool or platform?
- What kinds of plugins or extensions would actually be worth building?
Happy about any thoughts — positive or critical.
Greetings
- LoganDark 5mo agoLove to see wxPython!
- mttpgn 5mo agoOn MacOS, I'm seeing `ModuleNotFoundError: No module named 'miniword.core.utils'` whether I run `python3 -m miniword` from src/miniword/ or from src/miniword/miniword/.
- chrisecker 5mo agoMy mistake. Now it works (on linux).
- mttpgn 5mo agoThanks, and I got the main window open now, but I'm getting a second error that doesn't look OS related. `Plugin error (txtfilter.py): No module named 'miniword.importexport'`
- chrisecker 5mo agoFixed it. Thanks for reporting.
- avryhof 5mo agoLooks like a nice project. Looks like you missed a file, though. ModuleNotFoundError: No module named 'miniword.core.utils' I don't see it in my local clone of your repo, nor the repo iteslf.
- chrisecker 5mo agoMy apologies. I added the missing file.
- avryhof 5mo agoThanks. I got it to run on my work laptop that runs Windows. Selections don't work, and cairo spits out a bunch of errors during the screen redraws. I'll give it a shot on my own Ubuntu laptop.
- chrisecker 5mo agoI have been able to install MiniWord under Windows. It is a bit more challenging. You should use cairocffi instead of pycairo: pip install cairocffi You also need to install the Cairo DLL. The easiest way is to install the full GTK3 runtime from: https://github.com/tschoonj/gtk-for-windows-runtime-environment-installer/releases https://github.com/tschoonj/gtk-for-windows-runtime-environm... You must add the directory containing libcairo-2.dll to your PATH environment variable. In my case, this is: C:\Program Files\GTK3-Runtime Win64\bin Note that MiniWord is not yet optimised for Windows. While it mostly works, the rendering quality is lower and startup is slow.
- chjail-11 5mo agoI adore anything that avoids using a browser. <3
- kubb 5mo agoI thought the data structure part is solved: https://en.wikipedia.org/wiki/Rope_(data_structure) https://en.wikipedia.org/wiki/Rope_(data_structure)
- chrisecker 5mo agoRopes are for strings. In a word processor you need text with formatting, and structures as tables, images and math.
- fractallyte 5mo agoOne feature missing from almost every mainstream word processor: REVEAL CODES! (https://kb.corel.com/en/127364 https://kb.corel.com/en/127364) This is a famous "killer" feature from WordPerfect: the ability to view and edit the low-level formatting for a document. It's invaluable for fixing weird bugs. However, it works only because WP uses the "text-stream" paradigm, where a document comprises a linear stream of text with formatting codes (Bold, Font, Hard Return, etc.) embedded directly at the point at which they're applied. In contrast, Word uses the "nested containers" model (characters inside words, words inside paragraphs, paragraphs inside sections, etc.), where this feature can't be replicated. I didn't look closely at your code, but just thought to mention this feature.
- nomdep 5mo agoI don't see why the "nested containers" model would prevent this feature to be replicated, it's just a tree of nodes. Not edit-this-as-plain-text-simple but almost.
- vishnuharidas 5mo agoThis took me down the nostalgic memory lane of the planet-source-code days. There were hundreds of such projects in Visual Basic, Delphi, C/C++/MFC etc., and text editors and paint clones were the most popular projects.
- analogpixel 5mo agoat this point, a WYSIWYG just seems like a huge step backwards from just using markdown. I love having access to my files in a standard text format this is super easy to parse, and not being locked into whatever weird format that WYSIWYG decides to store it in. I still don't understand why people still use ~~Microsoft Word~~Copilot document writer , I think they have gotten into some weird mindset that their documents require all this weird unnecessary formatting to look "official"
- httpsterio 5mo agoMarkdown without formatting isn't usually the nicest to read imo. I actually appreciate a well laid out and formatted document myself. Also wysiwyg doesn't mean it can't be back and forwards compatible with markdown, it might just mean that it's a markdown editor gui with a preview.
- layer8 5mo agoIt’s also not nice to write longer text in monospace. Or to have long URLs interrupt the text just because you want a hyperlink on some word. Or having to lay out tables by hand like ASCII art. Seeing *this* isn’t the same as seeing this. And you need custom editor software anyway to have affordances like TOC navigation.
- yummybrainz 5mo ago> long URLs interrupt the text just because you want a hyperlink This annoyed me until I realized pandoc supports separating [the link text] from the link location. [the link text]: </url/to/resource> "`title` parameter of the <a> tag, if converted to HTML"
- layer8 5mo agoYep, but (a) that isn’t portable Markdown, (b) your editor probably doesn’t support opening the link from the link text in that case, and (c) whenever you want to modify the link text you have to modify all occurrences. A word processor can handle that automatically for you. It can also offer completion (like tab completion) for references that you use repeatedly. It can show as a tooltip what a given link text links to. Conveniences like that is what computers are for, let’s not relapse to the stone age here.
- johnwhitman 5mo ago[dead]
- __d 5mo agoThis is great! Curious about the choice of toolkit: what led you to wxPython?
- chrisecker 5mo agoWhen you want to develop cross platform apps which use the native widgets, there are not so many options. The two big players are qt and wx.
- subdomain 5mo agoI love seeing new word processor projects!
- kabir_daki 5mo ago[dead]
- chrisecker 5mo agoCursor positioning is simple. The layout is a tree of nested box. Each box knows the x,y-position of its children. There is also an index dimension which numbers possible cursor positions. A box lies from i1 to i2 in index space. You just iterate over all boxes holding cursor position i to find the cursor coordinate x,y. Selection is simple as well. It is defined by a start index s1 and end index s2. Some objects have a special selection, e.g. tables where you select a rectangular range of table cells.
- chrisecker 5mo agoI came from the TeX-Approach where all layout elements are boxes which contain other boxes. This box-tree is a kind of DOM if you want. But the box-tree only represents the layout, not the data itself. For the data you usually have a separate object. In Word this used to be the piece table structure, now it is probably something else. I described my approach here, if you want to know how and why: https://codeberg.org/chrisecker/texeltree/src/branch/main/doc/essay.md https://codeberg.org/chrisecker/texeltree/src/branch/main/do...
- Georgelemental 5mo ago> - Real WYSIWYG editing (no HTML layer, no embedded browser) with styles, images and tables. > - Clean, simple file format (human-readable, diff-friendly, git-friendly, AI-friendly) Very nice! Unfortunately, the UI menus seem to be broken when using a dark-mode GTK theme (e.g. Adwaita Dark).
- chrisecker 5mo agoYes, I can see what you mean: There are hand coded colors together with system colors. With the dark mode this gives white text on white background for the side panel. Thanks for mentioning.
- pbronez 5mo agoCheck out Typst. It’s a markup language focused on print with HTML layout as a secondary target.
- emanuele-em 5mo agoTables and images are the part where every "just use a rope" answer falls apart, so going B-tree feels right. I tried building a minimal rich text editor last year and got stuck exactly at the point where tables stopped being attachable as metadata and needed to live in the structure itself, ended up shelving it. Good to see someone actually push through it.
- antisol 5mo agoYou had me at "non-HTML-based" ;) I've been looking for a simple word processor that will let me easily/quickly do basic things and which will let me export to markdown and HTML that isn't terrible like the type word processors create. I recently found wordgrinder (https://github.com/davidgiven/wordgrinder https://github.com/davidgiven/wordgrinder), which is a terminal-based word processor that's very close to what I've been looking for. A wx-based thing like this might be a bit nicer. So I'll start with one suggestion: support for wordgrinder's .wg format would be real nice :)