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