Rendering of code fences in small windows

Steps to reproduce

Copying terminal output from zsh into code fence on small window causes rendered text to be extremely long.

Using fresh install of Kali Linux (machine image here) with zsh installed by default.

Initially I thought that newlines were being inserted into the code fence - but it seems specific characters from zsh terminal output cause the code fence to be ‘stretched’ when the window is small.

Expected result

E.g. with this terminal output:

└─$ mkdir example
└─$ cd example

On a large window the output looks normal:

Actual result

On a smaller window (half size window, with panes split vertically):


  • Operating system: Kali Linux 2021.2
  • Obsidian version: v0.12.12

Additional information

There are 26 ‘newlines’ in the ‘unexpected’ output.
I don’t think they are actually newline characters - when text is pasted into another text editor e.g. notepad the text inbetween the terminal commands appears to be several tab-like characters (i.e. for indentation of text).
I suspect this is something to do with how code fences render these specific characters.
This issue doesn’t occur when copying from a regular bash terminal.

This photo shows how the characters are rendered when highlighted:

The characters can be deleted, but it’s cumbersome to do so as the pane scrolls to the right when the text is highlighted.


Edit: problem does not disappear on larger windows. With window maximised, pasting fresh text causes the same issue to appear:

The terminal output:


And the text pasted into another text editor (mousepad):


Mousepad shows the problematic characters - line 313 is two lines long, and has a large number of characters in it which seem to be causing the issue:

This is likely partly zsh's fault, but it would be great if the code fences rendered the characters in a similar way to mousepad. Currently I’m having to copy individual commands to avoid this issue.


I am not going to take this as bug. Obsidian is rendering what your are pasting.

1 Like