def extract_embedded_image_files()

in migration/src/jira_util.py [0:0]


def extract_embedded_image_files(text: str, image_files: list[str]) -> set[str]:
    """Extract embedded image files in the given text.
    https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=images
    """
    # capture candidates for embedded images
    candidates = re.findall(REGEX_EMBEDDED_IMAGE, text)
    embedded_image_files = set([])
    for x in candidates:
        if x in image_files:
            # !xyz.png!
            embedded_image_files.add(x)
        elif any(map(lambda s: x.startswith(s + "|"), image_files)):
            # !xyz.png|styles!
            embedded_image_files.add(x.split("|", 1)[0])
    return embedded_image_files