fixes and functions

This commit is contained in:
Mateusz Gruszczyński
2026-08-04 23:21:27 +02:00
parent 6fc408ddf7
commit 4b25085bb5
28 changed files with 306 additions and 330 deletions
-20
View File
@@ -100,26 +100,6 @@ export function buildImageAlias(options = {}) {
return `[${kind}=${filename},${parts.join(",")}]`;
}
export function updateImageAliasInLine(line, aliasIndex, patch = {}) {
const source = String(line || "");
const targetIndex = Number(aliasIndex);
if (!Number.isInteger(targetIndex) || targetIndex < 0) return null;
const codeRanges = inlineCodeRanges(source);
let index = 0;
let changed = false;
const value = source.replace(imageAliasPattern(), (match, ...args) => {
const offset = args.at(-2);
if (isInsideRange(offset, codeRanges) || index++ !== targetIndex) return match;
const parsed = parseImageAlias(match);
if (!parsed) return match;
changed = true;
return buildImageAlias({ ...parsed, ...patch });
});
return changed ? value : null;
}
export function updateImageAliasInLineBySource(line, aliasSource, occurrence = 0, patch = {}) {
const source = String(line || "");
const target = String(aliasSource || "");