feat: convert non-image markdown links to readable filenames in Discord
[BuildPanel.tsx](/long/path#L320) → `BuildPanel.tsx:320` Keeps Discord output clean since local paths aren't clickable anyway.
This commit is contained in:
@@ -323,9 +323,15 @@ export class DiscordChannel implements Channel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let cleaned = text
|
let cleaned = text
|
||||||
.replace(MD_LINK_RE, (full, p) =>
|
.replace(MD_LINK_RE, (full, p, _offset, _str, groups) => {
|
||||||
IMAGE_EXTS.test(p) && seen.has(p.trim()) ? '' : full,
|
const trimmed = p.trim();
|
||||||
)
|
// Image links: remove entirely (attached as files)
|
||||||
|
if (IMAGE_EXTS.test(trimmed) && seen.has(trimmed)) return '';
|
||||||
|
// Non-image local path links: convert to readable filename
|
||||||
|
const basename = path.basename(trimmed.replace(/#.*$/, ''));
|
||||||
|
const lineMatch = trimmed.match(/#L(\d+)/);
|
||||||
|
return lineMatch ? `\`${basename}:${lineMatch[1]}\`` : `\`${basename}\``;
|
||||||
|
})
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
// Convert @username mentions to Discord mention format
|
// Convert @username mentions to Discord mention format
|
||||||
|
|||||||
Reference in New Issue
Block a user