Skip to content

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.

2 participants