Skip to content

[code_prettify] added support for IPython magics, cf #1018#1019

Merged
jfbercher merged 2 commits intoipython-contrib:masterfrom
jfbercher:code_prettify
Jul 14, 2017
Merged

[code_prettify] added support for IPython magics, cf #1018#1019
jfbercher merged 2 commits intoipython-contrib:masterfrom
jfbercher:code_prettify

Conversation

@jfbercher
Copy link
Copy Markdown
Member

To support IPython magics in python code cells, a function yapf_reformat is defined and automatically loaded at initialization as a library. This function takes care of commenting magics before reformatting and uncommenting them after. This should fix #1018.

@catch22
Copy link
Copy Markdown

catch22 commented Jul 11, 2017

Thanks, this PR works well for me.

@EWouters
Copy link
Copy Markdown
Contributor

I noticed that 2to3 has no problem with cell magics without yapf_reformat for some reason unknown to me, but in autopep8 %%something will get returned as % % something.

Would it be a good idea to add this to the KernelExecOnCells library somehow? I guess we don't want kernel specific code in there, but handling cell magics is a problem any python extension will face when using the library.

I guess the best thing would be to write some js code that handles cell magics so it works for all kernels.

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 this pull request may close these issues.

Code_prettify does not recognize IPython magic commands

3 participants