2 years ago
#72307
MemoryWrangler
How do I apply syntax highlighting to a string literal in Code Mirror?
I'm writing a python library that operates on C++ code stored in string literals. The normal use case is to create a code
object like so:
code(r"""
void* foo() {
return NULL;
}
""")
The library is meant to work in Jupyter Lab which uses Code Mirror for syntax highlighting/editing, so I'd like to extend Code Mirror to identify calls to code()
and apply C++ syntax highlighting to its argument, so it'd look something like this:
code(r""" # python highlighting
void* foo() { // C++ higlighting
return NULL;
}
""")
I know how to do something similar in Pygments, but I'm not sure where to get started with Code Mirror.
jupyter-lab
codemirror
0 Answers
Your Answer