My span elements disappear if i type in a line where they’re present.
There’s a few strange conditions necessary for this to happen, there has to be another span of the same class, even no class is fine and the occurrence can be anywhere later on in the text. The element has to have nothing inside of it.
In Live-Preview Place your cursor at the very end of the very first </span>. Now type pasta. The first span element is now deleted (not merely invisible). You can verify this by pressing ctrl+A or using source mode.
How can I prevent this behavior?
Also, it would even work for <span></span>, but I added a class to make it clearer that I am using these span-elements for a meaningful purpose.
Things I have tried
Obviously I reproduced this in sandbox mode. And I googled about the problem but I couldn’t find anything about it except for html disappearing when one switches to Read mode, which is not my issue.
Debug info: Obsidian version: v1.9.10, Installer version: v1.8.4, Operating system: Windows 11 Pro 10.0.26100
I posted here rather than debug because irrespective of whether it is a bug, am trying to find a solution.
Maybe I’ve misunderstood the problem, but this seems like expected behavior to me. Live Preview renders Markdown and HTML except the parts you’re interesting with, so an empty HTML element that you’re not interacting with will be invisible. If you want to see it, you can use Source Mode (as you’ve found).
It’s not that <span class="emoji-quark"></span becomes invisible or that it doesn’t render.
It’s that the string <span class="emoji-quark"></span in the note is actually completely gone, it’s deleted.
You can check it by doing my procedure in Live-Preview.
You can verify it after by for example: 1. Press ctrl+A, or 2. Turn on Source-Mode, or *3. Use CSS to render that element as an image, which is how I first noticed it.
I see what you mean now. I had pasted your example into a note but not done the typing, or maybe I deleted the As and retyped them. I was confused by the example because it says to type As but already contains some.
I’ve edited your original post to fix the typo, emphasize that the span is deleted, and make the example less ambiguous.
I tried to make the example smaller but found it didn’t trigger the deletion. I didn’t explore to find the minimum number of letters required; maybe you already did that.
You may have found a bug. Could you file a bug report (if one doesn’t already exist), following the template that appears in the text box when you make a new post in Bug reports? (The template includes instructions for ruling out plugins and other non-Obsidian causes.)