def section(self, heading, paragraphs, delimiter='\n\n'): heading = Ansi.bold(heading.upper()) body = list() for paragraph in paragraphs: paragraph.indent(self._indent_unit) body.append(self.wrap(paragraph)) body = delimiter.join(body) return "{heading}\n{body}".format(heading=heading, body=body)
def test_multiple_bold_words(self): self.assert_process("multiple *bold* words *inside* text", "multiple {bold} words {inside} text".format(bold=Ansi.bold("bold"), inside=Ansi.bold("inside")))
def test_escaped_backslash_in_front_of_bold(self): self.assert_process("escaped \\\\*backslash* before bold", "escaped \\{backslash} before bold".format(backslash=Ansi.bold("backslash")))
def test_escaped_symbols_in_bold_text(self): self.assert_process("escaped *symbols \\\\ \\* inside* bold text", "escaped {symbols_inside} bold text".format( symbols_inside=Ansi.bold("symbols \\ * inside")))
def test_multiple_bold_before_unmatched_asterisk(self): self.assert_process("*first* and *second* before *unmatched", "{first} and {second} before *unmatched".format(first=Ansi.bold("first"), second=Ansi.bold("second")))
def test_matched_before_unmatched_asterisk(self): self.assert_process("*matched* before *unmatched", "{matched} before *unmatched".format(matched=Ansi.bold("matched")))
def test_escaped_and_matched_asterisk(self): self.assert_process("\\*escaped and *matched* asterisk", "*escaped and {matched} asterisk".format(matched=Ansi.bold("matched")))
def test_bold_word(self): self.assert_process("a bold *word* inside", "a bold {word} inside".format(word=Ansi.bold("word")))