feat: Support more CSS selector attributes#16
Open
tomasfarias wants to merge 3 commits intophoebejaffe:mainfrom
Open
feat: Support more CSS selector attributes#16tomasfarias wants to merge 3 commits intophoebejaffe:mainfrom
tomasfarias wants to merge 3 commits intophoebejaffe:mainfrom
Conversation
Previously, we could only match on prefix strings. With this change, we allow matching on string suffixes and substring matches too. This is achieved by introducing a new configuration value "selector", by default set to Prefix to preserve old behavior. This can be configured to apply a different CSS selector. Some work is pending to ensure backwards compatibility, at the moment this would break existing configurations.
Owner
|
This is so cool! I'm not sure when I'm gonna have time to test it, or figure out how to deploy the new version though... I've been pausing my logseq usage until they release the db one as stable, then maybe I'll move back from obsidian. But if I find some time, maybe I'll work on figuring out how. Thank you for your interest and work on this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of all, love the plugin. Saw it recommended here: www.youtube.com/watch?v=PN6tjeQfxRc, and now use it a lot.
Problem
I really wanted to have the chance to match not only on prefixes but suffixes and even any regular expression too. There seems to be some interest from others too as seen in #5.
Changes
So, I went ahead and implemented that. I basically saw that CSS supports multiple selector attributes: https://www.w3.org/TR/selectors/#attribute-substrings. So I just added a new
selectorproperty toBlockStylesto choose among the 4 that seemed the most relevant (exact match, prefix, suffix, and substring).This means that with a configuration like this:

It's now possible to achieve this result:

Naturally, the new settings are not backwards compatible, so I also added a bit of code to handle mapping old settings to the new settings. Would really like somebody to test/review this too, just to have a second confirmation that everything works fine (I tested in with my own settings and they worked fine).
Unfortunately, I couldn't get the plugin setup for development without bumping a bunch of dependencies, so I bundled that together with this change.
TODO
Maybe more selectors could be added later? I am not super familiar with the CSS spec, pretty much just reading through the docs the first time now.
Personally, I would like to be able to group a bunch together, to shorten my settings when repeated styles happen.
I hope these changes are well received, if not, feel free to close this PR! Thank you for your time.