extensions
extensions copied to clipboard
[Unicode Symbols Search] find super script with number input
Extension – Unicode Symbols Search
Author: @mmazzarolo
I would love to be able to get a superscript number by entering something like super 9
-> ⁹
Describe the feature and the current behavior/state.
Currently it does not find the superscript item when I enter super 9
. I have to type super nine
.
It would be easier to use if it could just work with both, the numeric (9) value and the word (9). Same should work for subscript.
Who will benefit with this feature? Anybody using this to get super script numbers or subscript.
@mmazzarolo fyi
This issue/pull request 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 7 days to keep our backlog clean. Thanks for your contributions.
Hey @mmazzarolo @danielsequeira I think all that is required is to add the number to the name in the dataset json file: https://github.com/raycast/extensions/blob/d18a6e43408d105a3ed7a17b6693fca19ea75ea3/extensions/unicode-symbols/assets/dataset.json#L4803
Happy to send a PR if it will be merged.
@lukasoppermann to be honest I think it would be better to start support aliases for such use cases. The name
property is a strict mapping to the official unicode character name; if we start editing the some of them just because we don't like them, that might bite us back in the future (just my 2c!). What do you think @lukasoppermann ?
Would be happy to review and help shipping an aliasing feature btw!
(Sorry for the late reply, I didn't notice I was pinged twice 😓 )
@mmazzarolo That is even better. How would we go about adding this though?
@mmazzarolo That is even better. How would we go about adding this though?
OK, I started writing something and then I changed my mind 😬
Easiest way to implement this
- In the
generate-dataset.ts
script, add a something something likeconst charCodeToAliases = {"8313": ["superscript 9"]}
. This will be the list of aliases we want to apply to the final dataset. I think it might even be better to define it in its own json file. - Update
mapCharacterToDatasetItem
to also add thealiases
to the output (if any). - In the
src/dataset-manager.ts
, update the Fuse search to also search inaliases
(just add it to thekey
array).
I think this is the easiest (and most performant) way to implement this.
Drawback of this approach:
- Adding an alias requires re-running the
generate-dataset.ts
script. - It would be cool if users could add their own alias for a character as a preference, but I think it might be a bit hard to do with the current setup.
Let me know if it makes sense!
Previous idea (just for historical context):
It's been a while since I worked on this extension, but if I recall correctly the idea I had around character aliasing was:
- Create a new
/src/default-aliases.json
file that maps characters to custom aliases. Given your example, it would look something like:{"8313": ["superscript 9"]}
. People can submit PR to update this file. - It would also be nice to allow setting your own alises through preferences.
- In
dataset-manager.ts
, right after we get the filtered results from Fuse, append the result of the same search query but done directly on the aliases.
Reason about some of the decisions above:
- We could also merge the aliases with the dataset values using the
generate-dataset.ts
script. While more "elegant", I think this is less ergonomic because it requires running that script every time we add new aliases to the repo. - There might be a way to use Fuse to also handle the aliases search as well (instead of doing that search manually like I suggested), but we need to ensure we don't low the performance → AT THIS POINT I REALIZED THAT IT DOESN'T SEEM TO BE POSSIBLE TO GRAB CHARS BY ALIASES WITH THIS SETUP UNLESS WE FILTER THE ENTIRE DATASET WITHOUT USING FUZE. /STOP-SCREAMING
I might have time to work on this next weekend. Would it be possible to add generate-dataset
to the build
script so that the fact that "it requires running that script every time we add new aliases to the repo" doesn't become a pain point? I think merging aliases is the only way for this command to remain performant.
@Sheraff I think so? I think I did find some issues doing that in the past but I don't remember what they were... and things might have changed now 👍
This issue/pull request 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 7 days to keep our backlog clean. Thanks for your contributions.
This pull request 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 7 days to keep our backlog clean 😊
I'm closing this due to inactivity; feel free to comment in the thread when you're ready to continue working on it 🙂 You can also catch us in Slack if you want to discuss.