48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
|
|
// Test different mermaid syntaxes to see which ones work
|
||
|
|
const testDiagrams = [
|
||
|
|
{
|
||
|
|
name: "Minimal flowchart",
|
||
|
|
diagram: "flowchart TD\nA-->B"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Graph syntax",
|
||
|
|
diagram: "graph TD\nA-->B"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Sequence diagram",
|
||
|
|
diagram: "sequenceDiagram\nAlice->>Bob: Hello"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Pie chart",
|
||
|
|
diagram: 'pie title NETFLIX\n"Time spent looking for movie" : 90\n"Time spent watching it" : 10'
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Single line flowchart",
|
||
|
|
diagram: "graph LR; A-->B-->C"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "Semicolon separated",
|
||
|
|
diagram: "graph TD; A[Start]-->B[End]"
|
||
|
|
}
|
||
|
|
];
|
||
|
|
|
||
|
|
testDiagrams.forEach((test, i) => {
|
||
|
|
console.log(`\n=== Test ${i+1}: ${test.name} ===`);
|
||
|
|
console.log("Raw:", JSON.stringify(test.diagram));
|
||
|
|
console.log("Display:");
|
||
|
|
console.log(test.diagram);
|
||
|
|
console.log("Has newlines:", test.diagram.includes('\n'));
|
||
|
|
});
|
||
|
|
|
||
|
|
// Test if semicolons can replace newlines
|
||
|
|
console.log("\n=== Semicolon replacement test ===");
|
||
|
|
const original = `graph TD
|
||
|
|
A[Analytics] --> B[Traffic]
|
||
|
|
A --> C[Revenue]`;
|
||
|
|
|
||
|
|
const semicolonVersion = original.replace(/\n\s*/g, '; ');
|
||
|
|
console.log("Original:", JSON.stringify(original));
|
||
|
|
console.log("Semicolon version:", JSON.stringify(semicolonVersion));
|
||
|
|
console.log("Display semicolon version:");
|
||
|
|
console.log(semicolonVersion);
|