onlyafly / number-headings-obsidian Goto Github PK
View Code? Open in Web Editor NEWAutomatically number headings in a document in Obsidian
License: MIT License
Automatically number headings in a document in Obsidian
License: MIT License
I installed version 1.3.0, refreshed Obsidian, activate the plug-in, then get this on my screen:
But the headings are not numbered.
I reinstalled version 1.0.1, that worked. But when I reinstalled 1.3.0 that still does not work, then reinstalled 1.0.1 it did not work anymore either.
BTW, I am on MacOS.
Is there a way to have the numbers adjusted automatically when a heading is added or removed?
The numbering result of the following note is not correct.
---
number headings: first-level 1, max 6, _.1.1
---
# h1
## 1 h1-2
### 1.1 h1-2-1
## 2 h1-3
### 2.1 h1-3-1
### 2.2 h1-3-2
# h2
## 3 h2-1
### 3.1 h2-1-1
### 3.2 h2-1-2
## 4 h2-2
The expected result would be:
---
number headings: first-level 1, max 6, _.1.1
---
# h1
## 1 h1-2
### 1.1 h1-2-1
## 2 h1-3
### 2.1 h1-3-1
### 2.2 h1-3-2
# h2
## 1 h2-1
### 1.1 h2-1-1
### 1.2 h2-1-2
## 2 h2-2
The auto numbering option (that is enabled through the settings) triggers auto numbering of any file which is opened in the editor. Is there a possibility to turn this feature off for specific files? Adding a "manual" or "off" option to the front matter would solve the problem.
For me it interferes with the Kanban Plugin when I want to archive cards.
Hey, awesome plugin you've got here :D
One issue I've come accross is that in some situations, I want the numbering for a level 1 heading to start from a value different from 1
.
For example, using the Longform Writing plugin, the sections of my thesis are split into different notes. So for chapter 2, for example, I want the numbering to start at 2
, 2.1
, etc. instead of 1
as is the default.
I have a problem with the plugin: I use Zettelkasten prefixes in first level headings, e.g. 202109161700 Heading title
(same as file name). When acitvating the plugin it removes the prefix completely if I choose not to number the first level (plugin settings). IMHO this is a bug. At the moment I unfortunately can’t use the plugin this way. Is there a possibility to fix that bug?
Nice feature!
If one has added a ToC that way (i.e. # Header^toc
) and one wants to get rid of the ToC later on, removing ^toc
has no effect, one has to remove the ToC manually.
Is there a way to do it automatically after removing ^toc
?
I really like the table of contents function. Is there a way to be able to link to other notes with the same name as the TOC entry?
So, for example I give a heading the title "1 Introduction". In order to link this heading to another note with that same name I put the [[ ]] around it. This works for the heading itself, but not the actual TOC, where it turns into this
[[#1 [[1 Introduction|Introduction]]|1 [[1 Introduction|Introduction]]]]
or in Preview mode it becomes this:
[[#1 Introduction|1 Introduction]]
Any way to have JUST the name of the note show up?
Thanks :)
The auto toc adds a tab before the toc content which will result in a code block in the preview mode.
I noticed that there is a noticeable delay (about 1 second more or less) between typing a heading and seeing it numbered by the plugin. This affects my writing flow and makes me feel laggy. I wonder if there is a way to speed up the auto numbering process or reduce the delay time. Thank you for your great work on this plugin!
I am on a Mac and have noticed that when the plug-in is enabled I am not longer able to do Cmd+Z (undo), a keyboard shortcut that I use frequently.
What happens is that when it is enabled I can make 3 keystrokes, e.g. aaa
, and Cmd+Z will undo all 3 in 1 go.
If I do aaaa
Cmd+Z does not undo anything, and instead jumps to a different location on the page. When I scroll back to where I came from, sure enough aaaa
is still there.
Any idea why the table of contents doubles?
These are my settings:
Here is the complete file content:
Links
![[2023-01-28-superchared-links-settings.png|900]]
When I have a note with headers, then your plug-in adds numbers to those headers. Numbered headers are useful for navigation in long notes.
However, when e.g. a new header is inserted, the numbers in that note change, and all the links to those headers break.
Typora provides virtual heading numbering with some CSS code, and the numbering is NOT part of the note. Now, I asked about this a long time ago and someone (cannot remember who) explained that Typora and Obsidian have a different way of handling ………… uhm, something, so what Typora does is not possible in Obsidian. But with JavaScript a lot more is possible.
Is there a way for your plug-in to provide numbers as virtual numbers, i.e. not make them part of the note?
Thank you for providing such a useful plugin.
I occasionally found a need to skip some header from being numbered.
For instance, I want to prevent the ## Contents ^toc
from counted.
More generally, a command to prevent sections with custom suffix, e.g., # Uncounted ^exclude
, to skip them would be useful.
FYI, LaTeX provides starred commands like \section*
for such usage.
I accidentally had the wrong settings in the front matter, so had some headings with odd numbers like A.1.
When I tried to remove them all with the command in the pallet nothing is removed.
I would have thought that reissuing the numbering command, even if the old numbers are not removed, would overwrite the old numbers - that is how it was in 1.0.1. But that is not the case here.
Love your plugin but there is a snag....
When the option 'Skip top heading level' is active. The behaviour is a bit unexpected. I would expect the follow heading (##) to start at 1 every time there is a new heading 1 (#). E.g. now numbering results in this:
# Heading 1
## 1 Heading 2
### 1.1 Heading 3
### 1.2 Heading 3
## 2 Heading 2
### 2.1 Heading 3
### 2.2 Heading 3
## 3 Heading 2
### 3.1 Heading 3
### 3.2 Heading 3
# Heading 1
## 4 Heading 2
### 4.1 Heading 3
### 4.2 Heading 3
## 5 Heading 2
### 5.1 Heading 3
### 5.2 Heading 3
while I would expect this:
# Heading 1
## 1 Heading 2
### 1.1 Heading 3
### 1.2 Heading 3
## 2 Heading 2
### 2.1 Heading 3
### 2.2 Heading 3
## 3 Heading 2
### 3.1 Heading 3
### 3.2 Heading 3
# Heading 1
## 1 Heading 2
### 1.1 Heading 3
### 1.2 Heading 3
## 2 Heading 2
### 2.1 Heading 3
### 2.2 Heading 3
Am I missing something? Maybe add an option 'Reset counter after every top heading"?
number headings: first-level 1, max 4, _.1.1
, while I need number headings: first-level 1, max 4, _.1.1.
. Once you know it, it's easy to change it in the frontmatter for one local file. But this setting is impossible to set up globally, to use as default when commanding to create the numbering for the active file, or to be used automatically if the automatic numbering
toggle is on.Make a new frontmatter-like global setting field that would overwrite the rest of the graphical settings, that can be copied from and pasted into.
Hi!!
First of all just to want to say a big THANK YOU for developing this plugin! It really helped me a lot and I love it so much.
One small minor bug: in the setting => Separator Style
, I found when you add a space before your separator like -
instead of doing -
, the auto numbering will keep adding separators.
To reproduce the bug shown above:
Separator style
to -
(i.e. whitespace + dash)It might be worth to fix (not a priority). I personally find that using -
(whitespace + dash) as separator makes things easier to read than using -
only (e.g. 1.2 - My heading
vs. 1.2- My heading
)
When we enable automatic numbering, it will break the linkage and shows "unable to find section". Could this plugin update the linkage automatically as well?
e.g. We have two pages:
Page A.md
Page B.md
[[Page A^2. Heading2]
After inserting another heading before "2. Heading2". The link in Page B will show the error message.
Page A.md
I have this in my front matter
number headings: first-level 3, max 6, A.1., contents ^toc
But the table of contents generated isn’t ignoring the first two levels of headings.
Table of contents starts at H3 / whatever the first level is.
Can this function be changed to work only after input is complete?
This feature seems incompatible with the word selection function in Chinese and Japanese input method.
it looks like a bug
/** Numbered Headings **/
.cm-content { counter-reset: h1counter h2counter h3counter h4counter h5counter h6counter; }
.HyperMD-header-1 { counter-reset: h2counter; }
.HyperMD-header-2 { counter-reset: h3counter; }
.HyperMD-header-3 { counter-reset: h4counter; }
.HyperMD-header-4 { counter-reset: h5counter; }
.HyperMD-header-5 { counter-reset: h6counter; }
.HyperMD-header-1::before {
counter-increment: h1counter;
content: counter(h1counter) ".\0000a0\0000a0";
}
.HyperMD-header-2:before {
counter-increment: h2counter;
content: counter(h1counter) "." counter(h2counter) ".\0000a0\0000a0";
}
.HyperMD-header-3:before {
counter-increment: h3counter;
content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0";
}
.HyperMD-header-4:before {
counter-increment: h4counter;
content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0";
}
.HyperMD-header-5:before {
counter-increment: h5counter;
content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) ".\0000a0\0000a0";
}
.HyperMD-header-6:before {
counter-increment: h6counter;
content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) "." counter(h6counter) ".\0000a0\0000a0";
}
Is it possible to manually set the number of the first level heading, and automatically number other headings accordingly?
For example, I have a document, which is the Third Chapter of a book. Therefore, I'd like to set the first-level heading (which is the Chapter title) to 3, and then the later level 2 heading could be automatically numbered as 3.1, 3.2, ..., and so on.
Thanks for this useful plugin. It would be cool to have the first level in roman numbering (I, II, III, IV, ...).
I don't know if we mean the same thing when we talk about automatic renumbering.
If I have header A numbered as 1 and I have header B numbered as 2, and I insert a new header between A and B, then it should automatically number the new header as 2 and header B as 3.
That is how I understand it. Right now I still need to press my hotkey to get the numbers reset.
Hello @onlyafly !!!!!
I'd like to ask your help with one specific workflow that I'm trying to implement with your amazing plug-in:
Here is my situation:
1- I have a note that only have level 3 headings ###
Here is my "raw" note:
Here is the resut that I want to achieve:
As you can see, i just wanna apply 1
2
and 3
with a level 3 headers. :)
Attempt 1:
Attempt 2:
Attempt 3:
Could you help me to get the right setting to achieve this? :)
Thanks for your help!
Have a great day!!!
I am unsure whether this is intended behaviour or a bug. I would like the top level not to be numbered but to have the lower level headings be numbered as if the top level heading was numbered.
# heading 1
## 1.1 Contents ^toc
- [[#heading 1|heading 1]]
- [[#1.1 Contents ^toc|1.1 Contents]]
- [[#heading 2|heading 2]]
- [[#2.1 sub 1|2.1 sub 1]]
- [[#2.1.1 sub 2|2.1.1 sub 2]]
# heading 2
## 2.1. sub 1
### 2.1.1. sub 2
# heading 1
## 1. Contents ^toc
- [[#heading 1|heading 1]]
- [[#1. Contents ^toc|1. Contents]]
- [[#heading 2|heading 2]]
- [[#1. sub 1|1. sub 1]]
- [[#1.1. sub 2|1.1. sub 2]]
# heading 2
## 1. sub 1
### 1.1. sub 2
And
I love this plugin. It helps me adding chapter numbers to my books chapter. But when I need to get it in the publisher's WORD format, I can just remove them. Top notch!
Is there a way to provide some micro-support for you?
Hello @onlyafly !!!!!
I have a note only with tweets that I regularly export from twitter to obsidian
To make my note easy to search I have one header for each tweet:
After exportation I use your plug-in to create a numbered headings to my note
Since I import new tweets for this note everyday, I have to apply my front-matter settings Number all Headings in the document
once a day to add new numbers to my list
Every time I got this notification message when I use : Number all Headings in the document
I wanna request a new command to be used when you just need to update your note with the parameters previously defined in the front matter:
Number all Headings in the document using front matter settings
In my case, I already now my settings. I just want to update my note because of my new headers.
This way, I don't need to interact with the notification message box, I just need to apply the settings in the front-matter and continue to work :)
Automatic Numbering
?Since I have a lot of notes from books with huge TOC that uses Humber Headings
, I don't want to automatic numbering everything in my vault. I don't want to have a service running in all my notes trying to look for an update. I rather two this manually
Thanks for your help.
Have a great day
My use case are legal documents.
For example:
# § 1 Heading
## § 1.1 ...
So basically I want to prepend a § to all headings.
Just like the Chinese words e.g. 一 , 二, 三,...
it will be quite helpful.
i know for css some code like content: "(" counter(counter_h_3, cjk-ideographic) ")";
can be used.
what shall i do?
I have a note in which the heading numbers with version pre-1.4 (I think). I could not link to them from another note. I had to remove the numbers and let the latest version reinsert them to get the linking to work. I may well have more notes than that, but now I know what to.
When you want to remove the heading numbers in a note, the note has to be in Edit mode. That also applies to adding heading numbers. Neither action will work in Preview mode. Perhaps it is obvious to others, to me it was not.
Hi Kevin, could you tell us what has changed with this version, please?
I have a lot of wiki links to headings. After I updated the heading numbers with this plugin, the links break.
Is it possible to update all the references when updating the heading numbers. Just like the official obsidian context menu item "rename this heading".
I assume that this setting at “false” means that h1 headers WILL be counted. If I am right, then it does not work.
Note: the 1st time I used 1.4.0 and got the dialogue box with the question if I wanted to save those settings to the note's front matter I clicked on “yes”. In that dialogue the setting was set to “true”.
So, perhaps it has something to do with a cache? If so, please advise.
If cache clearance is an issue, it should be done automatically by the plug-in, right?
Edit: I went to ~/Library/Application Support/obsidian/Cache, deleted everything in there, refreshed, deleted numbers from headers, and tried again: no change.
BTW, after removing the numbers, then refreshing Obsidian, puts the numbers back. Cache issue.
If a heading title, which one has linked to, is changed, the link is broken.
In principle, this can be avoided by manually using the right-click submenu item Rename this heading.
However, if a heading is added to or deleted from a note, the plug-in automatically changes all the heading numbers in the note, bypassing the right-click method, of course.
So, pretty soon one ends up with many broken links throughout the vault.
I have an internal link [[#my_heading]]. If I number all headings in a document, "my_heading" will turn to "1 my_heading". Then the internal link will not work. Is there any way to show the head number just in preview mode not in the editor mode?
Is it possible to use multiple digits in each heading level as a format, e.g. 01, 002, 103, etc.?
I have a note with perhaps 50 headers (I have not counted them), but when I activate the plug-in to add numbers, it stops at 39. Could this be fixed?
Is it possible that, if I am in say header 4.1.3, that header is highlighted in the Outline pane?
My settings:
What is being transferred to frontmatter:
The following settings are not being transferred:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.