Skip to content

Commit

Permalink
fix: mermaid ~ escaping in nomnoml
Browse files Browse the repository at this point in the history
  • Loading branch information
demike committed Dec 4, 2023
1 parent 3cc4d6a commit c1efa98
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/core/renderer/mermaid-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ export const mermaidTemplate: Template = {
};

function propertyTemplate(property: PropertyDetails): string {
escapePropertyDetails(property);
let retVal = property.name;
if (property.type && SETTINGS.propertyTypes) {
if(property?.optional) {
retVal += "?";
}
retVal += ": " + property.type;
retVal += ": " + escapeMermaid(property.type);

}

Expand All @@ -70,10 +69,9 @@ function propertyTemplate(property: PropertyDetails): string {


function methodTemplate(method: MethodDetails): string {
escapeMethodDetails(method);
let retVal = method.name + "()";
if (method.returnType && SETTINGS.propertyTypes) {
retVal += " " + method.returnType;
retVal += " " + escapeMermaid(method.returnType);
}

return applyModifiers(method.modifierFlags, retVal);
Expand Down Expand Up @@ -120,19 +118,4 @@ function memberAssociation(association: MemberAssociation) {
// utility functions
function escapeMermaid(str: string) {
return str.replace(/[<>]/g,'~')
}


function escapeMethodDetails(details: MethodDetails) {
if(details.returnType) {
details.returnType = escapeMermaid(details.returnType);
}
return details;
}

function escapePropertyDetails(details: PropertyDetails) {
if(details.type) {
details.type = escapeMermaid(details.type);
}
return details;
}

0 comments on commit c1efa98

Please sign in to comment.