Insert XML into code block

Something is wrong when pasting the XML into the code block.

Steps to reproduce

Here is my piece of code which i copy from IDE (IntelliJ)

file settings

And paste this into a block of code

Expected result

When pasted into any text editor
be it notepad

or Sublime Text

It looks great

Actual result

But when I paste this into a code block in Obsidian I get this

I can bring it all back to normal by removing extra spaces and adding line breaks

Also, the text is pasted normally if I first paste it into a regular text editor (Notepad, Sublime Text), and then copy it from there and paste it into obsidian

Everything also works fine if I open this file not in IntelliJ, but through a text editor. It displays normally and is copied and pasted into Obsidian normally.

It seems that the problem is on the side of the IntelliJ, maybe he adds some metadata there or something like that IDK, but the fact is that text is inserted into any text editor normally, but not into Obsidian


  • Operating system:
    Windows 11 Pro
    Windows Feature Experience Pack 1000.22636.1000.0

  • Debug info:
    Obsidian 1.1.16
    IntelliJ IDEA 2022.1.4

Try pasting the working (non-IntelliJ) and broken (IntelliJ) versions into an editor that has an option to show invisible characters. Do you see a difference between them?

I turned on the display of invisible characters in Sublime Text and did not see the difference

when trying to do the same in Microsoft Word i got this

Dark background, different font, text size, text color

It turns out that all this formatting data is also stored in the clipboard?

Yeah, I think clipboards in general (definitely on Mac) store multiple things and paste the most appropriate one depending on context — plain text, rich text, a URL, etc.

Using Shift+Ctrl/Cmd+V to paste will give you the plain text version. You can also turn off Settings > Editor > “Auto convert HTML” to paste plain text by default. Perhaps one of these will help.

1 Like

Both of these tips helped me. Thank you!

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