Sublime Forum

Matching multiple scopes in color syntax

#1

I’m working on a color syntax and I want to select all markdown punctuation. I know I can comma-separate multiple scopes, but I was hoping there might a wildcard I could use.

Something like:

"scope": "punctuation.*.markdown"

Rather than the monstrosity I’m using right now:

"scope": "punctuation.definition.blockquote.markdown, punctuation.definition.bold.markdown, punctuation.definition.constant.begin.markdown, punctuation.definition.constant.end.markdown, punctuation.definition.constant.markdown, punctuation.definition.heading.markdown, punctuation.definition.italic.markdown, punctuation.definition.link.markdown, punctuation.definition.list_item.markdown, punctuation.definition.metadata.markdown, punctuation.definition.raw.markdown, punctuation.definition.string.begin.markdown, punctuation.definition.string.begin.markdown, punctuation.definition.string.end.markdown, punctuation.definition.string.end.markdown"

Alex

1 Like

Color Scheme Builder
#2

What are you trying to do? I think you might be going down the wrong road, maybe not. But I need to understand what you are doing in order to help.

0 Likes

#3

See what the top lever is, then you can do something like:

text.html.markdown punctuation.definition

This will color all those items that start that way. Adding text.html.markdown limits it to that type of document only.

I am assuming this is in the tmTheme file? If this is the tmLanguage file, ignore this, I’m not sure what you’re doing.

1 Like

#4

@handycam Thanks, that’s exactly what I was looking for!

Sorry for confusing you guys. I should have mentioned I was working on a tmTheme.

Alex

0 Likes

#5

I do wish the wildcard worked though; I’ve had a similar situation where I wanted only a specific language to have the styling applied.
Sure punctuation.definition does the trick but it does so for ALL languages, not just for Markdown as punctuation.*.markdown would do.

0 Likes

#6

@nick. Look at @handycam’s post again. To select all punctuation in markdown you would use: text.html.markdown punctuation.definition

1 Like

#7

Aha, I missed that, thanks! I had just assumed the space was akin to a CSS comma to style multiple scopes at once.
It makes sense that it references the hierarchy, given how the scope names appear using Ctrl+Alt+Shift+P.

0 Likes

#8

Now if only there was a way to use variables in .tmThemes…

EDIT: I mean for colors

0 Likes

#9

Would be easy enough to implement a parser in the existing syntax generating plugins.

0 Likes