MCPcopy Create free account
hub / github.com/crisxuan/bestJavaer / extractFirstImage

Function extractFirstImage

assets/article-cards.js:928–938  ·  view source on GitHub ↗
(markdown, markdownPath)

Source from the content-addressed store, hash-verified

926 }
927
928 function extractFirstImage(markdown, markdownPath) {
929 var imagePattern = /!\[[^\]]*]\(([^)\s]+)(?:\s+["'][^"']*["'])?\)|<img[^>]+src=["']([^"']+)["'][^>]*>/ig;
930 var imageMatch = imagePattern.exec(markdown);
931 var src = imageMatch && (imageMatch[1] || imageMatch[2]);
932
933 if (src) {
934 return resolveImageSource(src, markdownPath);
935 }
936
937 return '';
938 }
939
940 function getCurrentRoute() {
941 return (window.location.hash || '#/').replace(/^#\/?/, '').split('?')[0];

Callers 1

getCoverFunction · 0.85

Calls 1

resolveImageSourceFunction · 0.85

Tested by

no test coverage detected