/**
* Generates a flowchart from a PlantUML script using Unicode characters.
*
* @param {string} plantumlScript - The PlantUML script to generate the flowchart from.
* @returns {string} The generated flowchart as a string.
*/
function generateFlowchart(plantumlScript) {
// Define the Unicode characters for the flowchart elements
const elements = {
participant: '',
actor: '',
usecase: '',
class: '',
interface: '',
package: '',
arrow: '→',
dashedArrow: '⇢',
boldArrow: '⇨',
};
// Split the PlantUML script into lines
const lines = plantumlScript.split('\n');
// Initialize the flowchart string
let flowchart = '';
// Iterate over the lines in the PlantUML script
for (const line of lines) {
// Trim the line
const trimmedLine = line.trim();
// Check if the line starts with a keyword
if (trimmedLine.startsWith('participant')) {
// Extract the participant name
const participantName = trimmedLine.substring(11).trim();
flowchart += `${elements.participant} ${participantName}\n`;
} else if (trimmedLine.startsWith('actor')) {
// Extract the actor name
const actorName = trimmedLine.substring(6).trim();
flowchart += `${elements.actor} ${actorName}\n`;
} else if (trimmedLine.startsWith('usecase')) {
// Extract the use case name
const useCaseName = trimmedLine.substring(8).trim();
flowchart += `${elements.usecase} ${useCaseName}\n`;
} else if (trimmedLine.startsWith('class')) {
// Extract the class name
const className = trimmedLine.substring(6).trim();
flowchart += `${elements.class} ${className}\n`;
} else if (trimmedLine.startsWith('interface')) {
// Extract the interface name
const interfaceName = trimmedLine.substring(10).trim();
flowchart += `${elements.interface} ${interfaceName}\n`;
} else if (trimmedLine.startsWith('package')) {
// Extract the package name
const packageName...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.