##// END OF EJS Templates
Merge pull request #1490 from minrk/raw...
Merge pull request #1490 from minrk/raw rename plaintext cell -> raw cell Raw cells should be *untransformed* when writing various output formats, as the point of them is to let users pass through IPython to their rendered document format (rst, latex, etc.). This is different from what is the logical meaning of 'plaintext', which would suggest that the contents should be preserved as unformatted plaintext (e.g. in a `<pre>` tag, or literal block). In the UI, these cells will be displayed as 'Raw Text'. WARNING: any existing v3 notebooks which use plaintext cells, when read in by versions after this merge, will silently rename those cells to 'raw'. But if such a notebook is uploaded into a pre-merge IPython, cells labeled as 'raw' will simply *not be displayed*.

File last commit:

r4872:34c10438
r6480:a0e0f391 merge
Show More
ext_rescapture.py
59 lines | 1.3 KiB | text/x-python | PythonLexer
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151 # -*- coding: utf-8 -*-
Bernardo B. Marques
remove all trailling spaces
r4872 """ IPython extension: new prefilters for output grabbing
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
Bernardo B. Marques
remove all trailling spaces
r4872 Provides
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
var = %magic blah blah
var = !ls
"""
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 from IPython.core import ipapi
Brian Granger
Continuing a massive refactor of everything.
r2205 from IPython.core.error import TryNext
Brian Granger
Work to address the review comments on Fernando's branch....
r2498 from IPython.utils.text import make_quoted_expr
Brian Granger
genutils.py => utils/genutils.py and updated imports and tests.
r2023 from IPython.utils.genutils import *
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 ip = ipapi.get()
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
import re
def hnd_magic(line,mo):
""" Handle a = %mymagic blah blah """
var = mo.group('varname')
cmd = mo.group('cmd')
expr = make_quoted_expr(cmd)
Brian Granger
Massive refactoring of of the core....
r2245 return itpl('$var = get_ipython().magic($expr)')
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def hnd_syscmd(line,mo):
""" Handle a = !ls """
var = mo.group('varname')
cmd = mo.group('cmd')
vivainio
var = !cmd is no longer verbose
r902 expr = make_quoted_expr(itpl("sc -l =$cmd"))
Brian Granger
Massive refactoring of of the core....
r2245 return itpl('$var = get_ipython().magic($expr)')
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def install_re_handler(pat, hnd):
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 ip.meta.re_prefilters.append((re.compile(pat), hnd))
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
def init_handlers():
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 ip.meta.re_prefilters = []
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
install_re_handler('(?P<varname>[\w\.]+)\s*=\s*%(?P<cmd>.*)',
hnd_magic
)
Bernardo B. Marques
remove all trailling spaces
r4872
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151 install_re_handler('(?P<varname>[\w\.]+)\s*=\s*!(?P<cmd>.*)',
hnd_syscmd
)
init_handlers()
Brian Granger
First go an implementing a=!ls and a=%who syntax....
r2256 def regex_prefilter_f(self,line):
fperez
Defaults rename, clean up api to use properties or direct access rather than...
r284 for pat, handler in ip.meta.re_prefilters:
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151 mo = pat.match(line)
if mo:
return handler(line,mo)
Bernardo B. Marques
remove all trailling spaces
r4872
Brian Granger
Continuing a massive refactor of everything.
r2205 raise TryNext
vivainio
a = !ls, a = %alias now work (captures output or gets ret val for aliases)...
r151
Bernardo B. Marques
remove all trailling spaces
r4872 ip.set_hook('input_prefilter', regex_prefilter_f)