hsnips icon indicating copy to clipboard operation
hsnips copied to clipboard

Escaped backslash not showing before right curly brace

Open ahan98 opened this issue 1 year ago • 1 comments

The escaped backslash does not appear in the snippet return value \\}.

Minimal example:

  1. Create latex.hsnips
  2. Define the following snippet
snippet foo A
`` rv = `\\}` ``
endsnippet
  1. In somefile.tex, type foo
  2. Expected: \}, Received: }

To actually output \}, the RHS needs to be \\\\}.

Also, the error does not occur for: space-separated \\ }; individual characters \\ or }; other braces, e.g., \\{.

ahan98 avatar Mar 23 '23 10:03 ahan98

Pretty sure this is intended behavior. The first \ is to escape the } in the hsnips language. Then you need to escape it again so regex spits it in the snippet language, then you regularly escape it inside your regex. Triple escape.

This is also how it works in json (for the Conceal extension).

Fredlague avatar Jan 30 '24 01:01 Fredlague