Closed fjebaker closed 3 years ago
The way '#' is handled does not exactly match that description. It's very simple: inside a line containing a property declaration (that is, a ::
symbol) or inside a line containing an expression declaration (that is, a :=
symbol), the #
symbol acts as a wildcard (these lines are wrapped as strings, more or less, and then fed to Cadabra).
In all other situations, #
behaves as in Python.
Aha!
I'll push a change for that shortly to my fork -- thanks for the clarification! 🙂
Okay, so there's still one edge-case caveat, namely comments which contain the tokens ::
or :=
. To illustrate this, consider the snippet:
I can't think of a simple way to differentiate ::
and :=
being used in code or in comment form (using just regex expressions).
By the way, are you still experiencing that MIME-type error?
Yes, I still have that mime type mismatch error, so I do not see any of the syntax colouring. My suspicion is that my jupyter installation (from pip) sends the codemirror files which come with it (and are stored somewhere below ~/.local
) correctly, but does not attach the right mime content type if the file is coming from /usr/local
. That's clearly a jupyter problem.
Summary
A quick bugfix for comment highlighting in the Jupyter kernel, and operator highlights for
?
and??
wildcards.Details
The old CodeMirror mode for Cadabra2 doesn't highlight uses of
#
correctly.I'm a little confused as to how comments are used in Cadabra2, given the
#
operator for indices, however, this commit ammends the CodeMirror lexer to define a comment as any string obeying^\s*#
, in accordance tofrom the manpage on input formats.
That is to say
and common uses like
will highlight correctly with
#
as an operator, with comments written on seperate lines: