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

data-tag-name not applied in HTML #1208

Open
nucleogenesis opened this issue Jan 14, 2025 · 1 comment
Open

data-tag-name not applied in HTML #1208

nucleogenesis opened this issue Jan 14, 2025 · 1 comment

Comments

@nucleogenesis
Copy link

I'm trying to customize the appearance of particular tags per the suggestion in the docs:

/* --> Example Tag with angle brackets: #<my cool tag> */
.sb-hashtag[data-tag-name="my cool tag"] {
  background: purple;
  color: limegreen;
  font-weight: bolder;
}

But when I make a line #hello there in a doc, then inspect that element, this is the HTML output:

<div class="cm-line"><span class="sb-hashtag">#hello</span> there</div>

So there is no effect if I put space-styles like, for example:

.sb-hashtag[data-tag-name="hello"] { 
    background: orange;
    color: purple; 
}

I may investigate in the code a bit when/if I have time, so any guidance would be appreciated.

Running Version: 0.10.1 on Fedora Linux in Chromium browser

I do wonder, though, if this is something only I am experiencing because it seems like a bug that would affect people pretty immediately for anybody using such custom space-styles - so I'm curious if you/anybody can replicate.

@mjf
Copy link

mjf commented Jan 23, 2025

@nucleogenesis Well,

```space-style
.sb-hashtag[data-tag-name='my cool tag'] {
  background-color: Purple;
}
```

But you have to use The #<...> syntax for tag (the left and right angle brackets allows for spaces etc. in the tag name).

# Test CSS attribute selectors on tags

Some paragraph. #<my cool tag>

Another paragraph with #<my cool tag>.

```query
paragraph
  where
    tags = 'my cool tag'
  select
    text
```

Does this work for you?

Hint, I like to "structure" my tags a little, e.g., #Linux/Kernel, #<Linux/Performace Tuning> etc. The CSS selectors (see CSS Attribute Selectors) can then be used to match only the Linux/ part, like this:

.sb-hashtag[data-tag-name^='Linux/'] {
  background-color: Blue;
}

Then every tag which name starts with Linux/ will have blue background colour. It's very nice that the colour changes
while autocompleting!

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

No branches or pull requests

2 participants