You can use extensions or display
helpers in IPython to make whatever syntax highlighting you\'d like on output cells.
For some special cell magics, like
For recent IPython version, the selected answer no longer works. The 'config_default' property was renamed options_default (Ipython 6.0.0). The following works:
import IPython
js = "IPython.CodeCell.options_default.highlight_modes['magic_fortran'] = {'reg':[/^%%fortran/]};"
IPython.core.display.display_javascript(js, raw=True)
To replace IPython.config.cell_magic_highlight
, you can use something like
import IPython
js = "IPython.CodeCell.config_defaults.highlight_modes['magic_fortran'] = {'reg':[/^%%fortran/]};"
IPython.core.display.display_javascript(js, raw=True)
so cells which begin with %%fortran
will be syntax-highlighted like FORTRAN. (However, they will still be evaluated as python if you do only this.)