Furkanzmc / zettelkasten.nvim

A Vim Philosophy Oriented Zettelkasten Note Taking Plugin
The Unlicense
223 stars 9 forks source link

Add error handling for faulty notes #20

Closed dapc11 closed 1 year ago

Furkanzmc commented 1 year ago

Hey! Thanks for the PR.

Can you describe what a faulty note is?

dapc11 commented 1 year ago

Sorry, should have included that into the commit message. It was basically a note that I created outside the Zettelkasten workflow, thus forgot adding a proper header to the top of the document.

Furkanzmc commented 1 year ago

But the note's file name matches the pattern, right? If that's the case, the id of the note is actually the file name without the extension. And If we can't find the expected format for the title, maybe we can use the first non-empty line as the note title.

What do you think about that?

dapc11 commented 1 year ago

Yes it did, it was just that the title part (not date) of the heading that was missing.

Furkanzmc commented 1 year ago

Yes it did, it was just that the title part (not date) of the heading that was missing.

In that case I think the node ID should be extracted from the file name, and we should use the first non empty line as the title (Excluding the note id part if it's still there). Returning nil and not showing that note doesn't sound right to me.

Would you be willing to make that change?

dncnmcdougall commented 1 year ago

In my pull request for #19 (#21) I implemented explicit flags that allow you to specify whether to use the title or the filename (or both) for determining the id. It rases an error if you use both and they don't match. It does not do what this pull request does and raise an error if it could not extract it from the title.

Furkanzmc commented 1 year ago

I think #21 is an appropriate solution to this problem as well. Thank you for the contribution! If the new solution doesn't work for you, we can revisit this idea.