import re


def make_spoiler_tags(line: str) -> str:
    """Find spoiler marks in string and replace them with <span class="spoiler"> tags."""
    return re.sub(
        r"""
            (?<![\w%]) 
            (%%) 
            (?![<>\s%]) 
            ([^<>]+?) 
            (?<![<>\s%]) 
            \1 
            (?![\w%])
        """,
        r'<span class="spoiler">\2</span>',
        line,
        flags=re.X
    )