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

fix matching html content as obsidian tags #537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kai-kea
Copy link

@kai-kea kai-kea commented Feb 27, 2024

addresses #536

This regex matches obsidian tag style #my-tag only if it's not part of an HTML expression, e.g. from #536, ' will be matched and skipped over.

addresses ObsidianToAnki#536 

This regex matches obsidian tag style `#my-tag` only if it's not part of an HTML expression, e.g. from ObsidianToAnki#536, `&ObsidianToAnki#39;` will be matched and skipped over.
Copy link

@nicoberling nicoberling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RegExp you wrote adds an exceptions specifically for HTML special chars, instead it should simply match Obsidian tags, as described in the documentation:
/(?:^|[\t ])(#[a-zA-Z0-9\/_-]*[a-zA-Z\/_-][a-zA-Z0-9\/_-]*)+/g
This matches a tag preceded by the start of the line or whitespace, including at least one alphabetic letter, numbers, the hyphen, slash or underscore. Adapted slightly from here.

@kai-kea
Copy link
Author

kai-kea commented Mar 8, 2024

The RegExp you wrote adds an exceptions specifically for HTML special chars, instead it should simply match Obsidian tags, as described in the documentation:

/(?:^|[\t ])(#[a-zA-Z0-9\/_-]*[a-zA-Z\/_-][a-zA-Z0-9\/_-]*)+/g

This matches a tag preceded by the start of the line or whitespace, including at least one alphabetic letter, numbers, the hyphen, slash or underscore. Adapted slightly from here.

I agree, this solution is much cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants