IJulia.jl
IJulia.jl copied to clipboard
ipython nbconvert ignoring syntax highlighting
If you run ipython nbconvert on a Julia notebook to get a static HTML or PDF version of it, it uses Python syntax highlighting instead of Julia highlighting. I have no idea what hooks we would have to engage with to change this.
I'm on it. It is possible on dev by passing a command line flag but not super easy.
Envoyé de mon iPhone
Le 31 oct. 2013 à 08:00, Jonathan Malmaud [email protected] a écrit :
If you run ipython nbconvert on a Julia notebook to get a static HTML or PDF version of it, it uses Python syntax highlighting instead of Julia highlighting. I have no idea what hooks we would have to engage with to change this.
— Reply to this email directly or view it on GitHub.
Thanks.
@Carreau, just wanted to check where we are with this. I appreciate the effort.
for now it is here : https://github.com/ipython/ipython/pull/4403
once this is merge you can call $ ipython nbconvert --NbConvertBase.default_language=julia
and it should work.
Or put c.NbConvertBase.default_language=julia
in you config.py and then use $ ipython nbconvert --profile=julia
And all the variations of per folder config, default config... end so on, and so forth.
Can't it get the language from the notebook? We are setting the metadata.language
to Julia
....
That's one of the issues a raise in the pull request, and language field will be spec on the next .ipynb
format.
for now I just bring the possibility to chose highlight language and will work on selecting language base on metadata later in a second pass. (smaller PR get faster through than big one that changes everything also.)
I'd love to see this - it's even more important for languages that diverge more from Python's syntax, like Haskell (example notebook) where it doesn't even recognize comments.
Edit: I found this issue through a Google search, and initially thought I was commenting on the main IPython repository, now I see it's the IJulia one. I'll still leave it in, since we're all after the same thing.
I'll been working on trying to make nbconvert's highlighting more customizable. Nbconvert will already automatically select the right lexer. The main problem that I've found is that the pygments JuliaLexer is not very good. I've noticed it misses function names, println is a builtin, and thinks that a comment with a double quote in it is the start of a string when it's not.
I'd love to make a pygments style that nicely reflects the style of IJulia, but the lexer is a blockade. Someone could try submitting a pull request over at pygments to improve the lexer, but it hasn't seen any movement in a while.