import re

_CODE_FENCE_RE = re.compile(r"```[\s\S]*?```|`[^`\n]+`")
_TAG_RE = re.compile(r"(?<!\w)#([\w][\w-]*(?:/[\w][\w-]*)*)")


def extract_tags(body: str) -> list[str]:
    """Extract #tags from body text, ignoring code blocks."""
    cleaned = _CODE_FENCE_RE.sub("", body)
    tags = _TAG_RE.findall(cleaned)
    return sorted(set(tags))
