Skip to content

Commit 4e10fbc

Browse files
author
Al Manning
committed
remove duplication in handle-error, escape link sources for qmds
1 parent 45553f3 commit 4e10fbc

File tree

4 files changed

+41
-313
lines changed

4 files changed

+41
-313
lines changed

src/publish/confluence/confluence.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
ContentAncestor,
3030
ContentBody,
3131
ContentBodyRepresentation,
32+
ContentChange,
3233
ContentChangeType,
3334
ContentCreate,
3435
ContentProperty,
@@ -721,18 +722,31 @@ async function publish(
721722
}
722723
};
723724

725+
const handleChangeError = (
726+
label: string,
727+
currentChange: ConfluenceSpaceChange,
728+
error: any
729+
) => {
730+
console.info(label, currentChange);
731+
if (isContentUpdate(currentChange) || isContentCreate(currentChange)) {
732+
console.info("currentChange.fileName", currentChange.fileName);
733+
// console.info("Value to Update", currentChange.body.storage.value);
734+
}
735+
console.error(error);
736+
if (EXIT_ON_ERROR) {
737+
throw error;
738+
}
739+
};
740+
724741
for (let currentChange of changeList) {
725742
try {
726743
await doChange(currentChange);
727744
} catch (error: any) {
728-
console.info("Error Performing Change Pass 1", currentChange);
729-
if (isContentUpdate(currentChange) || isContentCreate(currentChange)) {
730-
console.info("Value to Update", currentChange.body.storage.value);
731-
}
732-
console.error(error);
733-
if (EXIT_ON_ERROR) {
734-
throw error;
735-
}
745+
handleChangeError(
746+
"Error Performing Change Pass 1",
747+
currentChange,
748+
error
749+
);
736750
}
737751
}
738752

@@ -755,18 +769,11 @@ async function publish(
755769
try {
756770
await doChange(currentChange, false);
757771
} catch (error: any) {
758-
//TODO remove duplication
759-
console.info("Error Performing Change Pass 2", currentChange);
760-
if (
761-
isContentUpdate(currentChange) ||
762-
isContentCreate(currentChange)
763-
) {
764-
console.info("Value to Update", currentChange.body.storage.value);
765-
}
766-
console.error(error);
767-
if (EXIT_ON_ERROR) {
768-
throw error;
769-
}
772+
handleChangeError(
773+
"Error Performing Change Pass 2",
774+
currentChange,
775+
error
776+
);
770777
}
771778
}
772779
}

src/resources/extensions/quarto/confluence/overrides.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function dumpObject(o)
3838
end
3939
end
4040

41-
function dump(object, label)
41+
function dump(label, object)
4242
print(label or '' .. ': ', dumpObject(object))
4343
end
4444

@@ -108,14 +108,13 @@ function LinkConfluence(source, target, title, attr)
108108
if(not startsWith(target,"http") and (not string.find(target, ".qmd"))) then
109109
return interpolate {
110110
LINK_ATTACHMENT_SNIPPET,
111-
source = source,
111+
source = escape(source),
112112
target = target,
113113
doubleBraket = "]]"
114114
}
115115
end
116-
117-
return "<a href='" .. escape(target,true) .. "' title='" ..
118-
escape(title,true) .. "'>" .. escape(source, false) .. "</a>"
116+
return "<a href='" .. escape(target,true) .. "' title='" ..
117+
escape(title,true) .. "'>" .. escape(source, false) .. "</a>"
119118
end
120119

121120
function CodeBlockConfluence(codeValue, languageValue)

src/resources/extensions/quarto/confluence/publish-classic.lua

Lines changed: 0 additions & 284 deletions
This file was deleted.

0 commit comments

Comments
 (0)