#Problem with mermaid.js

3 messages · Page 1 of 1 (latest)

atomic helm
#

My java code to make the automatic graph :

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;


public class MermaidGenerator {
    public static void main(String[] args) {
        String language = askAutomate();
        if (isValidLanguage(language)) {
            String mermaidDiagram = """
                    graph TD;\n""" +
                    link("A", "B", "a") +
                    link("B", "C", "b") +
                    start("A") +
                    end("B");

            try (FileWriter writer = new FileWriter("diagram.mmd")) {
                writer.write(mermaidDiagram);
                System.out.println("Diagramme Mermaid généré avec succès !");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        else {
            System.out.println("C fo");
        }
    }

    public static String askAutomate() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Language: ");  // Affiche le message
        // Lit l'entrée utilisateur
        return scanner.nextLine();
    }

    public static boolean isValidLanguage(String language) {
        if(!Character.toString(language.charAt(0)).equals("{")){
            return false;
        }
        return true;
    }

    public static String link(String from, String to, String value){
        return from + "(("+from+")) --> |"+value+"|"+to+"((" + to+"));\n";
    }

    public static String link(String from, String to){
        return from + "(("+from+")) --> |Ԑ|"+to+"((" + to+"));\n";
    }

    public static String start(String starter){
        return "Y@{ shape: text} --> "+starter+";\n";
    }

    public static String end(String finish){
        return finish + "(((" + finish + ")));\n";
    }
}```
jaunty hedgeBOT
#

Despite their similarity in name, Java and JavaScript are different languages and are not compatible with each other. This is a JavaScript server, but there are likely many Java-specific servers out there.

atomic helm
#

But is about a js module => and i want to know why "Y@{ shape: text} --> " have a problem with mermaid.JS