As I understand it the $OutlineOrder attribute – as its name implies – only gives the sequentially integer-numbered position of a note irrespective of its outline depth.
I was hoping that I could find (or code) an attribute that, in conjunction with a $DisplayName = rule, would assign automatically updating outline numbering prefixes to note names (in outline view) along the lines of
First Main Heading
Second Main Heading
2.1 Subheading A
2.2 Subheading B
Third Main Heading
3.1 Subheading C
3.1.1. Sub-subheading
(I’m not bothered about the formatting of the outline ordering – Harvard, whatever is fine)
In case this is an example of an xy problem, I should explain that as well as providing some formatting I’m actually planning to use this attribute to assign a large number of atomic notes to the outline (i.e. the atomic notes would have user-assigned values for a $TopicIndex attribute and the Heading notes in the outline would query for atomic notes with $TopicIndex == their outline number). I hope that makes sense…
I’ve done something like this with a Rule that looks at the outline level of the parent and prepends that to the current note’s outline level – with whatever formatting is desired.
Add this to a prototype that you’ll use for all numbered notes. Before adding any rule or edict code, first un-check the ‘Enabled’ box on the Inspector for the rule or edict. Why? Because you don’t want the code running in the prototype itself. I’d recommend using an edict as you can alway force update an edict, e.g. if you move or delete a note, but the code doesn’t need to run all the time (as would be the case with a rule).
Add a String-type user attribute ‘TopicNumber’ to your prototype.
Also in the prototype select the Text Inspector and un-check ‘Enabled’ for the Display Expression, then add this code:
$TopicNumber+" "+$Name
Also set the OnAdd action of your prototype (here mine is called “Task”) like so:
Prototype|="Task";
Lastly ensure all your prototype, template, etc., folders are at the end of the root container so your first content note is sibling #1. The result is like this:
But let’s say you want the number to be under a root container. It still works, as long as the parent (not using the prototype) has no $TopicNumber value:
As the code calculates values from the parent of the numbered note, the same prototype can populate more than one discrete set of numbering:
If you only want a trailing period that’s likely possible too, though it might make usage not as flexible as above. But, I’ll leave that as an exercise for someone else to try.