Skip to content

Latest commit

 

History

History
92 lines (69 loc) · 2.1 KB

File metadata and controls

92 lines (69 loc) · 2.1 KB

Text Box Wrapper

A simple Python package to wrap text with ASCII art or other characters. It also supports custom alignment (left, center, or right) and can be used as a decorator.

Installation

Install the package using pip:

pip install text-box-wrapper

Usage

Basic usage

Import the wrap_with_ascii_art function and use it to wrap your text:

from text_box_wrapper import wrap_with_ascii_art

text = "Hello, World!"
wrapped_text = wrap_with_ascii_art(text)
print(wrapped_text)

Example output:

###########################################
###########################################
#####                                 #####
#####                                 #####
#####          Hello, World!          #####
#####                                 #####
#####                                 #####
###########################################
###########################################

Customizing the wrapper

You can customize the padding, border string, and alignment:

from text_box_wrapper import wrap_with_ascii_art

text = "你好,成都"
border_string = "#"
wrapped_text = wrap_with_ascii_art(text, min_padding=5, vertical_padding=2, border_string=border_string, alignment="center")
print(wrapped_text)

Example output:

######################
#                    #
#                    #
#     你好,成都       #
#                    #
#                    #
######################

Using the decorator

You can also use the wrap decorator to automatically wrap the output of a function:

from text_box_wrapper import wrap

@wrap(min_padding=7, vertical_padding=1, border_string="*", alignment="center")
def greet(name):
    return f"Hello, {name}!"

print(greet("John"))

Example output:

****************************
*                          *
*       Hello, John!       *
*                          *
****************************

Contributing

Feel free to submit issues or pull requests if you have any suggestions, improvements, or bug reports.

License

This project is licensed under the MIT License.