Header counter

I have dataview scripts that only provide data in Reading view. So that makes it a breaking issue for me.

In the way the plugin is currently set up, it works in both editing and reading view, with the live preview both enabled and disabled. However, it seems to only work on my end, where on other clients there seem to be vastly different issues.

Iā€™m currently working on a way to minimize inconsistencies, which will also fix the multi-tab issue. Iā€™ll make sure to test it on more devices and OSs before announcing the new version here.

This is my first time working on an Obsidian plugin, so please have patience with the back and forth!

2 Likes

Maybe a theme conflict? I use the Minimal Theme

Ok maybe not. I switched to the default and had to turn Readable line length back on. still had zeros on everything.

1 Like

@Platon_Ivanov the plug-in does show up in my Settings now!
Nevertheless, the scroll issue whereby the numbers change is still present in the plug-in.

1 Like

Iā€™ve dug a little deeper and hereā€™s what the CodeMirror reference manual says about the viewport:

To be able to display large documents without consuming too much memory or overloading the browser, CodeMirror only draws the code that is visible (plus a margin around it) to the DOM. This property tells you the extent of the current drawn viewport, in document positions.

So the CSS only solution would produce problems @Klaas came across, since elements which donā€™t exist on the screen couldnā€™t be picked up by CSS counters. Furthermore, the first plugin solution wouldnā€™t work either, since at its core it still used CSS selectors to pick up DOM elements.

So I tried a new solution which is CodeMirror-based. This way we should avoid the issues with CSS selectors.

Please take a look at the new version and let me know if it works for you:

1 Like

Thanks for the effort. Unfortunately, the scrolling issue persists.
Do you not see it at your end?

2 Likes

@Platon_Ivanov hi Platon, is there any news on this plug-in?

Hello! :wave:

It has been a while since my last update. I had a very busy period, but now I finally found time to work on the plugin again. :tada:

It took me quite a bit of time to think of how to do it properly. On the previous CSS based solutions (oh, what simple times) we had the scrolling issue, which was caused by rendering optimizations built into Code Mirror. I tried to incorporate counting even with some text which isnā€™t being rendered using many different ways. The final solution turned out to be much, much simpler in the end, which Iā€™m happy about.

Now live preview counting works no matter the document length.

There are also some settings (the number separators and the heading level you want to start counting from (if you want to skip first-level headings for example)). Itā€™ll be good to add more settings in the future, especially in regards to styling.

The markdown preview, however, doesnā€™t work quite as well as Iā€™d imagine itā€¦ :confused:

  • it sometimes doesnā€™t count correctly, so you have to switch to editing mode and back
  • if you have the same file opened in two tabs, you have to switch to editing mode and back to update the count

Iā€™ll be looking for solutions to these issues, hopefully there is a way to track file changes and refresh all the related views. I wasnā€™t able to find it today.

Please let me know whether the current version works for you and if you find new bugs, please describe them here or start an issue on GitHub!

2 Likes

@Platon_Ivanov Hi there, long time no speak, I thought you had abandoned the plug-in.

Before I try it (probably tomorrow) I have 1 question:

when you say ā€œmarkdown previewā€, do you mean Live Preview, Reading, or Source Editor?

1 Like

I mean the Reading mode.

Yes, that works now

Yes that works now!!

Yes, thatā€™s good; I stick with your default settings :grinning:

I personally donā€™t mind because I donā€™t really use Reading mode.

Good improvements.

I have opened an issue, #5, on Github. I think I may have inadvertently messed up the number - oh boy, me and numbers :rofl:

1 Like

Just curious, what font is this that youā€™re using here? Are you using that only for the interface or for the font in the editor/preview as well.

Hi,

Iā€™ve been using @Platon_Ivanov 's EXCELLENT plugin. Found some issues with the build, and after fixing them, went on to add support for:

(1) global apply visual numbering by default or based on note frontmatter
(2) Note frontmatter property: ā€œvisually-number-headings: trueā€ or ā€œvisually-number-headings: falseā€; this will override the global default, so numbering can be switched on/off on a note-by-note basis.
(3) Some style adjustments so the collapse indicators are not obscured

The plugin with the above changes can be found here:

Iā€™ve submitted pull requests to the original, but have not heard back.

1 Like

I couldnā€™t install this with BRAT.
Error message: The release is not complete and cannot be download. main.js is missing from the Release

I hope Ivanov is OK. His name suggests he may be from an area currently in war.