From 4f1a3b5f9ad05aa7b08715d48909a2b06ee2fcb1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 18:35:31 +0200 Subject: Adding upstream version 3.0.43. Signed-off-by: Daniel Baumann --- examples/print-text/html.py | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 examples/print-text/html.py (limited to 'examples/print-text/html.py') diff --git a/examples/print-text/html.py b/examples/print-text/html.py new file mode 100755 index 0000000..5276fe3 --- /dev/null +++ b/examples/print-text/html.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python +""" +Demonstration of how to print using the HTML class. +""" +from prompt_toolkit import HTML, print_formatted_text + +print = print_formatted_text + + +def title(text): + print(HTML("\n{}").format(text)) + + +def main(): + title("Special formatting") + print(HTML(" Bold")) + print(HTML(" Blink")) + print(HTML(" Italic")) + print(HTML(" Reverse")) + print(HTML(" Underline")) + print(HTML(" Strike")) + print(HTML(" Hidden (hidden)")) + + # Ansi colors. + title("ANSI colors") + + print(HTML(" ANSI Red")) + print(HTML(" ANSI Blue")) + + # Other named colors. + title("Named colors") + + print(HTML(" orange")) + print(HTML(" purple")) + + # Background colors. + title("Background colors") + + print(HTML(' ')) + print(HTML(' ')) + + # Interpolation. + title("HTML interpolation (see source)") + + print(HTML(" {}").format("")) + print(HTML(" {text}").format(text="")) + print(HTML(" %s") % ("",)) + + print() + + +if __name__ == "__main__": + main() -- cgit v1.2.3