Show More
@@ -49,6 +49,13 b' def wrap(text, width=100):' | |||||
49 | wrpd = map('\n'.join, wrp) |
|
49 | wrpd = map('\n'.join, wrp) | |
50 | return '\n'.join(wrpd) |
|
50 | return '\n'.join(wrpd) | |
51 |
|
51 | |||
|
52 | def single_line(text): | |||
|
53 | """Wrap multi-line text into a single line | |||
|
54 | ||||
|
55 | Used in markdown heading cells, which are not allowed to be multiline. | |||
|
56 | """ | |||
|
57 | return ''.join(text.splitlines()) | |||
|
58 | ||||
52 |
|
59 | |||
53 | def strip_dollars(text): |
|
60 | def strip_dollars(text): | |
54 | """ |
|
61 | """ |
@@ -24,7 +24,7 b' from IPython.utils.py3compat import cast_bytes' | |||||
24 | # Classes and functions |
|
24 | # Classes and functions | |
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
26 |
|
26 | |||
27 | def pandoc(source, fmt, to, encoding='utf-8'): |
|
27 | def pandoc(source, fmt, to, extra_args=None, encoding='utf-8'): | |
28 | """Convert an input string in format `from` to format `to` via pandoc. |
|
28 | """Convert an input string in format `from` to format `to` via pandoc. | |
29 |
|
29 | |||
30 | This function will raise an error if pandoc is not installed. |
|
30 | This function will raise an error if pandoc is not installed. | |
@@ -44,7 +44,10 b" def pandoc(source, fmt, to, encoding='utf-8'):" | |||||
44 | out : unicode |
|
44 | out : unicode | |
45 | Output as returned by pandoc. |
|
45 | Output as returned by pandoc. | |
46 | """ |
|
46 | """ | |
47 |
|
|
47 | command = ['pandoc', '-f', fmt, '-t', to] | |
|
48 | if extra_args: | |||
|
49 | command = command + extra_args | |||
|
50 | p = subprocess.Popen(command, | |||
48 | stdin=subprocess.PIPE, stdout=subprocess.PIPE |
|
51 | stdin=subprocess.PIPE, stdout=subprocess.PIPE | |
49 | ) |
|
52 | ) | |
50 | out, _ = p.communicate(cast_bytes(source, encoding)) |
|
53 | out, _ = p.communicate(cast_bytes(source, encoding)) |
General Comments 0
You need to be logged in to leave comments.
Login now