Indent under header doesn't create code block

This is the one thing that is keeping me from using Obsidian right now. I just want to make a header, press enter, tab over, and make a list or start typing a sentence. But it creates a code block.

First off, I know, “that’s how markdown works.” I know that. I hate it. I’m used to apps that mainly use Markdown for text formatting like headers, bullets, bold, italics, etc. In those apps to do a code block to use the three ticks. I can still tab under a header and type anything.

I like to indent topics underneath parent topics which is why I like to indent under headers. But I can’t do that on Obsidian. Obsidian can do a million different things, but it can’t do this. Again, I know that’s how markdown works, but I would love just a slider in the options that says, “disable code block by indenting” or something to that effect. Please!

4 Likes

It sounds like you should be using CSS to change how the text appears.

you are asking to go against the markdown spec.

I know. I acknowledged this in my original post.

I understand how markdown works. But having used apps like Bear and Ulysses that use a flavor of markdown or markdown lite (not full markdown) I got used to the ability to tab or indent underneath a header. It’s not a crazy thing to do.

There are two ways to create a code block in markdown. One is easy to accidentally do, indent under a header, another is nearly impossible to accidentally do, typing three tick marks.

I’m just asking for a simple switch hidden deep in the settings that could turn off the ability to create a code block by indenting under a header.

1 Like

+1
This is what prevents me from fully migrating to Obsidian.
Every document I import inadvertently ends up having undesired code blocks due to tabs and all formatting is screwed up.

(BTW I assume this is what every new user without coding/markdown experience will stumble over and make the app seemingly confusing to use for note taking)

@ryanjamurphy kindly suggested a css code to change how the code looks - but it will still be formatted as code, if I understood correctly.

See: Option to change default tab behavior - #9 by ryanjamurphy

3 Likes

I think it’s unlikely a feature like this will be implemented since the goal of obsidian is to stay as close as possible to the markdown spec.

The CSS suggestion wasn’t about formatting the indented code block as normal text, but rather to use CSS to “indent” the text after a header. The tab itself won’t be there, but it will look indented. If that’s something you’re interested in, pop by the discord and ask one of our CSS wizards if they can help!

1 Like

This is what is keeping my from coming to Obsidian and just is making me wait for a good outliner style app to actually make a mobile app (doesn’t seem likely soon unfortunately).

I love the community of Obsidian a lot, but they always say, “Obsidian can do anything at all! There are tons of plugins for anything you want to do!” And that’s true, kanban, task management, calendar integration, spaced repetition, etc.

But if you want to indent under a header, get out of here. The fact that such a simple thing cannot and possibly will not ever happen is a total turn off and negates the flexibility of Obsidian for me personally and how I like to write and take notes. It’s so crazy that this one thing baffles a lot of people and no consideration will even be made to implement it.

1 Like

I guess it’s a lot a matter of preferences. It’s hard, if not impossible, to give everyone what they want. Many/Most users are fine with the alternatives or prefer adhering to the markdown spec. Deviating from the markdown spec is unlikely, in my opinion, but I might be wrong or some plugin developer could create something for this. You are also very much welcome to take this into your own hands since the API is public.

It’s alright if this is a dealbreaker for you, I don’t mean to sway you one way or another. I’m mostly adding options in case you want to consider them (if not that’s fine!) and for the benefit of other users who will stumble upon this thread in the future.

Another recommendation that just came into my mind thanks to your comment about plugins: For those wanting an outliner experience, the (duh!) outliner plugin is great! You might not be able to handle headers as was asked in this question, but that sure will help you if parent-child relationships are important to you!

2 Likes

Thanks for the response.

The outliner plugin is ok. It’s not great and doesn’t work in mobile either.

This is the only app I’ve used that has the code block under a header to indent. Most apps I use are really just “markdown lite” like Bear and Typora. And since I’ve used those apps for so long I’ve come to believe that I could do that in Markdown. But they weren’t using full Markdown specs.

It just kind of stinks that if I want to indent under a header - it’s literally impossible in Obsidian. And that’s not a strange thing to want to do, it’s a normal part of writing for a lot of people.

I guess I’ll just wait for a developer to hopefully figure this out as a plugin. Thanks.

Can you post an example where you can’t put a code block under a header?

Brian’s issue is that if he puts an indented bullet list under a header, it gets parsed as code block and he just wants it parsed as bullet list.

Brian, through trial and error I’ve put together this snippet:

  • it parses indented bullets as normal text
  • downside: code blocks are also parsed as normal text
  • bullet lists which start with an indented bullet are not recognized as bullet lists, i.e. you can’t fold the children. But you can fold from the header.

YMMV, I’m not using this snippet myself due to above shortcomings, but instead got used to not indenting bullets.

Maybe someone else has ideas how to improve the snippet.

Edit: might be interesting for you: @mat_rhein @Dor @Peanut @fierce_ninja




/*---- MAKE CODE LOOK NORMAL ----*/


/* EDITOR */
.cm-hmd-indented-code {
    color: var(--text-normal) !important;
    font: var(--text) !important;
}


/* PREVIEW */
.markdown-preview-view pre {
    color: var(--text-normal) !important;
    font: var(--text) !important;
    padding: var(--text) !important;
    background-color: var(--text) !important;
}
.markdown-preview-view code {
    color: var(--text-normal) !important;
    font: var(--text) !important;
    padding: var(--text) !important;
    background-color: var(--text) !important;
}

/* THIS IS APPARENTLY NOT NEEDED */
/.markdown-preview-view pre code {
/    color: var(--text-normal) !important;
/    font: var(--text) !important;
/}

obsidian default parse code as normal text.css (709 Bytes)

1 Like

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