Add elk layout support to mermaid (#36486)
Fixes: https://github.com/go-gitea/gitea/issues/34769 This allows the user to opt-in to using `elk` layouts using either YAML frontmatter or `%%{ init` directives inside the markup code block. The default layout is not changed. --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import {sourcesContainElk} from './mermaid.ts';
|
||||
import {dedent} from '../utils/testhelper.ts';
|
||||
|
||||
test('sourcesContainElk', () => {
|
||||
expect(sourcesContainElk([dedent(`
|
||||
flowchart TB
|
||||
elk --> B
|
||||
`)])).toEqual(false);
|
||||
|
||||
expect(sourcesContainElk([dedent(`
|
||||
---
|
||||
config:
|
||||
layout : elk
|
||||
---
|
||||
flowchart TB
|
||||
A --> B
|
||||
`)])).toEqual(true);
|
||||
|
||||
expect(sourcesContainElk([dedent(`
|
||||
---
|
||||
config:
|
||||
layout: elk.layered
|
||||
---
|
||||
flowchart TB
|
||||
A --> B
|
||||
`)])).toEqual(true);
|
||||
|
||||
expect(sourcesContainElk([`
|
||||
%%{ init : { "flowchart": { "defaultRenderer": "elk" } } }%%
|
||||
flowchart TB
|
||||
A --> B
|
||||
`])).toEqual(true);
|
||||
|
||||
expect(sourcesContainElk([`
|
||||
---
|
||||
config:
|
||||
layout: 123
|
||||
---
|
||||
%%{ init : { "class": { "defaultRenderer": "elk.any" } } }%%
|
||||
flowchart TB
|
||||
A --> B
|
||||
`])).toEqual(true);
|
||||
|
||||
expect(sourcesContainElk([`
|
||||
%%{init:{
|
||||
"layout" : "elk.layered"
|
||||
}}%%
|
||||
flowchart TB
|
||||
A --> B
|
||||
`])).toEqual(true);
|
||||
|
||||
expect(sourcesContainElk([`
|
||||
%%{ initialize: {
|
||||
'layout' : 'elk.layered'
|
||||
}}%%
|
||||
flowchart TB
|
||||
A --> B
|
||||
`])).toEqual(true);
|
||||
});
|
||||
Reference in New Issue
Block a user