Fix function formatting getting zettel from dir

This commit is contained in:
Marty Oehme 2021-04-30 15:26:32 +02:00
parent 5228a3b49e
commit e31630a8c4
Signed by: Marty
GPG key ID: B7538B8F50A1C800
4 changed files with 9 additions and 5 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
public/

View file

@ -65,6 +65,7 @@ next up:
* [ ] zettel 'lens' (preview first headline + content of linked zettel through floating window etc, on keypress)
* [ ] support *both* md-style and wiki-style links at the same time
* [ ] file/directory exception list for gathering files, which will be ignored
* [ ] 'strict' mode *only* matching and following valid anchor links
## TODO: maintenance

View file

@ -64,12 +64,13 @@ end
-- Take a list of zettel as an optional variable, without which
-- it will use the (recursive) results of the zettel_root directory.
function ls.get_zettel(anchor, all)
local zettels = all or
ls.get_anchors_and_paths(
ls.get_all_files(o.zettel().rootdir, true))
if not zettels then return end
if not all then
local files = ls.get_all_files(o.zettel().rootdir, true)
all = ls.get_anchors_and_paths(files)
end
if not all then return end
return zettels[anchor]
return all[anchor]
end
return ls

View file

@ -167,4 +167,5 @@ describe("get_zettel", function()
ls.get_zettel(expected)
assert.stub(fc).was_called_with(expected, true)
end)
end)