Css/plugin for using "{{" & "}}" as a 2nd alternate highlight

What I’m trying to do

I want to have text enclosed between {{ and }} to be highlighted in a different colour than using ==.

The reason is I use the spaced repetition plugin, and it has the option to create clozes with highlight(==), bold(**), or {{.

I want the flexibility of being able to highlight stuff without creating a cloze while still having the clozes highlighted differently.

Things I have tried

Haven’t found any

I have considered using == for the clozes and simply changing the font colour for ‘normal’ highlighting, but I’d like to use actual highlighting if possible

You can use the regex mark plugin to add a cssclass to the “{{ }}” text, and then you can add a css to change the background of the text with this cssclass.

1 Like

Thank you for the suggestion.

I’m not used to regex, so I’m having some trouble.

Documentation of my misery

This is how I have set it up;

And this is the result;
image

  1. It seems to open with a single { instead of double ({{)
  2. The closing tag doesn’t work

Even different tags (\^ as used in the plugin’s example) have the same problem of the closing tag not working.

I’m not sure if it is a problem with the plugin, or something on my end.

Any help would be much appreciated!

edit:
My css incase it is relevant;

.highlight2 {
    background-color: #3333aa;
}

The problem seems to be with the way to define the tags.

The default is {{open:}} but since I need to use {{ I had to change it to something else (it’s advised to do so by the plugin). Using the default setup properly closes the tag.

But I’m limited in my choice of alternate characters to use here. (, ((, [, [[, < none of these work.

Also, escaping the [using \ as instructed gives an error.

I’ve finally managed to get it to work lol.

Thank god I’m not a programmer.

I’ll leave my setup here for anyone else viewing this

Working setup

Opening tag => \[open:(.*?)\]
Closing tag => \[close:(.*?)\]

regex => [open:\{\{](.*)[close:\}\}]
regex flag => gi (default)
class => highlight2 (can use any classname)

css snippet

.highlight2 {
    background-color: #3333aa;
}

Only thing missing is a way to hide the curly brackets ({{).

Is it impossible as discussed here?

Hm, normally, you can enable a toggle in the settings, for each regex, to hide the open and close characters, just before the delete icon.

Seems to be a bug, I’ve opening a bug report on it.

Thanks again