nvim-neorg / norg-specs

A collection of specifications and grammars for Neorg's file format, `norg`.
88 stars 18 forks source link

[Suggestion]: Rethinking footnotes/definitions #48

Open boltlessengineer opened 5 days ago

boltlessengineer commented 5 days ago

We previously have footnotes/definitions syntax like this:

^^ footnote id
footnote content

which can be multiple paragraphs
^^

Which is defined as one type of detached modifier. Because they don’t need to be nested, v1 spec introduced 3rd type of detached modifiers; ranged detached modifiers. But should they really have to be like that?

Norg doesn't care where to put footnotes/definitions. User can put footnotes anywhere in the document, which is a really neat feature to have as a markup language. So all features they need is:

Then why should they need levels/nesting/grouping? How should we handled nested definitions?

In core concept, they are more closer to standard ranged tags which has exactly those two features.

Then how to reimplement footnotes/definitions?

We can implement footnote/definitions using tags:

|def word
definition of word
|end

|ftn 1
footnote index 1
|end

I used ftn to match with def. I'm not sure what would be more intuitive & easy to use. I’ve considered |$ and |^ but those seem a bit unintuitive to me.

Wait what about inlined versions?

We can implement those with infirm tags (I’m using syntax suggested from #47 for convenience)

.def word; definition of word

.ftn 1; footnote index 1

Ok then how to target them from links?

If footnotes/definitions are standard ranged tags, how to ensure they are linkable with prefix + title format?

I haven't fully made up my mind on this issue yet. So I’ll leave few ideas that come to mind.

Base idea

As footnotes/definitions are standard ranged tags, they can return altered Norg markup from given range of texts:

|def word
definition of word
|end

can be expanded to

+definition
+id word
definition of word

But this will match with all {# word} link targets so we should fix that.

Sol 1) custom non-strict prefix

Imagine .def word ... is expanded like this:

+definition
+id def-word
definition of word

So we can use it like this: {# def-word}

Simple, but not that convenient to use.

Sol 2) ability to define custom URI scheme

Let’s change the existing raw URI link target syntax. Now users can define a URI scheme to abstract objects.

+definition
+uri def://word
definition of word

So we can use it like this: {def://word}

Better in some points, but still not that convenient and feel too hacky solution.

Sol 3) Macro link target

What if we introduce macro link target; a macro that can be expanded inside the link definition. So we can define custom macro link def that searches for given id but filter to abstract object that has +definition attribute.

.macro-link def; …

+definition
+id some word
definition of some word

And use it like this: {.def some word}.