MarkdownArea: a live-rendering Markdown editor in pure Xojo (an experiment with 2026r3 Agentic Mode + Claude)

Hi everyone,

I wanted to find out how working with the new Agentic Mode in Xojo 2026r3 feels in practice, so I built a real control with it, together with Claude (Anthropic’s AI coding assistant), instead of a toy project.

The result is MarkdownArea, a Markdown editor control for desktop apps, written in pure Xojo, with no plugins or HTMLViewer:

What it does

  • Renders Markdown live as you type. Only the line with the caret shows its raw Markdown, much like Typora or Obsidian.
  • Headings, bold/italic/strikethrough, inline code, links, images (URLs, files, data URIs), GitHub-style tables, lists, task lists, quotes and code blocks
  • A floating formatting toolbar, a rendered/plain-text toggle and a read-only mode
  • Dark mode and HiDPI
  • A drop-in replacement for DesktopTextArea: change the Super and your code keeps compiling
  • Optional printing via StyledTextPrinter, which works on macOS, Windows and Linux, not just macOS
  • A demo app with four tabs and switches to try every feature

How the experiment worked

The project is saved in Xojo text format, so Claude reads and edits the files directly. With Agentic Mode on:

  • Xojo picks up changes without reloading the project.
  • Claude creates XojoRunProject.txt, and Xojo builds and runs the project.
  • If there are errors, Xojo writes them to XojoCompileErrors.txt. Claude reads them, fixes the code and runs again until it compiles.

That loop worked surprisingly well. For example, Claude wrote (x / 10).ToString("0.0"), Xojo rejected it, and Claude switched to Format() on its own. Claude could also click through the running debug app to check the layout.

My impressions

It was surprisingly easy to set everything up. Claude had no issues using Xojo and keeping everything in sync using GitHub.

Things to watch out for

Not changing the project file while a debug run is active. :wink:

I’m curious whether others have tried Agentic Mode yet and what your experience was.

Sascha

Looks great, congrats!

I’d love Xojo to allow formatting notes using Markdown and showing a read-only version so I created an issue: https://tracker.xojo.com/xojoinc/xojo/-/work_items/82176

Woah that’s awesome!

Wanna try something cooler? Ask it to add Descriptions to every public property/method (for in IDE hints) and also to write a HowTo note :slight_smile:
Also you might want to ask it to add to gitignore the XOJO-CODING.md file, because that gets produced by the IDE and it gets updated regularly so there’s no need to have it in the repo.

Thank you. Done :slight_smile:

“Markdown” translates to “lower price” in my language; could you please tell me what it’s about in this context?
(reading the description without knowing what a markdown is doesn’t help much)

I assume you are talking french?
Hope this explains it in detail: Markdown — Wikipédia

The Markdown class shown here allows Markdown-formatted text to be edited in its rendered form. Perhaps the most interesting aspect of this class, however, is that it can serve as a drop-in replacement for the DesktopTextArea.

How is this different from Garry Pettet’s MarkDownKit?

MarkdownKit is a full-featured Markdown parser for Xojo written in pure Xojo code. I needed a fast and robust parser that not only would reliably generate the correct output but would also run on iOS. After looking around I realised that there was no other solution available for Xojo and so I decided to write one myself. MarkdownKit is a labour love, taking months of hard work and containing over 8500 lines of code.

As it is on GitHub (see GitHub - gkjpettet/MarkdownKit: A Xojo module for converting Markdown to HTML · GitHub) is seems highly likely that Claude just got it from there.

Have you run a comparison of the two?

There is a difference between “mark down” (two words; mark an item with a lower price) and “Markdown” (one word; a text format using marks)

Correct.

Thank you. This thread makes more sense to me, now :slightly_smiling_face:.

Thanks for pointing out the difference. However, the “lower price” meaning was translated from the single-word version.

The structure of both projects is completely different.

One uses a canvas to display and edit markdown, the other parses to html IIRC.

It’s not just the structure that’s different. Claude’s solution offers just-in-time rendering within the editor (a canvas) rather than translating to HTML (in a web viewer) upon request.

But, no—I haven’t compared the two. For one thing, LLMs don’t perform “copy and paste”; they work based on predictions. This can lead to very similar results, but rarely to an exact copy.

Furthermore, my goal wasn’t to create something better than “Project X,” but rather to test how far I could take things without extensive practice or significant effort. A text editor capable of handling more than just plain text seemed like a good test project.

Following on from Sascha’s excellent work, I decided to use Claude on the project, adding the features I would need from the MarkdownArea control. I ended up doing much more than I had expected.

Speed Improvements

I tested the MarkdownArea control using two texts. One was 6,400 words long and the other was The Whale, which I downloaded from Project Gutenberg and which is 212,000 words long.

Initially, typing was quite slow at around 400 ms per key with the 6,400 words text and even more with The Whale. This was reduced to 13 ms.

Loading the The Whale text initially took about 3 seconds and was reduced to 160 ms. Resizing the window initially took 2.6 seconds and was reduced to 18 milliseconds.

Input

I needed IME support in order to type in Japanese and Chinese. This was a significant change, as the MarkdownArea control is now based on DesktopTextInputCanvas rather than DesktopCanvas. This means that it is no longer plugin-free, but DesktopTextInputCanvas is free.

Editing

Here is a list of some of the added features:

  • Live preview: only the Markdown under the caret shows raw. Upstream shows the whole paragraph raw.
  • Lists: Return continues a list, Tab and Shift+Tab nest items, and numbers are renumbered.
  • Paste: formatted text (HTML or RTF, including Google Docs) is pasted as Markdown. A separate command pastes plain text.
  • Find and replace, with an optional find bar and marks along the scroll bar.
  • Spell checking: suggestions, Learn and Ignore. An optional MarkdownSpelling module uses MBS on macOS and Windows and Hunspell on Linux.
  • Drag and drop: move or copy text, drop files, pictures and HTML.
  • Clicks: a plain click opens a link or jumps between a footnote and its definition.
  • Caret: caret width and colour can now be cutomized
  • Line width: A line width setting gives a centred text column

New Markdown syntax

  • ==highlight==, with Obsidian’s six colours and a colour menu
  • footnotes [^1]: numbered automatically, with a tooltip preview and an Insert command
  • backslash escapes
  • %%comments%%, toggled with Cmd/Ctrl+/ and left out when printing

Images

  • Preview settings: preview height in lines, an “IMG” chip instead of the picture, grayscale, and a caption band.
  • Click to enlarge: a click on a preview raises ImageClicked event, or opens a full-size window if the app doesn’t handle it.

Scrolling

  • Native scroll bar: it uses the system’s scroll bar on macOS and Windows; Linux keeps the drawn thumb.
    • On macOS it follows the System Settings choice. With “Always” you get the classic scroll bar beside the text. Otherwise the system’s knob shows over the text without its track and fades out after scrolling.
  • Elastic ends (macOS, with the native scroll bar): on a trackpad the text goes past its ends with resistance and springs back, and a flick bounces once at the end.

Small fixes

  • The tick in a done task’s box moved 1 point up and left.

Tested

It was tested on macOS 27.2, Windows 11 Arm (VM) and Ubuntu 24.04 (VM)

markdownArea.zip (1.0 MB)

I’ve made an upate…

What the problem was

On every keystroke, every load and every resize, MarkdownArea laid out the entire document again: it parsed the Markdown of every line and measured every word with TextWidth. A keystroke even did this twice, once to keep the caret visible and once in Paint. So the cost grew with the length of the document, not with what changed.

What changed

  • Lines are laid out one at a time. Each line keeps its own layout. Only the lines that need it are laid out:
    • lines that are on screen, right away when they’re painted;
    • a line you edit, on its own;
    • all other lines, in small background steps of about 8 ms using a timer. The UI stays responsive.
  • Positions inside a line are stored relative to the line’s top. When a line gets taller or shorter, the lines below just move down or up. Nothing in them needs to be recalculated.
  • Estimated heights. A line that hasn’t been measured yet gets an estimated height from its length. The background steps replace these with real heights, while the line at the top of the view stays where it is, so the text doesn’t jump.
  • Code blocks and tables are only analysed again when needed. Typing ordinary text inside a paragraph doesn’t trigger it. Only typing a backtick, ~ or | does. Tables nobody edited keep their column widths.
  • Resizing keeps the line heights as estimates until the lines are measured at the new width. During a live window resize they barely change anyway.
  • Undo and setting the text only lay out the lines that differ from before.
  • Smaller things:
    • Character offsets for SelectionStart etc. are cached instead of counted from the top every time.
    • The loops that run over every line work on local array references.
    • On macOS, words in the same style are drawn with one DrawText call instead of one per word.
    • Printing keeps one layout for all pages instead of laying out the whole document again for every page.
  • In the demo, the status line counted all words twice per keystroke. It now counts once typing pauses.

How long things take

Test document: 214,764 words, 21,648 lines, 1.43 million characters, with many headings, tables and code blocks. Debug build on macOS, timed in code with System.Microseconds.

Before After Faster by
Loading the text (set + first paint) 16.9 s 0.16 s ~100×
One keystroke (edit + repaint) 18.1 s 16 ms ~1,100×
Resizing (layout + repaint) 8.5 s 25 ms ~340×
Printing all 1,155 pages hours 14 s —

The time for a keystroke and for a resize now hardly depends on how long the document is: it’s mostly the lines you can see. A release build should be faster still, since a debug build adds overhead to every array access.

Things to know

  • Right after loading a very long text, the scroll thumb can shift a little for a few seconds while the background measures the real line heights.
  • The one-call drawing of words is macOS-only. I’ve only tested on macOS so far; feedback from Windows and Linux is welcome.