Live Preview: Better support of code blocks in lists

lmao. Has this product died?

Ugh, ran into this bug today. Please fix.

1 Like

Subscribint to this issue.
I guess this is the kind of thing you can get done in logseq and itā€™s almost impossible in every other tool

2 Likes

+1
When will this be fixed? This is fundamental issue. Seriously considering cancelling my subscription as it seems devs donā€™t care to fix a very important problem.

2 Likes

Hi, may I offer a different perspective.

Iā€™m a non-user, assessing moving from Notion to Obsidian. There are only two things stopping me from moving.

  1. Tables suck (fixed in 1.5, what good timing!) and
  2. I canā€™t nest code in an indented bullet list, which I do an enormous amount in my notes (writing a course)

So although maybe this isnā€™t the top most important feature for everyone, for this one person at least, itā€™s the only thing Obsidian needs for me to be able to switch from Notion.

And the fact that a two year old bug with so many comments isnā€™t fixed doesnā€™t give me the confidence to just switch now and trust itā€™ll be fixed soon.

6 Likes

Hi,

I am a recent one-month user who has just moved from Notion to Obsidian. I donā€™t regret my decision to move but I do wish the dev team could work on high priority fixes and features at a more time-efficient pace.

  1. I have tried the new table features in 1.5.0, but I canā€™t say theyā€™re as robust as Notionā€™s implementation yet.
  2. This can be done in a precise way mentioned in someoneā€™s post above.
    Basically write your code block on the root base level, select the entire code block and press Tab until it has as many indents as your current list level. Again, not as robust as Notionā€™s so I hope this gets a better UI/UX treatment.
2 Likes

For what itā€™s worth, Iā€™d also enjoy this feature. I make do without using lists for this, but it would certainly be better if ordered and unordered lists supported indented code blocks. Support for this is common in documentation publication toolchains, and both MkDocs and Docusaurus for example support this style of code+steps at proper indentation. It would be great if it worked here, too. It seems to be a solved problem elsewhere, so itā€™s definitely possible. Thanks.

1 Like

It seems that there is some upstream bug in HyperMD or codemirror as for the following case. The last two lines should not be recognized as part of the code block, but the syntax tree says they are.

Raw markdown

- ```python
	print
  ```

Here is outside the code block!

or

- ```python
print
```

Here is outside the code block!

LIve preview

Reading view

3 Likes

to 2.:
this is not a valid solution.
the tabs will be added to the code when using the copy function (clicking on the code-language indicator).
So tabbing the whole codeblock will ALTER the code (adding tabs), which is an absolute no-go!

2 Likes

I agree with @featurerequestaccoun that altering the code/blockquote with tabs to include it in a bullet or subbullet is not a great solution. Iā€™m not sure how to fix this while staying in valid Markdown but this hampers what you can do with ā€˜outliningā€™ and lists. Itā€™s also not intuitive to include the code block in deeply nested lists, I can never figure out how many indents to add before itā€™s correctly included. Itā€™s fragile.

3 Likes

+1
Iā€™m shocked this has been a large known bug for 2 years now and still not fixed. I often use Obsidian to write myself how-tos for programming and doing terminal stuff and want to have code blocks indented in numbered lists.

This seems like a pretty big missing part of markdown rendering for programmers (probably a fairly large portion of Obsidianā€™s user base).

8 Likes

+1

Just had to deal with this again. I avoided it by just no longer using lists again. But after a while of forgetting about this problem and wanting to use a basic feature like a list, bam, right back to shaking my fist at my nested code block experience.

1 Like

Just throwing my hat in to agree with everything said so far.

The least annoying way Iā€™ve managed to do things so far is as follows:

  1. Make a list.
  2. Shift-Enter to add a new line for the triple backticks:
    Shift-Tab the code block until it's completely un-indented.
    
  3. Paste in your code.
  4. Select the entire code block and hit Tab as needed to re-indent to the correct level.
  5. ???
  6. Profit.

Source code for the list:

1. Make a list.
1. Shift-Enter to add a new line for the triple backticks:
    ```text
    Shift-Tab the code block until it's completely un-indented.
    ```
1. Paste in your code.
1. Select the entire code block and hit Tab as needed to re-indent to the correct level.
1. ???
1. Profit.

Amusingly, the syntax highlighting is broken on the block here.

For this step, itā€™s probably easier to just hit Enter repeatedly until the cursor is all the way to the left. (Apparently, many people donā€™t know that apps often implement the convention that hitting Enter undoes the automatic bulleting and indenting.)

Thatā€™s fair, I suppose Iā€™m just used to treating it like other things Iā€™m trying to enter inline on the same bullet point like images.

I do not understand why this is not being marked as a top priority?

I donā€™t understand why this isnā€™t even on the roadmapā€¦
Obsidian Roadmap - Obsidian

Does the developer team think this isnā€™t even worthy of a future agenda?

2 Likes

I just wanted to chime in with my support for this bug fix. To those who are asking why this isnā€™t a top priority, your concern was answered by @WhiteNoise earlier in this thread. I feel similarly that I really would like to have this fixed, but thereā€™s a lot of work being done on LP, so itā€™s understandable why this bug hasnā€™t already been fixed. Itā€™s going to be folded into a larger release laterā€¦ but I donā€™t understand why that LP overhaul isnā€™t on the roadmap. I understand that with the current business model, youā€™ve got to make Synch a first-class citizen, and I assume that there are a lot of RTL users, but I hope the LP overhaul (or at least this bug fix) makes it to Planned some time soon. Itā€™s frustrating af, and from the outside without access to the code, itā€™s hard to understand why itā€™s implemented in the reading view but not in LP.

As a few folks have mentioned, Markdown is all over the place (it feels about as chaotic as a pack of ADHD Hyenas)ā€¦ so it doesnā€™t make fixing this easy. I really wish Asciidoc had support here. I love how it handles complex lists (see: Complex List Items | Asciidoctor Docs) and really hope that gets implemented someday rather than us having to jump through all the silly md-flavor hoops. Asciidoc has made this sort of stuff easy without all the bs bugginess of md flavors. I think there are a few FE for its implementation, like this one for an ASCIIDOC plugin. I just donā€™t understand why everyone makes their own flavor of md to address issues when thereā€™s already a great flavor (ok, distant cousin) of md called Aciidoc that does all the things, is human-readable, and slick in implementation.

2 Likes