extensions/markdown-language-features/src/languageFeatures/documentLinks.ts/extractDocumentLink
function extractDocumentLink(
	document: ITextDocument,
	pre: string,
	rawLink: string,
	matchIndex: number | undefined
): MdLink | undefined {
	const isAngleBracketLink = rawLink.startsWith('<');
	const link = stripAngleBrackets(rawLink);

	const offset = (matchIndex || 0) + pre.length + (isAngleBracketLink ? 1 : 0);
	const linkStart = document.positionAt(offset);
	const linkEnd = document.positionAt(offset + link.length);
	try {
		const linkTarget = resolveLink(document, link);
		if (!linkTarget) {
			return undefined;
		}
		return {
			kind: 'link',
			href: linkTarget,
			source: {
				text: link,
				resource: document.uri,
				hrefRange: new vscode.Range(linkStart, linkEnd),
				...getLinkSourceFragmentInfo(document, link, linkStart, linkEnd),
			}
		};
	} catch {
		return undefined;
	}
}