jensmtg / influx

An alternative backlinks plugin, which displays relevant and formatted excerpts from notes with linked mentions, based on the position of mentions in the notes' hierarchical structure (bullet level indentation).
MIT License
310 stars 14 forks source link

Problem finding the correct heading #32

Open DeutscheGabanna opened 1 year ago

DeutscheGabanna commented 1 year ago

Hi, consider this snippet:

# My title
Something

# Same-level title
> [!callout]
> Testing a callout.

- [[the actual mention]]

Once influx finds this mention, it mistakenly assumes that # My title is the heading for the mention. In reality, # Same-level title is the correct heading for the mention.

Why does it happen? Could a callout in-between mess up the logic?

DeutscheGabanna commented 1 year ago

Real life example: image image

jensmtg commented 1 year ago

It's not a mistake, in the sense that Influx uses the first header it finds in the note in all cases. I agree that using the nearest and highest header would be more natural, but that requires additional conditional evaluation logic. Flagging it as a potential enhancement.

MitchWagnerSD commented 1 year ago

I second this enhancement request--it would be very useful for me.

I've only been using Influx for a few hours and I already love it. Great work!

MitchWagnerSD commented 1 year ago

Workaround: Preceded the header with a bullet.

In the above example, if you write out

- # Same-level title

That should yield the expected behavior.

pawel-ilnicki commented 1 year ago

Influx uses the first header it finds in the note in all cases.

Pre-1.0 obsidian release I would agree with you, because without inline titles the heading hierarchy looked like this:

# Title
## Actual section
Text
## Another section
Text

But now, post-1.0 release, with inline titles, h1 no longer needs to be the entire note's title. This is now a valid approach too:

# Actual section
Text
# Another section
Text
danieltomasz commented 1 year ago

In general, in many markdown implementations there should be only one h1 in file which is interpreted as a title in file https://github.com/updownpress/markdown-lint/blob/master/rules/025-single-h1.md

As many people will probably use multiple h1 in the notes, this might be a non default settings to set

jensmtg commented 1 year ago

Yes, this is not as straight-forward as it may seem. Multiple mentions in the same document also illustrate why:

# My title
- [[a note]] first mention

# Same-level title
- [[a note]] second mention

As I see it, either "My title" should be used as the representing header for the page, or the notion that a header can represent a note must be abandoned. In the last case, headers may be considered part of the "context hierarchy" for mentions, and simply part of the text.