Live Preview: Better support of code blocks in lists

I fully agree.
Codeblocks not being rendered correctly in lists is MOST DEFINITELY a bug.

9 Likes

This is the single feature that should be at the topmost priority. Why is this not being fixed??

5 Likes

The top feature? Come on, take a look at all the feature requests and tell me this is more important than the hundreds of other FRs.

I believe better markdown rendering is fundamental as compared to other features. If this is done, it would be much easier to edit quotes/codes/tables at a bullet (list) level without having to worry about indentation. Currently Typora has a really good markdown experience. This is where obsidian should catch up. If the markdown live editor experience is great, then any other feature would certainly benefit.

I also think it’s more a bug than a feature request.
Maybe not the top bug. But still something to consider.
There are quite a lot of developers amongst Obsidian users, including me.
Also, it may be quite simple to fix? Isn’t it?

Unfortunately, It’s not quite a simple fix. There are several parts of Live Preview that aren’t just buggy but flatout not done (just search “Live Preview Support” ).

I can move it to Bug Reports if it makes you feel better but it wont make this get done any faster. Right now, the attention is elsewhere and these issues will likely be addressed in batch next time LP is reworked. Sorry!

12 Likes

I wouldn’t be as passionate(or perhaps, dramatic) as some people are about this, but I see where they’re coming from. The lack of this feature/bug-fix makes an outliner-loving developer’s workflow essentially impossible in Obsidian.

Or, maybe unexpectedly, this also excudes workflows that depend on “special-block-in-a-list-style” functions. Callouts or block quotes, for example, fall prey to the same sort of malfunction. This means plugins that rely on code blocks, like Dataview or Dynamic TOC, also don’t work in lists. If this were added/fixed, it’d open a whole host of new opportunities for extensibility in lists.

As a developer myself, I understand the shift away from active LP development—it’s exhausting to have to tinker with one thing without end. That said, I’m glad this is still somewhere further down on the docket because it’d be a valuable piece of a more comprehensive Obsidian markdown experience.

I do think this should be under Bug Reports, simply because when I first tried it, I was thinking “okay, this 'oughta work”, rather than “I wonder if this works”. It feels like something you’d expect to be there, yet it isn’t actually there. I think that’s closer to a bug than a feature request, but it probably just comes down to your opinion on semantics.

9 Likes

+1 this is an important issue to fix

7 Likes

+1 ! Poor WYSIWYG rendering is why I hesitate to migrate from LogSeq to Obsidian entirely :sob:

4 Likes

+1! this’s important

3 Likes

+1
this issue is the only bad point

3 Likes

+1
Actually, I’m pulling my hairs off my head trying to put CodeBlock into list.
It’s bugged as hell.
Took this app to write faster and better notes with the markdown support.
Actually here I’m loosing Hours trying to fix the mess…

Edit 1 : I Found a temporary fix, gonna smoke another cigarette and then post it in Edit 2.

Not sure why Obsidian’s editor mode struggles with embedded markdown in any kind of indented md, but this definitely feels inline with the issues that callouts are having

1 Like

Edit 3 : This is the behavior I have in screenshots and a ´fix´ for CodeBlock in Lists.
Notes that I am working on the Intel Mac version on Ventura 13.1.







And a reply to my post to say, if your trying to copy/past in CodeBlock that are in list, your in for some other troubles… (at least I am).
No matter if you command+v or command+shift+v.
I just quit trying to use CodeBlock in List as for now, the behavior made me lose 8 hours of my time.

2 Likes

Hello. For those still struggling with the behavior of codeBlock in list, I found this post and it helped me a lot to incorporate correctly.

Also what helped me to prevent wonky behavior when you copy/paste code in a codeBlock that is in a list is to activate ´Scroll long lines´option in Style Setting plugins.
That way you can control the behavior in editing more without weird display behavior.
This imply you are using the Minimal Theme Settings plugin + its Style Setting.

1 Like

The current state of the code blocks in live View is pretty bad.
As a coder who stores a lot of code snippets in my note, I am really questioning if obsidian is the right software for this :confused:

Does somebody know if there is currently development ongoing or planned to fix this situation?

18 Likes

This is an intolerable error, please be sure to fix it asap…

This is indeed a serious bug that deserves its reputation as the top bug report of all time. Come on guys, time to send it to the graveyard! :blush:

My cumbersome workaround is keeping code blocks stashed at the bottom of a file, then copy-pasting block embeds into a list.

This way, I can properly indent code blocks. But this is rather time-consuming, and it is easy to get lost as the page gets longer.

It would be great if this bug could be addressed so that Obsidian could reach its full outlining potential.

5 Likes

Summary

I also care about this issue, since I can’t easily render nested code blocks while editing in Obsidian. Indenting code blocks in lists is such a useful technique for technical documentation, since you can group and organize complex commands or code snippets—aids readability.

For example, consider the following Reboot your server illustrative procedure:

Reboot your server

The following procedure describes how to reboot yourserver web server.

  1. Connect to your server.

    ssh yourserver
    

    Note: If you leave out your username, then the ssh command defaults to your current username—the one in your USER environment variable.

  2. Reboot your server.

    reboot
    

    Consider the following details:

    1. Insight: Rebooting your server applies industry standard troubleshooting technique.
    2. Gotcha: If you reboot your server during business hours, then all your apps will go down—major bummer.

Markdown reference

I easily (it’s not really easy since I needed to manually type 3 spaces (a pattern I haphazard
realized through trial and error)) rendered that Markdown in this forum Markdown renderer with the following Markdown:

1. Connect to your server.

   ```
   ssh yourserver
   ```
   **Note:** If you leave out your username, then the `ssh` command defaults to your current username—the one in your *`USER`* environment variable.

1. Reboot your server.

   ```
   reboot
   ```
   Consider the following details:
   1. **Insight:** Rebooting your server applies industry standard troubleshooting technique.
   1. **Gotcha:** If you reboot your server during business hours, then all your apps will go down.

Consider the following details about that Markdown:

  1. Observation: Notice that you can clearly see which notes, insights, and gotchas correspond to which command—excellent!
  2. Observation: Notice the surprising mechanism to actually render the nested codeblocks: I put 3 spaces in front of the code fences.
  3. Guess: This Obsidian problem is related to confusion about how to actual render nested code blocks in Markdown and for details about those Markdown challenges, see Fenced code blocks inside ordered and unordered lists gist comment and CommonMark Spec docs.

Conclusion

Nested code blocks are great for readability; but hard to actually type. The root cause might be related to the confusion about the Markdown spec—see Fenced code blocks inside ordered and unordered lists gist comment and CommonMark Spec docs.

3 Likes