nothingislost / obsidian-dynamic-highlights

An experimental Obsidian plugin that highlights all occurrences of the word under the cursor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trouble with "escaping" characters

ReaderGuy42 opened this issue · comments

I'd like to use this plugin to highlight LaTeX citing code, so e.g. \cite{Smith2020}. I'd like to permanently highlight everything between the \ and the }.

According to regexr.com this should work: (?<=\\)(.*?)(?=\}), i.e. it should highlight everything between a backslash \ and a }, so that \cite{Smith2020} would be highlighted.

The plugin doesn't like that though. When I do it via the GUI nothing happens, but when I try importing a highlighter, using the template from the github page:

{
 "TeX-Cite-highlight": {
   "class": "TeX-Cite-highlight",
   "color": "#77787C4A",
   "regex": true,
   "query": "(?<=\\)(.*?)(?=\})",
   "mark": [
     "match",
     "group"
   ],
   "css": ""
 }
}

I get the error: Error importing highlighters: SyntaxError: Unexpected token } in JSON at position 138.

So it seems that the escape character isn't read?

I've also tried this: \\(.*?)\} but with the same result. Again according to that regexr website it should work.

It's not just curly brackets btw. It also can't escape )

Any ideas?