Skip to content

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

Accept badge-only table cells and routes in the step node column

tt-a1i7d59301e5f9e
diff --git a/archify/explainer/parse.mjs b/archify/explainer/parse.mjs
index f8734a05..4b4edb62 100644
--- a/archify/explainer/parse.mjs
+++ b/archify/explainer/parse.mjs
@@ -196,7 +196,7 @@ export function parseExplainer(sourceText, { inputPath, output } = {}) {
case 'callout': rowWidth(rows,1,1,type);Object.assign(block,{level:a.level||'note',...select(a,['title']),text:a.text??rows.map(r=>r.cells[0]).join('\n')});break;
case 'facts':rowWidth(rows,2,2,type);block.entries=rows.map(r=>({key:r.cells[0],value:r.cells[1]}));break;
case 'metric':Object.assign(block,select(a,['label','unit','note']));for(const key of ['value','limit'])if(a[key]!==undefined)block[key]=number(a[key],at,type);if(a.typical!==undefined)block.typical=boolean(a.typical,at,type);break;
- case 'steps':rowWidth(rows,2,7,type);block.items=rows.map(r=>{const [id,text,detail,diagram,node,route,edges]=r.cells;const target=diagram?{diagram,...(node?{node}:{}),...(route?{route:route.split('~')}:{}),...(edges?{edges:csv(edges)}:{})}:undefined;if(!diagram&&(node||route||edges))fail(r.line+1,type,'A step node, route or edge reference needs its diagram ID.','| step | Read cache | | cache-flow | redis | | |');return{id,text,...(detail?{detail}:{}),...(target?{target}:{})};});break;
+ case 'steps':rowWidth(rows,2,7,type);block.items=rows.map(r=>{let [id,text,detail,diagram,node,route,edges]=r.cells;if(node?.includes('~')&&!route){route=node;node='';}const target=diagram?{diagram,...(node?{node}:{}),...(route?{route:route.split('~')}:{}),...(edges?{edges:csv(edges)}:{})}:undefined;if(!diagram&&(node||route||edges))fail(r.line+1,type,'A step node, route or edge reference needs its diagram ID.','| step | Read cache | | cache-flow | redis | | |');return{id,text,...(detail?{detail}:{}),...(target?{target}:{})};});break;
case 'diagram': {
if(positional.length!==1)fail(at+1,type,'A diagram requires exactly one native type.','@diagram sequence source=cache.sequence.json');
block.diagramType=positional[0];
@@ -225,7 +225,8 @@ export function parseExplainer(sourceText, { inputPath, output } = {}) {
function assessment(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};
+ // A cell holding only a badge ({bad:Drop}) shows the badge; its label doubles as the cell text.
+ return match?{text:`${match[1].trim()}${match[4].trim()}`||match[3]?.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/archify/explainer/reader.css b/archify/explainer/reader.css
index 3547845d..2a6a1a67 100644
--- a/archify/explainer/reader.css
+++ b/archify/explainer/reader.css
@@ -5,6 +5,7 @@
/* Base */
*{box-sizing:border-box}
+[hidden]{display:none!important}
body{margin:0;background:var(--paper);color:var(--secondary);font:14.5px/1.72 var(--sans);-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;font-feature-settings:"kern"}
h1,h2,h3,p,ul,ol,dl,dd,figure{margin:0}
strong,b{color:var(--ink);font-weight:600}
diff --git a/archify/explainer/render.mjs b/archify/explainer/render.mjs
index 4536b922..232e137f 100644
--- a/archify/explainer/render.mjs
+++ b/archify/explainer/render.mjs
@@ -47,7 +47,7 @@ export function renderExplainer(document, options = {}) {
case 'prose': body = block.text.split(/\n\s*\n/).map(text => `<p>${i(text)}</p>`).join(''); break;
case 'list': { const tag = block.ordered ? 'ol' : 'ul'; if (block.checklist) { body = `<ul class="checklist">${block.items.map(text => `<li><label><input type="checkbox"><span>${i(text)}</span></label></li>`).join('')}</ul>`; break; } body = `<${tag} class="text-list">${block.items.map(text => `<li>${i(text)}</li>`).join('')}</${tag}>`; break; }
case 'callout': body = `<aside class="callout ${escape(block.level)}">${block.title ? `<h3>${i(block.title)}</h3>` : ''}<p>${i(block.text)}</p></aside>`; break;
- case 'comparison': body = `<div class="table-scroll"><table><thead><tr><th scope="col">${block.labelColumn ? i(block.labelColumn) : ''}</th>${block.columns.map(text => `<th scope="col">${i(text)}</th>`).join('')}</tr></thead><tbody>${block.rows.map(row => `<tr id="${escape(row.id)}"><th scope="row">${i(row.label)}</th>${row.cells.map(cell => `<td>${cell.assessment ? `<span class="assessment ${escape(cell.assessment)}"><span class="assessment-meter" aria-hidden="true"><i></i><i></i><i></i></span><b>${i(cell.verdict || ({good:locale.startsWith('en')?'Favorable':'有利',caution:locale.startsWith('en')?'Tradeoff':'有代价',bad:locale.startsWith('en')?'Unfavorable':'不利'}[cell.assessment]))}</b></span>` : ''}<span class="cell-text">${i(cell.text)}</span></td>`).join('')}</tr>`).join('')}</tbody></table></div>`; break;
+ case 'comparison': body = `<div class="table-scroll"><table><thead><tr><th scope="col">${block.labelColumn ? i(block.labelColumn) : ''}</th>${block.columns.map(text => `<th scope="col">${i(text)}</th>`).join('')}</tr></thead><tbody>${block.rows.map(row => `<tr id="${escape(row.id)}"><th scope="row">${i(row.label)}</th>${row.cells.map(cell => `<td>${cell.assessment ? `<span class="assessment ${escape(cell.assessment)}"><span class="assessment-meter" aria-hidden="true"><i></i><i></i><i></i></span><b>${i(cell.verdict || ({good:locale.startsWith('en')?'Favorable':'有利',caution:locale.startsWith('en')?'Tradeoff':'有代价',bad:locale.startsWith('en')?'Unfavorable':'不利'}[cell.assessment]))}</b></span>` : ''}${cell.assessment && cell.text === cell.verdict ? '' : `<span class="cell-text">${i(cell.text)}</span>`}</td>`).join('')}</tr>`).join('')}</tbody></table></div>`; break;
case 'facts': body = `<dl class="facts">${block.entries.map(entry => `<div><dt>${i(entry.key)}</dt><dd>${i(entry.value)}</dd></div>`).join('')}</dl>`; break;
case 'metric': {
const over = block.value !== undefined && block.limit !== undefined && block.value > block.limit;
diff --git a/test/explainer-parser.test.mjs b/test/explainer-parser.test.mjs
index b4251941..fc1a4ff8 100644
--- a/test/explainer-parser.test.mjs
+++ b/test/explainer-parser.test.mjs
@@ -179,3 +179,9 @@ test('an authored page style is kept and limited to the shipped styles',()=>{
assert.equal(parse('# T\n\nA.\n\n@meta style=editorial\n\n## Q {#q}\n\nText.').document.meta.style,'editorial');
assert.equal(validateExplainer(parse('# T\n\nA.\n\n@meta style=neon\n\n## Q {#q}\n\nText.').document).ok,false);
});
+
+test('a badge-only comparison cell and a route written in the node column are accepted',()=>{
+ const {document}=parse('# T\n\nA.\n\n## Q {#q}\n\n| Trap | Verdict |\n| --- | --- |\n| Flood car | {bad:Drop} |\n\n@sequence id=flow\n| actor a | A |\n| actor b | B |\n| a | b | hi |\n\n@steps id=walk\n| one | Hello | Detail | flow | a~b |\n| two | Back | Detail | flow | b |');
+ assert.deepEqual(document.panels[0].blocks[0].rows[0].cells[0],{text:'Drop',assessment:'bad',verdict:'Drop'});
+ assert.deepEqual(document.panels[0].blocks[2].items[0].target,{diagram:'flow',route:['a','b']});
+});