indent
- mdtools.file_handler.indent(text, amount, char=' ')[source]
Indent a text by a given amount.
Pad every line of text with as many instances of char as given by amount. Lines in text are identified by Python’s string method
str.splitlines()
.- Parameters:
- Returns:
indented_text (
str
) – The input text with every line padded by the given amount of padding characters.
Examples
>>> s = "Hello, World!\n It's me, Mario!" >>> print(s) Hello, World! It's me, Mario! >>> print(mdt.fh.indent(s, amount=4)) Hello, World! It's me, Mario! >>> print(mdt.fh.indent(s, amount=1, char="# ")) # Hello, World! # It's me, Mario!