-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow control of lexer used for syntax highlighting #180
Comments
AFAIR the lexer isn't hardcoded, the line you refer to is just providing the custom ipython lexer to sphinx. jupyter-sphinx infers the lexer from kernel metadata. Therefore, I think, you need to register a custom ipython kernel (kernels already have a pygments lexer metadata entry) that executes your code, and then also add your lexer to sphinx. Does that sound like a reasonable approach? |
Hi @akhmerov, I'm on the same team as @SeanDS. Thanks for the help! I've got things working locally doing it this way, but there seemed to be a few issues in Firstly, the
Fixing this then causes syntax highlighting to break, as the line here defines the wrong name - it should be After fixing both of these the highlighting works as intended, and for example in the html output, normal jupyter-execute blocks now have a class of Hopefully this makes sense and I've understood what's going on. I can open a pull request if you want, but it's only a two line change. Thanks again for the help! |
@philj56 thanks for following through! Your description sounds correct, and I'd really appreciate a PR with the fixes. |
No problem, it's #181 |
Looks like it! Thanks. EDIT: any idea when the next release will be? Keen to use @philj56's fix! |
I use
jupyter-sphinx
to show examples using Python to execute an application-specific language:This gets rendered like this:
I've got a pygments syntax highlighter that can handle highlighting our special syntax inside the string, inside Python code. I would like to change the lexer type used by Sphinx for the cell that gets compiled. This would make it render like this:
Currently the lexer used by
jupyter-sphinx
is hard-coded here. Is it possible to change this on a per-cell basis?The text was updated successfully, but these errors were encountered: