Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag definition #50

Open
dawsers opened this issue Apr 22, 2024 · 5 comments
Open

Tag definition #50

dawsers opened this issue Apr 22, 2024 · 5 comments

Comments

@dawsers
Copy link

dawsers commented Apr 22, 2024

I am sorry I am bringing this up again. I have noticed a small bug when parsing tags.

According to the Obsidian manual, a tag is defined this way:

Tag format

You can use any of the following characters in your tags:

  • Alphabetical letters
  • Numbers
  • Underscore (_)
  • Hyphen (-)
  • Forward slash (/) for Nested tags

Tags must contain at least one non-numerical character. For example, #1984 isn't a valid tag, but #y1984 is.

When I use tag auto-completion, I get this:

screenshot-1713774068

It seems parsing only tests for at least one non-numerical character between # and a space. That is why #2024 is parsed correctly as a non-tag, but not the links. Those tags include the full URL. #7 wouldn't be a tag, but if we include ] and the rest as valid characters for a tag name, we end up with the tag shown in the dialogue. The same goes for #seven.

The tree-sitter markdown parser considers this a tag:

_tag_name: $ => seq($._word_no_digit, repeat(choice($._word_no_digit, $._digits, '-'))),

that means after the # there cannot be a digit as first character, but then they are allowed, so #y1984 is valid, but #1984y isn't.

So I think the regular expression needs some tweaking, something like:

/(^| )+#[a-zA-Z_\-\/][0-9a-zA-Z_\-\/]*/

screenshot-1713777330

I don't know about #-/_/tag, but it doesn't seem the spec rejects it. Maybe you prefer to tweak the first part so the first character doesn't include _-/ either.

Thank you!

@Feel-ix-343
Copy link
Owner

Thank you for this!

Your comments are exceptionally helpful!

Solving this should involve a trivial adjustment of the tag regex + some testing. Nothing too hard!

@dawsers
Copy link
Author

dawsers commented Apr 22, 2024

I would like to be of more help by coding instead of filing reports, but as I explained, Rust is foreign to me. I spent one full day trying to change six lines of code in the Vault part of your application before I gave up. :-)

@Feel-ix-343
Copy link
Owner

Ah well the reports are extremely helpful.

Also I am in the process of a huge refactor, and the current code is not very good to be honest. Hopefully after the refactor things will become more clear!

@anandkumar89
Copy link

Also, tag completion only happens at the start of line. Is it the default behaviour?

@Feel-ix-343
Copy link
Owner

Also, tag completion only happens at the start of line. Is it the default behaviour?

This is because of #17 ; It's an nvim-cmp issue

@Feel-ix-343 Feel-ix-343 added this to the Refined Markdown Oxide milestone May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

3 participants