Skip to content

Conversation

@tomasfarias
Copy link

@tomasfarias tomasfarias commented Oct 30, 2025

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 selector property to BlockStyles to choose among the 4 that seemed the most relevant (exact match, prefix, suffix, and substring).

This means that with a configuration like this:
image

It's now possible to achieve this result:
image

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.

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.
@phoebejaffe
Copy link
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!

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