def fix_media_src(filestr, dirname, dest):
    'Fix the (relative) path to any figure and movie in the DocOnce file.\n\n    The generated .md and .ipynb files will be created in the path passed to `--dest`.\n    This method fixes the paths of the image and movie files so that they can be found\n    in generated .md and .ipynb files.\n    :param str filestr: text string\n    :param str dirname: Path to an existing folder\n    :param str dest: directory name\n    :return: filestr with new paths\n    :rtype: str\n    '
    patterns = [movie2html['movie_regex'], '\\!\\[<p><em>(.*)</em></p>\\]\\((.*)\\)', img2ipynb['imgtag_regex'], img2ipynb['md_regex'], '<!-- (?:dom:)(FIGURE|MOVIE): \\[(.*)', '<!-- <(\\w+) src="(.*)" .*>(?=[<|\\\\n])']
    filestr_out = filestr
    for (i, pattern) in enumerate(patterns):
        for m in re.finditer(pattern, filestr):
            match = m.group()
            tag = m.group(1)
            src = m.group(2)
            if (pattern == movie2html['movie_regex']):
                errwarn('*** warning : To make images work consider to add this extensions to _config.yml:\n', 'parse:\n  myst_enable_extensions:\n    - html_image\n')
            if (not src.startswith('/')):
                if ((dirname != '') and (not dirname.endswith('/'))):
                    dirname += '/'
                src_new = os.path.relpath((dirname + src), start=dest)
                replacement = match.replace(src, src_new, 1)
                filestr_out = filestr_out.replace(match, replacement, 1)
    return filestr_out
Fix the (relative) path to any figure and movie in the DocOnce file.

The generated .md and .ipynb files will be created in the path passed to `--dest`.
This method fixes the paths of the image and movie files so that they can be found
in generated .md and .ipynb files.
:param str filestr: text string
:param str dirname: Path to an existing folder
:param str dest: directory name
:return: filestr with new paths
:rtype: str
def fix_media_src(filestr, dirname, dest):
    'Fix the (relative) path to any figure and movie in the DocOnce file.\n\n    The generated .md and .ipynb files will be created in the path passed to `--dest`.\n    This method fixes the paths of the image and movie files so that they can be found\n    in generated .md and .ipynb files.\n    :param str filestr: text string\n    :param str dirname: Path to an existing folder\n    :param str dest: directory name\n    :return: filestr with new paths\n    :rtype: str\n    '
    patterns = [movie2html['movie_regex'], '\\!\\[<p><em>(.*)</em></p>\\]\\((.*)\\)', img2ipynb['imgtag_regex'], img2ipynb['md_regex'], '<!-- (?:dom:)(FIGURE|MOVIE): \\[(.*)', '<!-- <(\\w+) src="(.*)" .*>(?=[<|\\\\n])']
    filestr_out = filestr
    for (i, pattern) in enumerate(patterns):
        for m in re.finditer(pattern, filestr):
            match = m.group()
            tag = m.group(1)
            src = m.group(2)
            if (pattern == movie2html['movie_regex']):
                errwarn('*** warning : To make images work consider to add this extensions to _config.yml:\n', 'parse:\n  myst_enable_extensions:\n    - html_image\n')
            if (not src.startswith('/')):
                if ((dirname != ) and (not dirname.endswith('/'))):
                    dirname += '/'
                src_new = os.path.relpath((dirname + src), start=dest)
                replacement = match.replace(src, src_new, 1)
                filestr_out = filestr_out.replace(match, replacement, 1)
    return filestr_out