zk icon indicating copy to clipboard operation
zk copied to clipboard

Special characters throw off the YAML frontmatter parser

Open mickael-menu opened this issue 3 years ago • 5 comments

It looks like using special characters in the YAML frontmatter or note titles might be breaking the indexing.

Ahh, I'm wondering if certain characters in a filename or title might be breaking completion? |, :, and & are command items in some of my note file names and titles (i auto-extract calendar titles and use those from meeting note generation and pass that along to zk.nvim to generate the note, or open an existing note with the same file name).

When searching for a note (using zk edit --interactive via cli, not abstracted out via zk.nvim) that does contain one of the above characters, these are throw into the preview area of fzf:

image

Originally posted by @megalithic in https://github.com/mickael-menu/zk/issues/22#issuecomment-814347167

mickael-menu avatar Apr 06 '21 20:04 mickael-menu

@megalithic From the logs you shared, I think it's the content of the YAML frontmatter failing with these notes. Would you mind sharing the content of one of these notes up to the first heading? Redacted if you prefer.

Btw such errors might be visible only after modifying these notes. You can force reindexing the notes with zk index --force to see all the errors found when parsing your notebook.

mickael-menu avatar Apr 06 '21 20:04 mickael-menu

I can reproduce this warning:

zk: warning: yaml: mapping values are not allowed in this context

with the following frontmatter:

---
title: A title with: special characters
---

But it's not valid YAML, if it contains a : the title must be surrounded by double quotes to produce a valid string, this works:

---
title: "A title with: special characters"
---

mickael-menu avatar Apr 06 '21 20:04 mickael-menu

ahh, i will handle that post-haste in my own templates and configs. thank you!

megalithic avatar Apr 06 '21 20:04 megalithic

Okay let me know if you have any other warnings after fixing your templates, and then I'll close this issue. I'm not sure there's anything to do in zk at the moment.

YAML is annoyingly ambiguous, I wish another format was more widespread for Markdown frontmatters. I'm thinking we could fallback on MultiMarkdown parsing, but it doesn't support lists for tags.

mickael-menu avatar Apr 07 '21 08:04 mickael-menu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 5 days.

github-actions[bot] avatar Jan 23 '22 15:01 github-actions[bot]