Examples or documentation of `Surrounder` class usage?

I’ve recently found the Surrounder class in Anki’s code, the code can be found here: anki/surround.ts at main · ankitects/anki · GitHub

It seems that this class should be able to do quite a lot of nice things, for instance the ability to toggle whether a piece of text is surrounded. Unfortunately I’m not well versed enough in JS/ TS to figure out how to use it myself. I was therefore wondering whether there are any examples or documentation on how to use it, especially when wrapping text with plain text not html elements which is very useful when writing LaTeX formulas for example.

I did find the builtin wrap function which seems to be based on the Surrounder class but doesn’t expose any of the more intricate features such as the toggling of surrounding text/ elements.

There are some plugins which seem to implement functionalities provided by the Surrounder class as well such as GitHub - AnKing-Memberships/anki-wrapper: Automatically create wrapper buttons based on config.json so it does seem I’m not the only one interested in this functionality :slight_smile:

I believe you’re quite buzzy these days so obviously feel free not to but could you potentially elaborate on this @hengiesel ? I suppose you’d be in the best position to do so given you’ve written the code if I’m not mistaken.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.