# Bug report: user-inserted NBSP disappear when editing

**URL:** <https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845>\
**Category:** Help\
**Created:** [February 15, 2026, 9:17pm UTC](https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845 "2026-02-15T21:17:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jd-dev](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/jd-dev/32/32233_2.png) [@jd-dev](https://forums.ankiweb.net/u/jd-dev)\
**Post date:** [February 15, 2026, 9:17pm UTC](https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845/1 "2026-02-15T21:17:11Z")

</div>

Hello,

When entering cards in the desktop editor, I sometimes insert non-breaking spaces (NBSP), as I’m typing in French and the French language requires a non-breaking space to be inserted between the end of a sentence and some punctuation characters (including ‘?’, ‘!’ and ‘:’).

However, the NBSP is deleted as soon as I type the punctuation mark.

I’m using Anki 25.09.2 (built from source – commit `3890e12`) on Ubuntu 24.04.3 LTS x86\_64, but this also affects me on Arch GNU/Linux, with the same version of Anki (package `anki-bin`)

Thank you in advance 🙂

---

<div class="post-metadata">

**Author:** ![BenJamesBen](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@BenJamesBen](https://forums.ankiweb.net/u/BenJamesBen)\
**Post date:** [February 16, 2026, 2:45am UTC](https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845/2 "2026-02-16T02:45:16Z")

</div>

> [@jd-dev](#):
>
> I sometimes insert non-breaking spaces (NBSP)…  
> … between the end of a sentence and some punctuation characters (including ‘?’, ‘!’ and ‘:’).
> 
> However, the NBSP is deleted as soon as I type the punctuation mark.

Could you please provide the steps you are performing when seeing this bug, with enough detail so others can try to reproduce it? For example:

- What keys are you pressing to insert the non-breaking space character?
- Where are you doing this typing? Is it in the regular field or the HTML editor for the field?

I did some testing on the Anki 25.09.2 Mac desktop app:

1. In the Add window, I pressed the “\<\>” icon next to a field to expose the HTML editor for the field.
2. In the HTML editor field, I typed the characters `a&nbsp;` to insert the letter “a” followed by a non-breaking space character.
3. I observed that the HTML editor field contained the text `a&nbsp;` and the regular field contained `a `.
4. In the HTML editor field, I then typed the `!` character.
5. I observed that the HTML editor field contained the text `a&nbsp;!` and the regular field contained `a !`.

So, the non-breaking space character did not get deleted when the punctuation mark was typed.

However, I also saw this behavior for alternate steps 4 and 5:  
4. Switcing to the regular field, at the end of the existing text I typed the `!` character.  
5. I observed that the HTML editor field contained the text `a !` and the regular field also contained `a !`.

So, in this alternate procedure I again saw that the non-breaking space did not get deleted when the punctuation mark was typed. However, the non-breaking space did seem to get replaced with a regular space character.

---

<div class="post-metadata">

**Author:** ![jd-dev](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/jd-dev/32/32233_2.png) [@jd-dev](https://forums.ankiweb.net/u/jd-dev)\
**Post date:** [February 16, 2026, 6:17pm UTC](https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845/3 "2026-02-16T18:17:24Z")

</div>

Sure!

First, I’m using the BÉPO keyboard layout that allows me to enter a non-breaking space using Ctrl+Alt gr.+Space bar (at least using xkb on GNU/Linux). I think xkb actually lets you use this combination to type a NBSP in any layout, but I’m not sure about that. The behaviour I describe also happens when copy-pasting a NBSP in the field.

So when I do the following steps:

1. Open the “Add card” window (and select “Basic” as card type for instance);
2. Type some text in the non-HTML field (i.e. the regular field);
3. While typing the text, type a non-breaking space using Ctrl+Alt gr.+Space bar, then a punctuation symbol, such as ‘!’;

what I observe when looking in the HTML editor field is that a `&nbsp;` tag is inserted when I type the NBSP, but as soon as I type the ‘!’, the NBSP is replaced by a regular ASCII space.

By the way, doing the same steps as above but in the HTML editor field inserts a NBSP character in the editor, which is replaced by `&nbsp;` as soon as the field is unfocused.

I can provide screen recordings if necessary

Edit: it seems like putting a regular space at step 3 also adds a `&nbsp;` tag that gets replaced by a space when typing ‘!’ (or any character). Also, manually replacing a space by a NBSP when there are characters before and after does not changes it back to a space

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [March 18, 2026, 6:18pm UTC](https://forums.ankiweb.net/t/bug-report-user-inserted-nbsp-disappear-when-editing/68845/4 "2026-03-18T18:18:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
