import re


def link_pull_requests(mkdwn, repo_shortname):
    """
    Links pull request mentions like #123 in a markdown string

    repo_shortname is the repository in org/repo format.
    """
    def replace_func(match):
        result = f'{match.group(1)}[{match.group(2)}](https://github.com/{repo_shortname}/pull/{match.group(3)})'
        return result

    result = re.sub(r'([^\[a-z0-9])(#([0-9]+))', replace_func, mkdwn)
    return result