IJulia.jl icon indicating copy to clipboard operation
IJulia.jl copied to clipboard

ipython nbconvert ignoring syntax highlighting

Open malmaud opened this issue 11 years ago • 8 comments

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.

malmaud avatar Oct 31 '13 06:10 malmaud

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.

Carreau avatar Oct 31 '13 08:10 Carreau

Thanks.

malmaud avatar Oct 31 '13 15:10 malmaud

@Carreau, just wanted to check where we are with this. I appreciate the effort.

malmaud avatar Nov 12 '13 17:11 malmaud

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.

Carreau avatar Nov 12 '13 17:11 Carreau

Can't it get the language from the notebook? We are setting the metadata.language to Julia ....

stevengj avatar Nov 12 '13 18:11 stevengj

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.)

Carreau avatar Nov 12 '13 18:11 Carreau

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.

houshuang avatar Jan 03 '14 04:01 houshuang

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.

t-makaro avatar Aug 24 '18 22:08 t-makaro