Creating new mode(?) reusing existing mode (e.g. new clike syntax highlighting)

Hello.
I am new user, I have recently started using Jupter, which in turn uses CodeMirror in is notebooks.
I am not sure if my question is right for this forum.

What I am trying to accomplish?
I have created my own programming language and I want to integrate it fully with Jupyter,
that means also getting syntax highlighting working in the notebook.

What I get so far?
I got Jupyter notebook up and running backed up by my kernel.
I can have syntax highlighting if I copy one of existing modes and edit it to suite my needs.

What I want to achieve?
I want to reuse existing mode, namely ‘clike’ to do my highlighting for me.
I read through clike.js, and I found there a section that creates a bunch of different highlighting
for different languages (C, C++, Java, C#).
My language has very similar syntax so it makes sense to get highlighting for it in the same way
C or Java highlighting is done, I mean, reusing common ‘clike’ template.

I do not want to modify any of the Jupyter/CodeMirror files, which means, I do not want
to edit clike.js. I want to keep my mode definition in separate file which I can copy/link
into proper mode directory.

I tried to mimic what happens at end of clike.js in
mode definition file I created.

Unfortunately this does not work.
Or, it sorta works iff I add alert() call at end my mode file :astonished:

My questions are:
What is the proper way of defining new mode(?)/MIME for new language with very clike syntax?
Can I reuse exiting clike mode like C# or Java does?
Can I do all of this while keeping my definition in separate file?

Your code looks okay. The thing where it only works when you add an alert suggests you have some kind of timing issue or other problem not directly related to what you’re describing.