Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

Keep a citation after a comparison assessment out of the cell text

tt-a1if04c6c9e8753
diff --git a/archify/explainer/parse.mjs b/archify/explainer/parse.mjs
index 33019da2..c08b6ac6 100644
--- a/archify/explainer/parse.mjs
+++ b/archify/explainer/parse.mjs
@@ -220,8 +220,9 @@ export function parseExplainer(sourceText, { inputPath, output } = {}) {
}
}
function assessment(text) {
- const match = text.match(/^(.*?)\s*\{(good|caution|bad)(?::([^}]+))?\}$/u);
- return match?{text:match[1].trim(),assessment:match[2],...(match[3]?{verdict:match[3].trim()}:{})}:{text};
+ // Citations may follow the assessment; they stay with the cell text.
+ const match = text.match(/^(.*?)\s*\{(good|caution|bad)(?::([^}]+))?\}((?:\s*\[[^\]]*\]\([^)\s]*\))*)\s*$/u);
+ return match?{text:`${match[1].trim()}${match[4].trim()}`,assessment:match[2],...(match[3]?{verdict:match[3].trim()}:{})}:{text};
}
while(cursor<lines.length) {
const at=cursor, trimmed=lines[at].trim();
diff --git a/test/explainer-parser.test.mjs b/test/explainer-parser.test.mjs
index 52e67ac8..4a1627d8 100644
--- a/test/explainer-parser.test.mjs
+++ b/test/explainer-parser.test.mjs
@@ -157,3 +157,11 @@ test('a callout may take the following paragraph and may share its panel ID with
assert.equal(callout.text,'Do not pay before checking the deed.\nAsk for the owner ID.');
assert.equal(parseExplainer('# T\n\nA.\n\n## Q {#flow}\n\n@sequence id=flow\n| a | b | hi |').document,null,'a diagram keeps its ID, so a clash with its panel still fails');
});
+
+test('a comparison assessment may be followed by a citation',()=>{
+ const {document}=parse('# T\n\nA.\n\n@source law title="Civil code" url=https://example.com/law\n\n## Q {#q}\n\n| Who | Risk |\n| --- | --- |\n| Sublet | Can be ended {bad:Lose both} [](source:law) |');
+ const cell=document.panels[0].blocks[0].rows[0].cells[0];
+ assert.equal(cell.assessment,'bad');
+ assert.equal(cell.verdict,'Lose both');
+ assert.equal(cell.text,'Can be ended[](source:law)');
+});