# Code Block Remains Visible in Folded Headings

**URL:** <https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352>\
**Category:** Help\
**Tags:** tracked\
**Created:** [June 26, 2024, 12:54pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352 "2024-06-26T12:54:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karpets](https://forum.obsidian.md/user_avatar/forum.obsidian.md/karpets/32/67720_2.png) [@karpets](https://forum.obsidian.md/u/karpets)\
**Post date:** [June 26, 2024, 12:54pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352/1 "2024-06-26T12:54:15Z")

</div>

### Bug Report: Code Block Remains Visible in Folded Headings After Restart

#### Summary

In Obsidian, I have a long tutorial (1278 lines) with headings (3 levels deep). When I restart my Mac and open Obsidian, the code block shows up right below the folded heading. However, the code block was initially placed deep inside the heading hierarchy. The expected behavior is to have the code block be hidden when the heading is folded.

#### Steps to Reproduce

1. Create a long tutorial in Obsidian with headings up to 3 levels deep.
2. Insert a code block surrounded by triple backticks ` ` deep inside the heading hierarchy.
3. Fold the headings so that the code block should be hidden.
4. Restart the Mac and open Obsidian.

#### Expected Behavior

The code block should remain hidden when the heading is folded.

#### Observed Behavior

The code block shows up right below the folded heading upon reopening Obsidian after a Mac restart.

#### Additional Information

- This issue appears to be specific to code blocks. Regular text, screenshots, or code placed within single backticks ` ` do not trigger the issue.
- I have multiple long tutorials with headings, screenshots, and code blocks surrounded by triple backticks ` `.

#### Workaround

As a temporary workaround, I have to unfold all headings and fold them up again to hide the code blocks.

#### Environment

- **Obsidian Version:** 1.6.5 (Installer 1.4.13)
- **macOS Version:** macOS Sonoma 14.5
- **Device:** MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)

#### Screenshots

 ![01](https://forum.obsidian.md/uploads/default/original/3X/5/1/5181741151699c4ebec4cbf010edd33fa34cd32e.png)

 ![02](https://forum.obsidian.md/uploads/default/original/3X/7/6/76e1c2fbf1041f09f9bfe0359b54d2856552c788.png)

 ![03](https://forum.obsidian.md/uploads/default/original/3X/4/a/4aaf0fe5e99db52c32c60398e8ce8ae1b168d66b.png)

 ![04](https://forum.obsidian.md/uploads/default/original/3X/9/d/9da49693e1f0b1f07e8e8a3919ee981d66a5257a.png)

 ![05](https://forum.obsidian.md/uploads/default/original/3X/0/2/02a30436a9b0fef41b6187ec16ec02b42a944d54.png)

Thank you for looking into this issue.

---

<div class="post-metadata">

**Author:** ![WhiteNoise](https://forum.obsidian.md/user_avatar/forum.obsidian.md/whitenoise/32/11_2.png) [@WhiteNoise](https://forum.obsidian.md/u/WhiteNoise)\
**Post date:** [June 26, 2024, 1:03pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352/2 "2024-06-26T13:03:07Z")

</div>

Download and reinstall Obsidian.  
Please, Post a screen recording of this happening in the sandbox vault or a new empty vault.

---

<div class="post-metadata">

**Author:** ![karpets](https://forum.obsidian.md/user_avatar/forum.obsidian.md/karpets/32/67720_2.png) [@karpets](https://forum.obsidian.md/u/karpets)\
**Post date:** [June 26, 2024, 1:58pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352/3 "2024-06-26T13:58:04Z")

</div>

@WhiteNoise Thank you for your swift response!

I performed a clean installation of Obsidian on a Windows 10 machine and synchronized the affected Obsidian vault.

It seems the issue is unrelated to the length of the note/tutorial.

I observed that all affected code blocks in my note begin with a #. It looks like Obsidian is interpreting # inside triple backticks ``` as an H1 heading, thereby elevating the code block to the highest header hierarchy.

Here is an example code block:

```auto
# Flush Redis data before starting the Redis service
redis-cli FLUSHALL

```

Please note that the opening triple backticks are missing in the screenshot.

![2024-06-26_165242](https://forum.obsidian.md/uploads/default/original/3X/f/b/fb89482bded97628f333cfa7c90242e35c7c242b.png)

---

<div class="post-metadata">

**Author:** ![WhiteNoise](https://forum.obsidian.md/user_avatar/forum.obsidian.md/whitenoise/32/11_2.png) [@WhiteNoise](https://forum.obsidian.md/u/WhiteNoise)\
**Post date:** [June 26, 2024, 2:56pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352/4 "2024-06-26T14:56:55Z")

</div>

Duplicate of

> [@Folding applied on code block lines starting with "#"](https://forum.obsidian.md/t/folding-applied-on-code-block-lines-starting-with/39466):
>
> Steps to reproduce In Live Preview : Create headings (H1, H2, etc…) Create some code blocks containing some lines starting with a “#” Fold all headings then unfold manually Take note that you will need to fold/unfold headings multiple times in order to reproduce the bug. These steps have been reproduced in the Sandbox vault. Expected result Folding should not be applied on code block lines. Actual result You will see that folding is applied on the code block lines starting with a “#” Env…

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [September 24, 2024, 2:57pm UTC](https://forum.obsidian.md/t/code-block-remains-visible-in-folded-headings/84352/5 "2024-09-24T14:57:32Z")

</div>

Closed on September 24, 2024, 2:57pm UTC

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