Tab indicator visible for four spaces on a single line within an nginx code block

Once you’ve done the above, delete everything above this line.

Steps to reproduce

on a clean obsidian install make a new note:

    ```nginx
    server {
      listen 80 default_server;
      root /var/www/cs;
      index index.html;
      server_name _;
      location / {
        try_files $uri $uri/ =404;
      }
    }
    ```

Expected result

The overall appearance of the code block should be consistent. but the line with four spaces at the start has a tab indicator while the rest do not, given that the entire block is a code block I would think it better to not use the vertical bar tab indicator.

Actual result

The actual result is a tab indicator within the code block:

Environment

Operating system: Arch Linux x86_64 (DE: Plasma 5.26.4)

  • Debug info:
SYSTEM INFO:
	Obsidian version: v1.1.9
	Installer version: v1.1.8
	Operating system: #1 SMP PREEMPT_DYNAMIC Thu, 22 Dec 2022 01:46:41 +0000 6.0.12-arch1-1-vfio
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

Additional information

This may not actually be a bug and simple a design choice or something that was overlooked. The vertical bar looks very out of place to me. I have used markdown in a few other projects, for example zola static site generator and github, and I don’t remember seeing these within those code blocks.

I can’t reproduce this. And your code example has spaces before the 3 backticks. This is actually a typo, and will just result in a generic code-block with the backticks included in the code-block. But your screenshot looks correct.

In either case, I tried both ways. I see indentation guides on all elements, do it does appear consistent to me.

In v1.1.9 release notes, it was recommended to download and reinstall, to get the latest Electron. So that might be the different factor, in case that is where the prisms.js highlighting comes from. (I’m not sure.)

Since you had some strange indentation before your backticks, I just tested both ways (Sandbox Vault, MacOS, v1.1.11, installer 1.1.9):

With indentation removed:

```nginx
    server {
      listen 80 default_server;
      root /var/www/cs;
      index index.html;
      server_name _;
      location / {
        try_files $uri $uri/ =404;
      }
    }

```

Your original post:

    ```nginx
    server {
      listen 80 default_server;
      root /var/www/cs;
      index index.html;
      server_name _;
      location / {
        try_files $uri $uri/ =404;
      }
    }
    ```

If I remove all the indentation, I see a match to your screenshot.

But to me this just seems like it doesn’t show an indentation guide until 4 spaces. You only have 2 spaces, (or 6 depending if your indentation on the forum was a typo or not, so it’s hard to tell) which I think is the core of your problem.

AND, I tried setting the tab indentation in my Editor Settings to 2 spaces. And it still only shows indentation guides at 4 spaces. So that might be able to be considered a bug. But for your original post, I think we need clarification on the actual indentation you used.

```nginx
server {
  listen 80 default_server;
  root /var/www/cs;
  index index.html;
  server_name _;
  location / {
	try_files $uri $uri/ =404;
  }
}

```

Here is a screenshot with proper 4-space indentation. You mentioned 4 spaces in your post, so I imagine this is what you intend. I suspect maybe you are mixing 2-space indentation with 4-space code-block, but this is not necessary. The backticks are used instead of indentation to create a code-block.

```nginx
server {
    listen 80 default_server;
    root /var/www/cs;
    index index.html;
    server_name _;
    location / {
        try_files $uri $uri/ =404;
    }
}
```
3 Likes

My opening post had an additional 4 spaces because I was having trouble trying to display a code block within a code block. (because of forum formatting)

From your reply this means if somebody uses 2 spaces indentation instead of 4 space indentation they will have weird formatting. The physical screenshot that I took in my opening post is exactly what I meant.

The same code on github with 2 space indentation does not do this.

2023-01-13_19-34-38

But at least now I understand, it was somebodies intention that indentation on code blocks should always be 4 spaces. So if 2 space indentation is used then the lines that happen to have 4 spaces will get the mark while other will not, and it will just look really weird.

I still cannot seem to post a code block within a code block the way that I have it in obsidian. so lets see if this works.

It worked! below you will see the actual indentation that I am using! Thanks for the reply, I do appreciate it.

obsidian.nginx.md (159 Bytes)

Settings > Editor > “Tab indent size“ may help.

1 Like

Surround it with 4 backticks and it will work here on the forum.

1 Like

I thought it might help, I set it to 3 since I always use multiples of 2, so that I can essentially just disable the feature. Unfortunately it seems to still be assuming 4 spaces, so I do not think it made a difference.

Obsidian Editor only supports indentation guides when 1 tab or 4 spaces are used. It’s a limitation of the current editor. There is an open FR about his.