Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Module: nbconvert.filters.strings¶
String filters.
Contains a collection of useful string manipulation filters for use in Jinja templates.
13 Functions¶
-
IPython.nbconvert.filters.strings.wrap_text(text, width=100)¶ Intelligently wrap text. Wrap text without breaking words if possible.
Parameters: text : str
Text to wrap.
width : int, optional
Number of characters to wrap to, default 100.
-
IPython.nbconvert.filters.strings.html2text(element)¶ extract inner text from html
Analog of jQuery’s $(element).text()
-
IPython.nbconvert.filters.strings.add_anchor(html)¶ Add an anchor-link to an html header
For use on markdown headings
-
IPython.nbconvert.filters.strings.add_prompts(code, first='>>> ', cont='... ')¶ Add prompts to code snippets
-
IPython.nbconvert.filters.strings.strip_dollars(text)¶ Remove all dollar symbols from text
Parameters: text : str
Text to remove dollars from
-
IPython.nbconvert.filters.strings.strip_files_prefix(text)¶ Fix all fake URLs that start with
files/, stripping out thefiles/prefix. Applies to both urls (for html) and relative paths (for markdown paths).Parameters: text : str
Text in which to replace ‘src=”files/real...’ with ‘src=”real...’
-
IPython.nbconvert.filters.strings.comment_lines(text, prefix='# ')¶ Build a Python comment line from input text.
Parameters: text : str
Text to comment out.
prefix : str
Character to append to the start of each line.
-
IPython.nbconvert.filters.strings.get_lines(text, start=None, end=None)¶ Split the input text into separate lines and then return the lines that the caller is interested in.
Parameters: text : str
Text to parse lines from.
start : int, optional
First line to grab from.
end : int, optional
Last line to grab from.
-
IPython.nbconvert.filters.strings.ipython2python(code)¶ Transform IPython syntax to pure Python syntax
Parameters: code : str
IPython code, to be transformed to pure Python
-
IPython.nbconvert.filters.strings.posix_path(path)¶ Turn a path into posix-style path/to/etc
Mainly for use in latex on Windows, where native Windows paths are not allowed.
-
IPython.nbconvert.filters.strings.path2url(path)¶ Turn a file path into a URL
-
IPython.nbconvert.filters.strings.ascii_only(s)¶ ensure a string is ascii
-
IPython.nbconvert.filters.strings.prevent_list_blocks(s)¶ Prevent presence of enumerate or itemize blocks in latex headings cells
