fixed alt text handling
This commit is contained in:
@@ -247,7 +247,7 @@ export class ImportAnalysisEngine {
|
|||||||
// - Otherwise, use the original image src
|
// - Otherwise, use the original image src
|
||||||
const imageUrl = hrefIsImage ? href : imgSrc;
|
const imageUrl = hrefIsImage ? href : imgSrc;
|
||||||
|
|
||||||
// Derive alt text: prefer alt, then title, then filename
|
// Derive alt text: prefer alt, then title, then cleaned filename
|
||||||
let altText = imgAlt.trim();
|
let altText = imgAlt.trim();
|
||||||
if (!altText) {
|
if (!altText) {
|
||||||
altText = imgTitle.trim();
|
altText = imgTitle.trim();
|
||||||
@@ -256,13 +256,11 @@ export class ImportAnalysisEngine {
|
|||||||
// Extract filename from the image URL as last resort
|
// Extract filename from the image URL as last resort
|
||||||
const urlPath = imageUrl.split('?')[0]; // Remove query string
|
const urlPath = imageUrl.split('?')[0]; // Remove query string
|
||||||
const filename = urlPath.split('/').pop() || '';
|
const filename = urlPath.split('/').pop() || '';
|
||||||
altText = filename;
|
// Clean the filename: remove extension and replace underscores with spaces
|
||||||
|
altText = filename.replace(/\.[^.]+$/, '').replace(/_/g, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the markdown image link
|
// Build the markdown image link (without title attribute)
|
||||||
if (imgTitle) {
|
|
||||||
return ``;
|
|
||||||
}
|
|
||||||
return ``;
|
return ``;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ export class ImportExecutionEngine extends EventEmitter {
|
|||||||
// - Otherwise, use the original image src
|
// - Otherwise, use the original image src
|
||||||
const imageUrl = hrefIsImage ? href : imgSrc;
|
const imageUrl = hrefIsImage ? href : imgSrc;
|
||||||
|
|
||||||
// Derive alt text: prefer alt, then title, then filename
|
// Derive alt text: prefer alt, then title, then cleaned filename
|
||||||
let altText = imgAlt.trim();
|
let altText = imgAlt.trim();
|
||||||
if (!altText) {
|
if (!altText) {
|
||||||
altText = imgTitle.trim();
|
altText = imgTitle.trim();
|
||||||
@@ -170,13 +170,11 @@ export class ImportExecutionEngine extends EventEmitter {
|
|||||||
// Extract filename from the image URL as last resort
|
// Extract filename from the image URL as last resort
|
||||||
const urlPath = imageUrl.split('?')[0]; // Remove query string
|
const urlPath = imageUrl.split('?')[0]; // Remove query string
|
||||||
const filename = urlPath.split('/').pop() || '';
|
const filename = urlPath.split('/').pop() || '';
|
||||||
altText = filename;
|
// Clean the filename: remove extension and replace underscores with spaces
|
||||||
|
altText = filename.replace(/\.[^.]+$/, '').replace(/_/g, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the markdown image link
|
// Build the markdown image link (without title attribute)
|
||||||
if (imgTitle) {
|
|
||||||
return ``;
|
|
||||||
}
|
|
||||||
return ``;
|
return ``;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user