Customize the Codemirror Auto Close Brackets Plugin

Hello,

I did not find related topics so I decided to make a post. If you wish to add customized pair to be auto closed, do the following:

(0. install codemirror and auto close brackets plugin)

  1. open the file $:/plugins/tiddlywiki/codemirror/addon/edit/closebrackets.js
  2. search for the string (function(C){var r={pairs:"()[]{}''\"\"",closeBefore:")]}'\":;>",triples:"",explode:"[]{}"}, You can find this by searching for pairs, the first result should be this.
  3. add your pair after pairs:", add the closing part after closeBefore: e.g.:
(function(C){var r={pairs:"$$()[]{}''\"\"",closeBefore:"$)]}'\":;>",triples:"",explode:"[]{}"},
  1. Save and Reload. This should work.

Note: I use Katex in markdown so I only need $$. I’m not sure if $$$$ will work.

That’s all. May you have a great day.

3 Likes