2025-03-08 12:39:07 +00:00
# Heading Decorator
2025-06-15 10:27:20 +00:00
**English** | [简体中文 ](./README-zh_CN.md ) | [繁體中文 ](./README-zh_TW.md )
2025-03-08 12:39:07 +00:00
## Introduction
This is a plugin for [Obsidian ](https://obsidian.md ).
2025-03-21 05:01:55 +00:00
Implement displaying specific content around headings based on their levels.
2025-03-10 15:51:26 +00:00
2025-05-27 14:49:38 +00:00
This plugin supports optional decoration for reading view, editing view (*Live Preview* and *Source mode* ), *[Outline](https://help.obsidian.md/plugins/outline)* , *[Quiet Outline](https://github.com/guopenghui/obsidian-quiet-outline)* and *[Headings in Explorer](https://github.com/patrickchiang/obsidian-headings-in-explorer)* plugin. This plugin does not modify any note content, only decorates the heading section based on the existing note content.
2025-03-10 15:51:26 +00:00
## Preview
2025-03-13 03:28:10 +00:00
In *Live Preview* :
2025-03-10 15:51:26 +00:00

2025-03-13 03:28:10 +00:00
The interaction between the decorator and the collapse button:

2025-03-10 15:51:26 +00:00
## Settings
2025-04-02 12:44:56 +00:00
### Metadata keyword
The key name that reads the enabled status from the [properties ](https://help.obsidian.md/Editing+and+formatting/Properties ). The default value is: `heading` . Usage reference: [Enabled status of notes ](#enabled-status-of-notes ).
2025-03-10 15:51:26 +00:00
### Enabled
2025-03-11 05:32:10 +00:00
The plugin supports configure heading decorator for each editor mode. You can control the effect range:
2025-03-10 15:51:26 +00:00
2025-04-02 12:44:56 +00:00
- **Enabled in reading view**: Allow to decorate the heading under the *Reading* view.
- **Enabled in live preview**: Allow to decorate the heading under the *Live Preview* .
- **Enabled in source mode**: Allow to decorate the heading under the *Source mode* .
- **Enabled in outline plugin**: Allow to decorate the heading under the *Outline* plugin.
2025-05-27 14:49:38 +00:00
- **Enabled in "Quiet Outline" plugin**: Allow to decorate the heading under the *[Quiet Outline](https://github.com/guopenghui/obsidian-quiet-outline)* plugin.
2025-04-22 12:15:57 +00:00
- **Enabled in "Headings in Explorer" plugin**: Allow to decorate the heading under the *[Headings in Explorer](https://github.com/patrickchiang/obsidian-headings-in-explorer)* plugin.
2025-04-02 12:44:56 +00:00
2025-08-05 14:30:21 +00:00
In addition, you can enable the default status of each note within the *Config* subpage. It mainly works together with [Enabled status of notes ](#enabled-status-of-notes ).
2025-03-10 15:51:26 +00:00
### Effect
Control the display effect of the decorator.
2026-01-09 11:46:57 +00:00
- **Mode**: Toggle this setting to decorate headings as ordered, independent, splice or unordered.
2026-01-09 05:07:00 +00:00
- **Ordered**: Connect the current heading level with the top-level heading level using a separator in the decorator style to build the result, similar to the effect shown in [Preview ](#preview ).
- **Independent**: By default, build the result of the current heading level according to the decorator style of each level.
2026-01-09 11:46:57 +00:00
- **Splice**: The result is builded by connecting the current heading level with the top-level heading level using a separator, following the respective level decorator style.
2026-01-09 05:07:00 +00:00
- **Unordered**: Build the current heading level directly as a fixed string.
2025-03-10 15:51:26 +00:00
- **Opacity**: Set the opacity of the heading decorator. The value is the form of percentage.
2025-03-21 04:44:14 +00:00
- **Position**: Set the position of the heading decorator. You can configure the content to appear before or after the heading.
2025-08-11 13:35:03 +00:00
- **Maximum level recognized**: Specify the maximum level of headings to be recognized, ignoring headings above this level.
2025-03-10 15:51:26 +00:00
2026-01-09 05:07:00 +00:00
Examples of differences between different decorator modes:
2026-01-09 11:46:57 +00:00
| Ordered (Decimal numbers) | Independent | Splice | Unordered (using `H1 H2 H3 H4 H5 H6` ) |
| :-----------------------: | :---------: | :----: | :-----------------------------------: |
|  |  |  |  |
2026-01-09 05:07:00 +00:00
Examples of differences between different decorator positions:
2025-04-09 14:16:03 +00:00
2025-04-18 15:58:21 +00:00
| Before the heading | Before the heading (inside) | After the heading |
2025-04-19 12:29:56 +00:00
| :----------------: | :-------------------------: | :---------------: |
2025-04-18 15:58:21 +00:00
|  |  |  |
2025-04-09 14:16:03 +00:00
2025-08-11 13:35:03 +00:00
Here are examples of different recognized maximum levels:
| The maximum level recognized is `6` | The maximum level recognized is `4` |
| :---------------------------------: | :---------------------------------: |
|  |  |
2026-01-09 05:07:00 +00:00
#### Special settings for independent
##### Level using ordered list
2025-03-10 15:51:26 +00:00
2026-01-09 05:07:00 +00:00
When the heading level exceeds the specified level, build it as an ordered list. For example:
| Default (*setting is `6` *) | Setting is `4` |
| :------------------------: | :------------: |
|  |  |
### Decorator Style
2025-03-10 15:51:26 +00:00
You can control the counter style type and delimiter. There are two special types of counter styles:
2026-01-09 05:07:00 +00:00
- **Custom list styles**: Set custom list styles for decorator. Using spaces to separate entries.
- **Specified string**: Set a specified string for decorator.
2025-03-10 15:51:26 +00:00
2025-03-13 03:14:10 +00:00
For example:
2025-03-10 15:51:26 +00:00
2025-03-13 03:14:10 +00:00
| Decimal numbers | Custom List Styles (using `Ⓐ Ⓑ Ⓒ` ) | Specified String (using `#` with empty delimiter) |
| :-------------: | :----------------------------------: | :-----------------------------------------------: |
|  |  |  |
2025-03-10 15:51:26 +00:00
2026-01-09 05:07:00 +00:00
### Logic
2026-01-09 11:46:57 +00:00
When you set the decorator mode to ordered, independent or splice, you can control the rendering logic of headings to adjust rendering results, or ignore heading levels you don't want to handle.
2026-01-09 05:07:00 +00:00
2025-04-02 14:14:38 +00:00
#### Allow zero level
For the *Allow zero level* setting, if the next heading is more than one level higher, the omitted level is zero instead of one. For example:
| Default | Allow zero level |
| :-----: | :--------------: |
|  |  |
2025-03-27 13:43:02 +00:00
#### Based on the existing highest level
2026-01-09 05:07:00 +00:00
For the *Based on the existing highest level* setting, use the highest level of headings in the note as the base for building decorators. For example:
2025-03-27 13:43:02 +00:00
| Default | Based on the existing highest level |
| :-----: | :----------------------------------: |
|  |  |
2025-06-20 13:32:24 +00:00
#### Always ignore the top-level headings
2025-03-27 13:43:02 +00:00
2026-01-09 05:07:00 +00:00
Exclude the top-level heading when building decorators. controlled by the *Maximum number of ignored levels* option. For example:
2025-03-10 15:51:26 +00:00
2025-06-20 13:59:19 +00:00
| Default | Enabled (Maximum number of ignored levels set to `2` ) |
2026-01-05 04:58:49 +00:00
| :-----: | :---------------------------------------------------: |
2025-06-20 13:32:24 +00:00
|  |  |
2025-03-10 15:51:26 +00:00
2025-06-20 13:32:24 +00:00
#### Ignore the single heading at the top-level
2025-04-02 14:05:24 +00:00
2026-01-09 05:07:00 +00:00
For the *Ignore the single heading at the top-level* setting, if the top-level has only a single heading, exclude it when building decorators. controlled by the *Maximum number of ignored levels* option. This setting contains *Based on the existing highest level* , but it deals with more "aggressive". For example:
2025-04-02 14:05:24 +00:00
2025-06-20 13:59:19 +00:00
| Default | Enabled (Maximum ignored levels: `1` ) | Enabled (Maximum ignored levels: `6` ) |
| :-----: | :-----------------------------------: | :------------------------------------: |
2025-06-20 13:32:24 +00:00
|  |  |  |
2025-04-02 14:05:24 +00:00
2026-02-19 12:27:19 +00:00
### Editor display
Render heading decorations in a gutter column instead of inline with the text. Applies to both live preview and source mode. For details, see [#24 ](https://github.com/dragonish/obsidian-heading-decorator/issues/24 ). Preview effect:
2026-03-10 13:16:31 +00:00

2026-02-19 12:27:19 +00:00
2025-08-24 08:11:20 +00:00
### Other settings for reading view
#### Render policy for reading view
When editing note content, the render policy used by the heading decorator in the reading view.
- **Partial**: Rerender active heading decorator after the update.
- **Full**: Rerender all heading decorators after the update.
2025-04-27 13:48:53 +00:00
### Other settings for source mode
#### Hide number signs on inactive lines
Hide number signs (`#`) on inactive lines similar to live preview.
2025-04-22 12:35:16 +00:00
### Blocklist
2025-04-03 14:36:04 +00:00
2025-04-22 12:35:16 +00:00
#### Folder blocklist
2025-04-03 14:36:04 +00:00
2025-04-22 12:35:16 +00:00
Disables the heading decorator in notes within the specified folder. For notes that are on the blocklist, you can still use [Enabled status of notes ](#enabled-status-of-notes ).
2025-04-03 14:36:04 +00:00
#### Note name regex blocklist
2025-04-22 12:35:16 +00:00
Disables the heading decorator in notes whose note name matches the specified regular expression. The format uses [JavaScript regular expression ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions ), for example: `/^daily.*/i` . For notes that are on the blocklist, you can still use [Enabled status of notes ](#enabled-status-of-notes ).
2025-04-03 14:36:04 +00:00
2025-04-02 12:44:56 +00:00
## Enabled status of notes
This plugin allows for configure the enabled status based on specific fields in the note [properties ](https://help.obsidian.md/Editing+and+formatting/Properties ). You can individually control the enabled status of a note.
2025-04-22 12:15:57 +00:00
You can specify the status after the configured property [keyword ](#metadata-keyword ):
2025-04-02 12:44:56 +00:00
```yaml
---
2025-04-22 12:15:57 +00:00
heading: false
2025-04-02 12:44:56 +00:00
---
```
2025-04-22 12:15:57 +00:00
The values `true` , `yes` , `on` or `1` indicates enabled; the values `false` , `no` , `off` or `0` indicates disabled. Other values are equivalent to undeclared.
2025-04-02 12:44:56 +00:00
2025-04-22 12:15:57 +00:00
You can also use the following subfields to specify the status of a specific mode:
2025-04-02 12:44:56 +00:00
2025-04-22 12:15:57 +00:00
- **reading**: the status of the decorator in the reading view.
- **preview**: the status of the decorator in the live preview.
- **source**: the status of the decorator in the source mode.
- **outline**: the status of the decorator in the outline plugin.
2025-05-27 14:49:38 +00:00
- **quiet-outline**: the status of the decorator in the "Quiet Outline" plugin.
2025-04-22 12:15:57 +00:00
- **file-explorer**: the status of the decorator in the "Headings in Explorer" plugin.
- **all**: the status of the decorator in all modes.
For example, you can set all other modes to be disabled and enable the decorator in the reading view alone:
2025-04-02 12:44:56 +00:00
```yaml
---
2025-04-22 12:15:57 +00:00
heading:
all: false
reading: true
2025-04-02 12:44:56 +00:00
---
```
2025-04-22 12:15:57 +00:00
If you prefer to use Obsidian's default property `cssclasses` , you can also fill in `cssclasses` with some equivalent class names:
2025-04-02 12:44:56 +00:00
- reading: `enable-reading-heading` /`disable-reading-heading`
- preview: `enable-preview-heading` /`disable-preview-heading`
- source: `enable-source-heading` /`disable-source-heading`
- outline: `enable-outline-heading` /`disable-outline-heading`
2025-05-27 14:49:38 +00:00
- quiet-outline: `enable-quiet-outline-heading` /`disable-quiet-outline-heading`
2025-04-22 12:15:57 +00:00
- file-explorer: `enable-file-explorer-heading` /`disable-file-explorer-heading`
2025-04-02 12:44:56 +00:00
- all: `enable-heading` /`disable-heading`
2025-04-22 13:28:49 +00:00
For example, a value equivalent to the above example:
2025-04-02 12:44:56 +00:00
```yaml
---
2025-06-12 15:17:08 +00:00
cssclasses:
- disable-heading
- enable-reading-heading
2025-04-02 12:44:56 +00:00
---
```
2025-04-19 13:03:48 +00:00
## Custom decorator styles
2025-04-18 15:58:21 +00:00
You can customize the heading decorator style by CSS classes. For decorators in the editor, `.custom-heading-decorator` can be used. Or for specific editor modes:
2025-04-22 12:15:57 +00:00
- Reading view: `.reading-custom-heading-decorator` .
- Live Preview: `.preview-custom-heading-decorator` .
- Source mode: `.source-custom-heading-decorator` .
For decorators in other plugins, it is necessary to combine pseudo-element keywords:
2025-04-18 15:58:21 +00:00
2025-04-22 12:15:57 +00:00
- Outline: `.outline-custom-heading-decorator::before` or `.outline-custom-heading-decorator::after` .
2025-05-27 14:49:38 +00:00
- Quiet Outline: `.quiet-outline-custom-heading-decorator::before` or `.quiet-outline-custom-heading-decorator::after` .
2025-04-22 12:15:57 +00:00
- Headings in Explorer: `.file-explorer-custom-heading-decorator::before` or `.file-explorer-custom-heading-decorator::after` .
2025-04-18 15:58:21 +00:00
2026-01-06 12:59:45 +00:00
Each decorator element has an attribute `[data-decorator-level="n"]` associated with the current heading level (*`n` is the heading level*).
2025-04-18 15:58:21 +00:00
For example, make all the decorators display in green:
```css
.custom-heading-decorator,
.outline-custom-heading-decorator::before,
2025-04-22 12:15:57 +00:00
.outline-custom-heading-decorator::after,
2025-05-27 14:49:38 +00:00
.quiet-outline-custom-heading-decorator::before,
.quiet-outline-custom-heading-decorator::after,
2025-04-22 12:15:57 +00:00
.file-explorer-custom-heading-decorator::before,
.file-explorer-custom-heading-decorator::after {
2025-04-18 15:58:21 +00:00
color: green;
}
```
2025-04-22 14:18:19 +00:00
In addition, the plugin provides a set of CSS variables for customizing the spacing of decorators:
- `--reading-heading-decorator-margin` : the margin of the heading decorator in the reading view.
- `--reading-heading-decorator-translate` : the translating vector value of the heading decorator in the reading view.
- `--preview-heading-decorator-margin` : the margin of the heading decorator in the live preview.
- `--preview-heading-decorator-translate` : the translating vector value of the heading decorator in the live preview.
- `--source-heading-decorator-margin` : the margin of the heading decorator in the source mode.
- `--source-heading-decorator-translate` : the translating vector value of the heading decorator in the source mode.
- `--outline-heading-decorator-margin` : the margin of the heading decorator in the outline plugin.
2025-05-27 14:49:38 +00:00
- `--quiet-outline-heading-decorator-margin` : the margin of the heading decorator in the "Quiet Outline" plugin.
2025-04-22 14:18:19 +00:00
- `--file-explorer-heading-decorator-margin` : the margin of the heading decorator in the "Headings in Explorer" plugin.
For example, to adjust the spacing in the reading view to `8px` :
```css
body {
--reading-heading-decorator-margin: 8px;
}
```
2025-03-10 15:51:26 +00:00
## Credits
- [@jsamr/counter-style ](https://github.com/jsamr/react-native-li/tree/master/packages/counter-style#readme )
## License
[MIT ](/LICENSE ) license