import re


def add_custom_directives(html: str) -> str:
    """Helper to add custom RST directives into rendered HTML."""

    directives = [
        # [[secret="title"]]
        {
            "old": "<p>\[\[secret=\"([0-9a-zA-Z_.]+)\"\]\]</p>",
            "new": "<details>\n<summary>\\1</summary>",
        },
        # [[/secret]]
        {
            "old": "<p>\[\[/secret\]\]</p>",
            "new": "</details>"
        },
    ]

    for d in directives:
        html = re.sub(d["old"], d["new"], html)
    return html