import click


def title_string(
    original_string: str, underline: str = "=", transform: bool = True
) -> str:
    """
    Create a title string with underline barrier row (markdown style).

    :param original_string: The original string to turn to title
    :type original_string: str
    :param underline: Character to use as underline to the title
    :type underline: str
    :param transform: Transform first letter of each word to upper case
    :type transform: bool
    :return: Markdown title string
    :rtype: str
    """
    unstyled_string = click.unstyle(original_string)
    returned = (
        original_string.replace(unstyled_string, unstyled_string.title())
        if transform
        else original_string
    )
    returned += "\n" + underline * len(unstyled_string)
    return returned