Show More
@@ -14,6 +14,7 b'' | |||||
14 |
|
14 | |||
15 | import re |
|
15 | import re | |
16 | from IPython.utils import coloransi |
|
16 | from IPython.utils import coloransi | |
|
17 | from IPython.utils.text import strip_ansi | |||
17 |
|
18 | |||
18 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
19 | # Classes and functions |
|
20 | # Classes and functions | |
@@ -26,19 +27,6 b' __all__ = [' | |||||
26 | 'ansi2latex' |
|
27 | 'ansi2latex' | |
27 | ] |
|
28 | ] | |
28 |
|
29 | |||
29 | def strip_ansi(source): |
|
|||
30 | """ |
|
|||
31 | Remove ansi from text |
|
|||
32 |
|
||||
33 | Parameters |
|
|||
34 | ---------- |
|
|||
35 | source : str |
|
|||
36 | Source to remove the ansi from |
|
|||
37 | """ |
|
|||
38 |
|
||||
39 | return re.sub(r'\033\[(\d|;)+?m', '', source) |
|
|||
40 |
|
||||
41 |
|
||||
42 | ansi_colormap = { |
|
30 | ansi_colormap = { | |
43 | '30': 'ansiblack', |
|
31 | '30': 'ansiblack', | |
44 | '31': 'ansired', |
|
32 | '31': 'ansired', |
@@ -27,7 +27,7 b' from IPython.utils.path import compress_user' | |||||
27 | from IPython.utils.py3compat import bytes_to_str |
|
27 | from IPython.utils.py3compat import bytes_to_str | |
28 | from IPython.utils.sysinfo import get_sys_info |
|
28 | from IPython.utils.sysinfo import get_sys_info | |
29 | from IPython.utils.tempdir import TemporaryDirectory |
|
29 | from IPython.utils.tempdir import TemporaryDirectory | |
30 |
from IPython. |
|
30 | from IPython.utils.text import strip_ansi | |
31 |
|
31 | |||
32 | try: |
|
32 | try: | |
33 | # Python >= 3.3 |
|
33 | # Python >= 3.3 |
@@ -491,6 +491,17 b' def strip_email_quotes(text):' | |||||
491 | text = '\n'.join([ ln[strip:] for ln in lines]) |
|
491 | text = '\n'.join([ ln[strip:] for ln in lines]) | |
492 | return text |
|
492 | return text | |
493 |
|
493 | |||
|
494 | def strip_ansi(source): | |||
|
495 | """ | |||
|
496 | Remove ansi escape codes from text. | |||
|
497 | ||||
|
498 | Parameters | |||
|
499 | ---------- | |||
|
500 | source : str | |||
|
501 | Source to remove the ansi from | |||
|
502 | """ | |||
|
503 | return re.sub(r'\033\[(\d|;)+?m', '', source) | |||
|
504 | ||||
494 |
|
505 | |||
495 | class EvalFormatter(Formatter): |
|
506 | class EvalFormatter(Formatter): | |
496 | """A String Formatter that allows evaluation of simple expressions. |
|
507 | """A String Formatter that allows evaluation of simple expressions. |
General Comments 0
You need to be logged in to leave comments.
Login now