Closed fjebaker closed 3 years ago
This one does not highlight/color syntax at all for me, but I am probably doing something wrong. I'm using Jupyter 6.1.4 out of the box. Code completion works well.
I am unable to recreate the issue with 6.1.4, even using a fresh install on a VM.
Could you verify that
/usr/local/lib/python3.7/site-packages/notebook/static/components/codemirror/mode
or equivalent contains a directory named cadabra
, and within is cadabra.js
? My install script may be putting the file in the wrong place on your machine.
Also is Jupyter, or your browser console, logging anything unusual?
I have that file, but my web browser console shows
The resource from “http://localhost:8890/static/components/codemirror/mode/cadabra/cadabra.js?v=20201027114815” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
Try adding
CodeMirror.defineMIME("text/cadabra2", "cadabra");
in cadabra.js
between lines 146-147, before the final });
.
That made no difference, unfortunately; I still get that mime type mismatch error (in Firefox, haven't tried other browsers yet). I have nevertheless merged into master as it may work for others, and your pull request certainly improves on what we had already.
I'll try working with a few different browsers then, to see if I can recreate the mime-type error.
Summary
Details
I found a way of extending the existing python lexer to also highlight cadabra syntax, and track indentation level. It isn't cadabra keyword aware (instead using regex rules to identified cadabra syntax), but with the code completion that doesn't prove too problematic, as it limits the ability to mistype.
I copied a list of cadabra
::properties
from the manual and made the code completer aware of them, so that it can suggest them over the general namespace. I left this out for the algorithms, since they already exist as python functions by (mostly?entirely?) the same names. Additionally, if addressing members of an object with e.g.obj.<tab>
it will now searchdir(obj)
for the completion, so that typing is again less error prone.With this PR, the kernel is in pretty good shape -- going to take a break from development now 🤓