mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
fix: clean comments in text in getDiagramFromText API so flowchart works well
This commit is contained in:
parent
0c0f7a739e
commit
1d5378a4f2
@ -1539,7 +1539,11 @@
|
||||
class I bugged_node
|
||||
</pre>
|
||||
<hr />
|
||||
|
||||
<pre class="mermaid">
|
||||
flowchart LR
|
||||
%% this is a comment A -- text --> B{node}
|
||||
A -- text --> B -- text2 --> C
|
||||
</pre>
|
||||
<h1 id="link-clicked">Anchor for "link-clicked" test</h1>
|
||||
|
||||
<script type="module">
|
||||
|
@ -8,6 +8,8 @@ import { encodeEntities } from './utils.js';
|
||||
import type { DetailedError } from './utils.js';
|
||||
import type { DiagramDefinition, DiagramMetadata } from './diagram-api/types.js';
|
||||
|
||||
import { cleanupComments } from './diagram-api/comments.js';
|
||||
|
||||
export type ParseErrorFunction = (err: string | DetailedError | unknown, hash?: any) => void;
|
||||
|
||||
/**
|
||||
@ -23,7 +25,7 @@ export class Diagram {
|
||||
|
||||
private detectError?: UnknownDiagramError;
|
||||
constructor(public text: string, public metadata: Pick<DiagramMetadata, 'title'> = {}) {
|
||||
this.text = encodeEntities(text);
|
||||
this.text = encodeEntities(cleanupComments(text));
|
||||
this.text += '\n';
|
||||
const cnf = configApi.getConfig();
|
||||
try {
|
||||
@ -85,6 +87,8 @@ export const getDiagramFromText = async (
|
||||
metadata: Pick<DiagramMetadata, 'title'> = {}
|
||||
): Promise<Diagram> => {
|
||||
const type = detectType(text, configApi.getConfig());
|
||||
let title;
|
||||
|
||||
try {
|
||||
// Trying to find the diagram
|
||||
getDiagram(type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user