LOL, It’s a shame really, coz it works so well when the code is the right length, and there is no nesting of codeblocks.
What CSS Snippet, have you got one? Because I have been looking high and low, and even talked to some of theme creators out there, they said they had been looking into implementing that feature but they were limited by the live-preview mode of obsidian;.
I fully agree with the rest of your post, but this one in particular also bothered me the most. I’m not 100% sure if it’s a limitation of Markdown itself that Codeblocks don’t display properly within indented bullet-point lists, but it sure does break apart my train of thought when I use a code-block within bullet-points.
According to this stackoverflow discussion you have to be really careful with the amount of indentations that you use. But it sure could be improved in terms of QoL.
yes exactly, I remember one day, I had had enough and i finally sat down to figure out the number of indents you had to do , for obsidian to recognise your code… as code… Now I do it all the time, but still super annoying.
I’m sure there’s more CSS trickery I could do (I tried setting overflow-x: auto; but it sticks a scrollbar in the middle of the codeblock lol) but I agree that this feels like it should be supported natively.
Here’s the weirdness that results with the overflow-x adjustment I mentioned:
I use obsidian a lot for saving old code, preparing for interviews etc. its super fast and super easy. but this is a huge impact on readability of code, i too am using the same hack as you, u just wish they come out with a fix sooner. It’s been 2 years i think.
Devs still doing great work tho. Loving how fast and stable the app is!!
In case it doesn’t break other things, I suggest putting all of a code block’s lines (HyperMD-codeblock) in a common parent DIV. That way, theme authors can add horizontal scroll and apply custom styling to the code blocks as a whole.
It seems like this is not a popular enough feature request, so if you come across this thread because this problem is frustrating to you, please consider contributing to this thread, or creating another feature request i guess.
No devs bothered to respond to this either which is super odd
I think it’s very problematic that in a live preview every line of code is a separate div. A “code block” is not really there, it’s just an appearance. So, you can hide the overflow, but then each long line of code will be scrolling separately, independently of the rest of the “code block”. Like in this screenshot, where I wheel-scrolled the middle line.
The amount of indentation that defines a codeblock is pretty exhaustively documented in the CommonMark spec. A large percentage of the examples in most sections mention spacing and codeblocks.
I agree that letting user choose about scrollbar presence would be nice, and more syntax highlighting by default in Live Preview would be fantastic. Turning everything red is not useful syntax highlighting.
Completely agree. Its pretty horrendous to read when you have loops in loops, especially for indent focussed languages like python. Horizontal scrolling would be amazing (but i think it would be important to be a switch so you can see how it would look otherwise in an export).
True, I feel like Obsidian is truly limited because of its code related capabilities, the other day someone made a plugin to run your code snippet within obsidian, and get an output!! If obsidian starts to provide better support for codeblocks, the possibilities are endless!!