Editing an Existing Card Breaks Field Formatting and Displays Raw HTML

Editing an Existing Card Breaks Field Formatting and Displays Raw HTML

Hi! I'm experiencing a recurring issue when editing existing cards in Mochi.

The card is initially created correctly and works normally. It contains several separate fields, such as ID, Question, Answer, Topic, Source, and Notes. However, when I open an already existing card, click Edit, make any change, and save it again, the card becomes incorrectly formatted when I review it.

After saving the edited card, HTML that should be interpreted as formatting starts appearing as literal text. For example, tags such as <div class="resposta"> and </div> are displayed directly in the card instead of being rendered. At the same time, the structure of the other fields also seems to be lost. Content that originally belonged to separate fields, such as Source, Notes, and ID, is shown sequentially as plain text below the answer, almost as if all the fields had been merged into a single block of content.

The important part is that this does not seem to be only a visual or cache-related issue. I can reproduce the same behavior both on the macOS application and on the iPhone app. I do not use the paid cloud synchronization feature, so I usually move my collection between devices by exporting and importing it manually. Even after exporting the collection and importing it again on a different device, the affected cards remain broken in exactly the same way.

Because the issue survives export/import and also appears on different devices, it seems that something may be changing in the card data itself when an existing card is edited and saved, possibly affecting how the fields or HTML content are serialized and later interpreted.

Has anyone experienced this before, or could this be a bug related to editing cards that use multiple fields or HTML formatting?

Steps to reproduce:

Create a card with multiple fields. Save it and confirm that it displays normally. Open the card again and select Edit. Modify any content. Save the card. Review the card again. The card now displays raw HTML and some of the fields are shown as plain text instead of being rendered/handled separately.

Since this survives export and import, the archive will tell you what changed. Rename the exported .mochi to .zip, open it, and look at one broken card in data.edn (or data.json).

A card has its own :content string, and cards built from a template also carry a :fields map with a value per field. So the thing to compare is a card you haven't touched against one you edited and saved.

Was this deck imported from Anki? A div with a class like resposta is what Anki note types tend to look like, and Mochi's import docs say it converts HTML to Markdown and strips CSS and JS on the way in

If you want the cards to be robust rather than repaired, the native route is a template: fields for Question, Answer, Source and Notes, <> placeholders in the template markdown, and --- where the card should split into sides.

If you post a sample archive, I'm happy to look at what the edited cards contain.

@Livia We'll need to see what your template looks like to help. Most likely this is an issue with a specific template and not a general bug in Mochi.