mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-22 00:40:22 +02:00
fix: trimStart to text
This commit is contained in:
@@ -14,13 +14,13 @@ graph TD
|
|||||||
%% This is a comment
|
%% This is a comment
|
||||||
`;
|
`;
|
||||||
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
"
|
"
|
||||||
|
|
||||||
graph TD
|
graph TD
|
||||||
A-->B
|
A-->B
|
||||||
|
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should keep init statements when removing comments', () => {
|
it('should keep init statements when removing comments', () => {
|
||||||
@@ -61,12 +61,12 @@ graph TD
|
|||||||
C-->D
|
C-->D
|
||||||
`;
|
`;
|
||||||
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
expect(cleanupComments(text)).toMatchInlineSnapshot(`
|
||||||
"
|
"
|
||||||
graph TD
|
graph TD
|
||||||
A-->B
|
A-->B
|
||||||
|
|
||||||
C-->D
|
C-->D
|
||||||
"
|
"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,5 +4,5 @@
|
|||||||
* @returns cleaned text
|
* @returns cleaned text
|
||||||
*/
|
*/
|
||||||
export const cleanupComments = (text: string): string => {
|
export const cleanupComments = (text: string): string => {
|
||||||
return text.replace(/^\s*%%(?!{)[^\n]+/gm, '');
|
return text.trimStart().replace(/^\s*%%(?!{)[^\n]+/gm, '');
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user