Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/check-image-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function findMDXFiles(dir, fileList = []) {
function extractImageReferences(content, filePath) {
const images = [];

// Remove code blocks to avoid flagging example images
// Remove code blocks to avoid flagging example images in documentation
const contentWithoutCodeBlocks = removeCodeBlocks(content);

// Extract markdown images: ![alt](path)
Expand Down
7 changes: 3 additions & 4 deletions scripts/check-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ const CHECK_EXTERNAL = process.argv.includes('--external');

// Regex patterns for finding links
const MARKDOWN_LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/g;
const JSX_LINK_REGEX = /(?:href|src)=["']([^"']+)["']/g;
const JSX_LINK_REGEX = /href=["']([^"']+)["']/g;
const ANCHOR_REGEX = /#[^)\s"']*/;
const CODE_BLOCK_REGEX = /```[\s\S]*?```/g;

function removeCodeBlocks(content) {
// Replace code blocks with same number of newlines to preserve line numbers
return content.replace(CODE_BLOCK_REGEX, (match) => {
const newlineCount = (match.match(/\n/g) || []).length;
return '\n'.repeat(newlineCount);
Expand All @@ -45,7 +44,7 @@ function findMDXFiles(dir, fileList = []) {
function extractLinks(content, filePath) {
const links = [];

// Remove code blocks to avoid flagging example links
// Remove code blocks to avoid flagging example links in documentation
const contentWithoutCodeBlocks = removeCodeBlocks(content);

// Extract markdown links: [text](url)
Expand All @@ -59,7 +58,7 @@ function extractLinks(content, filePath) {
});
}

// Extract JSX links: href="..." or src="..."
// Extract JSX links: href="..."
while ((match = JSX_LINK_REGEX.exec(contentWithoutCodeBlocks)) !== null) {
links.push({
url: match[1],
Expand Down