import re


def read_more(html, anchor):
    """Will truncate the text at the place the user left a [read_more] tag.

    This truncation will appear in the /index, /drafts and /search pages.
    The purpose is to make the listing of posts more brief.

    Parameters
    ----------
    html : class 'markupsafe.Markup'
        Html of the posts.
    anchor : class 'markupsafe.Markup'
        Anchor tag linking to the post detail.

    Returns
    -------
    f'{splitted_html[0]}{anchor}' : str
        Returns the html of the truncated post including the hyperlink
        leading to the detail of the post in full.
    html : class 'markupsafe.Markup'
        Returns the html of the post in full. Happens when no [read_more] tag
        is found.
    """
    splitted_html = re.split('\[read_more\]', html, maxsplit=1)
    if len(splitted_html) > 1:
        return f'{splitted_html[0]}{anchor}'
    return html