mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-03 17:34:28 +09:00
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>
60 lines
1.1 KiB
TypeScript
60 lines
1.1 KiB
TypeScript
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);
|
|
});
|