def preprocess_cell(self, cell, resources, index):
        # path of notebook directory, relative to conf.py
        nb_path = Path(resources['metadata']['path']).relative_to(self.DOC_DIR)
        to_root = [os.pardir] * len(nb_path.parts)

        if cell.cell_type == 'markdown':
            text = cell.source
            replace = []
            for match in self.URL_PATTERN.finditer(text):
                path = to_root[:]
                path.append(match.group(1))

                rel_url = "/".join(path)
                filename = match.group(2)
                replace.append((match.group(0), '({}/{}.rst)'.format(rel_url, filename)))

            for s, r in replace:
                text = text.replace(s, r)
            cell.source = text
            return cell, resources
        return cell, resources