Skip to content
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

nbconvert: use r pygmentize backend when highlighting "%%R" cells #4184

Closed
pablooliveira opened this issue Sep 9, 2013 · 5 comments · Fixed by #4187
Closed

nbconvert: use r pygmentize backend when highlighting "%%R" cells #4184

pablooliveira opened this issue Sep 9, 2013 · 5 comments · Fixed by #4187
Milestone

Comments

@pablooliveira
Copy link
Contributor

It would be very nice to have R syntax highlighting on cells using the '%%R' magic when using nbconvert.

Tested on:

{'codename': 'An Afternoon Hack',
 'commit_hash': '59d4731',
 'commit_source': 'repository',
 'default_encoding': 'UTF-8',
 'ipython_path': '$HOME/ipython/IPython',
 'ipython_version': '2.0.0-dev',
 'os_name': 'posix',
 'platform': 'Linux-3.9-0.bpo.1-amd64-x86_64-with-debian-7.1',
 'sys_executable': '/usr/bin/python',
 'sys_platform': 'linux2',
 'sys_version': '2.7.3 (default, Jan  2 2013, 13:56:14) \n[GCC 4.7.2]'}
@Carreau
Copy link
Member

Carreau commented Sep 9, 2013

That's true for many things like %%cython, %perl... That might be dooable using preprocessors and filters.
Want to give a try and make a PR ?

@pablooliveira
Copy link
Contributor Author

Sure, I will give it a try, but I know very little about IPython architecture.
Would you have time to review my pull request?

Thanks,

Pablo

@Carreau
Copy link
Member

Carreau commented Sep 9, 2013

Sure, wherever the PR come from, it will be reviewed, we don't treat regular of new user differently. Just ask if we are not clear on how to do things, it is often hard to judge how people are used to code.

You will probably need an heuristic in nbconvert preprocessor that inspect the cell source and decide for a highlighting scheme, stuff this in metadata along with the cell, and use those metadata to feed them to the hightlight filter in templates.

@jdfreder should also be able to help you too.

pablooliveira added a commit to pablooliveira/ipython that referenced this issue Sep 18, 2013
Detect cells that use language extension magics such as %%R or %%bash
and call the appropriate pygmentize lexer.

Closes ipython#4184
@mgaitan
Copy link
Contributor

mgaitan commented Sep 19, 2013

The extension Fortran magic monkeypatch the javascript IPython.config to use codemirro'r fortran mode in the cell, but nbconvert has no notion of this.

Shoudn't (this)[https://github.com/pablooliveira/ipython/blob/009a294cba472233585a4c1dbbbba6e3cfc2cb59/IPython/nbconvert/filters/highlight.py#L34] dictionary populate dinamically ?

@pablooliveira
Copy link
Contributor Author

You can use the HighlightMagicsPreprocessor.languages configuration to add fortran to this dictionary when using Fortran magic plugin.
(see #4187 for the details). Is that good enough ?

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Detect cells that use language extension magics such as %%R or %%bash
and call the appropriate pygmentize lexer.

Closes ipython#4184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants