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

Very incomplete diacritics support #310

Closed
TempaYeshe opened this issue Aug 15, 2024 · 9 comments
Closed

Very incomplete diacritics support #310

TempaYeshe opened this issue Aug 15, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@TempaYeshe
Copy link

TempaYeshe commented Aug 15, 2024

Hi,
Right now, you are using this solution to remove diacritics for the "Treat accent diacritics as alphabetic characters" option.
The problem is that it does not cover all diacritic combinations at all, and it does not look very clean. There is a much better solution, used in this other plugin, which is:

  1. "Decomposing" the diacritics with the String.prototype.normalize("NFD") function. The result in unicode is the base letter without diacritic code + the appropriate "Combining Diacritical Mark" code(s).
  2. Now, you just have to remove the combining diacritical mark(s) with a regular expression /[\u0300-\u036f]/g

So in the end there is a very simple function to remove all possible diacritics (taken from here):

function removeDiacritics(str: string): string {
    return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
}

Thank you for your plugin!

@tadashi-aikawa
Copy link
Owner

Thank you for your suggestion, @TempaYeshe :)

This is about a different plugin, but I once implemented it in exactly the same way as you suggested.

tadashi-aikawa/obsidian-another-quick-switcher@cea95e6

However, I received reports that this implementation does not handle certain symbols. After that, I rewrote it to cover those as well, which led to the current somewhat forceful implementation.

tadashi-aikawa/obsidian-another-quick-switcher#23

Unfortunately, since I never use diacritics, I am unsure about what is reasonable or what to prioritize for this specification. If you happen to know a solution that could resolve the issue above, I would appreciate it if you could share it with me👍

@TempaYeshe
Copy link
Author

TempaYeshe commented Aug 17, 2024

The technical reason is that "Ø" is not a diacritic (cf. Wikipedia), like other characters like "œ". Right now your current solution has the benefit of covering these cases that are not "pure" diacritics, so I guess it is not worth changing. But there is a problem with it when a word starts with one or multiple diacritics such as śūnyatā: the completion does not trigger if you type the letters without diacritics (sun in the example, you need to type explicitly śūn which defeats the purpose).

@tadashi-aikawa
Copy link
Owner

@TempaYeshe
Thank you for the detailed explanation. I wasn't aware of the distinction between pure diacritics and those that aren't, so I learned something new.

But there is a problem with it when a word starts with one or multiple diacritics such as śūnyatā: the completion does not trigger if you type the letters without diacritics

I tried writing a test using śūnyatā for the exact same method in a different project, and contrary to my expectations, the test passed successfully. Since Various Complements use the same logic, I believe sunyata should also work.

image

image

If you encounter any issues in your environment, it would be helpful if you could share the reproduction steps within Sandbox Vault.

@TempaYeshe
Copy link
Author

TempaYeshe commented Aug 20, 2024

Thank you for helping me. The problem happens in the sandbox vault (Obsidian v1.6.7) with only Various Complements and completely default settings (except for "Treat accent diacritics as alphabetic characters"):

Screen.Recording.2024-08-20.at.16.44.20.mov

@tadashi-aikawa
Copy link
Owner

Thank you, @TempaYeshe :)

I could reproduce it 👍

@tadashi-aikawa
Copy link
Owner

@TempaYeshe
I have identified the cause. This issue occurs only when the "Current file complement" is used, and the "Match strategy" is set to "prefix."

I have a fix in sight and plan to release a revised version by the end of this week.

@TempaYeshe
Copy link
Author

Thank you very much @tadashi-aikawa 🙏

tadashi-aikawa added a commit that referenced this issue Aug 25, 2024
…rent file complement" and "Current vault complement" when "Match strategy" is set to "prefix," even if "Treat accent diacritics as alphabetic" is enabled (#310)
@tadashi-aikawa tadashi-aikawa moved this from In Progress to Done in Obsidian Various Complements Plugin Aug 25, 2024
@tadashi-aikawa
Copy link
Owner

@TempaYeshe
Released in v10.0.3 🚀

@TempaYeshe
Copy link
Author

Works wonderfully, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants