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