pseudoloc icon indicating copy to clipboard operation
pseudoloc copied to clipboard

Multiple delimeters

Open robertlevy opened this issue 10 years ago • 2 comments

Would love to see support for multiple delimiters. Something like:

options.delimiters = [
  '__', 
  {start: '<', end: '>'}, 
  {start: '{{', end: '}}'} 
]

Bonus points for handling nested delimiters (the ones that use start/end atleast)

robertlevy avatar Sep 13 '14 23:09 robertlevy

I don't have any need for this so probably won't be adding it myself. If you decide to add support, I'd be happy to take a pull request.

bunkat avatar Sep 14 '14 03:09 bunkat

@robertlevy I needed something like this as well, but the way that I am getting away with having multiple delimiters is passing in RegEx that will match multiple things. It doesn't work perfectly, but it may work for you.

Example:

pseudoloc.option.startDelimiter = '(%{|<|</)'; // %{ or < or </
pseudoloc.option.endDelimiter = '(}|>|/>)'; // } or > or />

The reason this works is because the delimiters are prepended/appended to a RegEx.

For me, it doesn't work perfectly, because I have html strings with attributes (<a href="">) that don't get excluded properly. However, strings like <strong> and </strong> get excluded OK.

Hope this helps!

burin avatar Aug 25 '15 19:08 burin