mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-01 14:46:41 +02:00
Merge branch 'develop' into feature/4451-vertical-branches-in-gitgraph
This commit is contained in:
1
.github/workflows/e2e.yml
vendored
1
.github/workflows/e2e.yml
vendored
@@ -45,6 +45,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||||
VITEST_COVERAGE: true
|
VITEST_COVERAGE: true
|
||||||
|
CYPRESS_COMMIT: ${{ github.sha }}
|
||||||
- name: Upload Coverage to Codecov
|
- name: Upload Coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v3
|
||||||
# Run step only pushes to develop and pull_requests
|
# Run step only pushes to develop and pull_requests
|
||||||
|
@@ -1,93 +0,0 @@
|
|||||||
const utf8ToB64 = (str) => {
|
|
||||||
return window.btoa(unescape(encodeURIComponent(str)));
|
|
||||||
};
|
|
||||||
|
|
||||||
const batchId = 'mermaid-batch' + new Date().getTime();
|
|
||||||
|
|
||||||
export const mermaidUrl = (graphStr, options, api) => {
|
|
||||||
const obj = {
|
|
||||||
code: graphStr,
|
|
||||||
mermaid: options,
|
|
||||||
};
|
|
||||||
const objStr = JSON.stringify(obj);
|
|
||||||
let url = 'http://localhost:9000/e2e.html?graph=' + utf8ToB64(objStr);
|
|
||||||
if (api) {
|
|
||||||
url = 'http://localhost:9000/xss.html?graph=' + graphStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.listUrl) {
|
|
||||||
cy.log(options.listId, ' ', url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return url;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const imgSnapshotTest = (graphStr, _options = {}, api = false, validation = undefined) => {
|
|
||||||
cy.log(_options);
|
|
||||||
const options = Object.assign(_options);
|
|
||||||
if (!options.fontFamily) {
|
|
||||||
options.fontFamily = 'courier';
|
|
||||||
}
|
|
||||||
if (!options.sequence) {
|
|
||||||
options.sequence = {};
|
|
||||||
}
|
|
||||||
if (!options.sequence || (options.sequence && !options.sequence.actorFontFamily)) {
|
|
||||||
options.sequence.actorFontFamily = 'courier';
|
|
||||||
}
|
|
||||||
if (options.sequence && !options.sequence.noteFontFamily) {
|
|
||||||
options.sequence.noteFontFamily = 'courier';
|
|
||||||
}
|
|
||||||
options.sequence.actorFontFamily = 'courier';
|
|
||||||
options.sequence.noteFontFamily = 'courier';
|
|
||||||
options.sequence.messageFontFamily = 'courier';
|
|
||||||
if (options.sequence && !options.sequence.actorFontFamily) {
|
|
||||||
options.sequence.actorFontFamily = 'courier';
|
|
||||||
}
|
|
||||||
if (!options.fontSize) {
|
|
||||||
options.fontSize = '16px';
|
|
||||||
}
|
|
||||||
const url = mermaidUrl(graphStr, options, api);
|
|
||||||
openURLAndVerifyRendering(url, options, validation);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const urlSnapshotTest = (url, _options, api = false, validation) => {
|
|
||||||
const options = Object.assign(_options);
|
|
||||||
openURLAndVerifyRendering(url, options, validation);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const renderGraph = (graphStr, options, api) => {
|
|
||||||
const url = mermaidUrl(graphStr, options, api);
|
|
||||||
openURLAndVerifyRendering(url, options);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const openURLAndVerifyRendering = (url, options, validation = undefined) => {
|
|
||||||
const useAppli = Cypress.env('useAppli');
|
|
||||||
const name = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
|
||||||
|
|
||||||
if (useAppli) {
|
|
||||||
cy.log('Opening eyes ' + Cypress.spec.name + ' --- ' + name);
|
|
||||||
cy.eyesOpen({
|
|
||||||
appName: 'Mermaid',
|
|
||||||
testName: name,
|
|
||||||
batchName: Cypress.spec.name,
|
|
||||||
batchId: batchId + Cypress.spec.name,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
cy.visit(url);
|
|
||||||
cy.window().should('have.property', 'rendered', true);
|
|
||||||
cy.get('svg').should('be.visible');
|
|
||||||
|
|
||||||
if (validation) {
|
|
||||||
cy.get('svg').should(validation);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useAppli) {
|
|
||||||
cy.log('Check eyes' + Cypress.spec.name);
|
|
||||||
cy.eyesCheckWindow('Click!');
|
|
||||||
cy.log('Closing eyes' + Cypress.spec.name);
|
|
||||||
cy.eyesClose();
|
|
||||||
} else {
|
|
||||||
cy.matchImageSnapshot(name);
|
|
||||||
}
|
|
||||||
};
|
|
132
cypress/helpers/util.ts
Normal file
132
cypress/helpers/util.ts
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
import { Buffer } from 'buffer';
|
||||||
|
import type { MermaidConfig } from '../../packages/mermaid/src/config.type.js';
|
||||||
|
|
||||||
|
interface CypressConfig {
|
||||||
|
listUrl?: boolean;
|
||||||
|
listId?: string;
|
||||||
|
name?: string;
|
||||||
|
}
|
||||||
|
type CypressMermaidConfig = MermaidConfig & CypressConfig;
|
||||||
|
|
||||||
|
interface CodeObject {
|
||||||
|
code: string;
|
||||||
|
mermaid: CypressMermaidConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
const utf8ToB64 = (str: string): string => {
|
||||||
|
return Buffer.from(decodeURIComponent(encodeURIComponent(str))).toString('base64');
|
||||||
|
};
|
||||||
|
|
||||||
|
const batchId: string = 'mermaid-batch-' + Cypress.env('CYPRESS_COMMIT') || Date.now().toString();
|
||||||
|
|
||||||
|
export const mermaidUrl = (
|
||||||
|
graphStr: string,
|
||||||
|
options: CypressMermaidConfig,
|
||||||
|
api: boolean
|
||||||
|
): string => {
|
||||||
|
const codeObject: CodeObject = {
|
||||||
|
code: graphStr,
|
||||||
|
mermaid: options,
|
||||||
|
};
|
||||||
|
const objStr: string = JSON.stringify(codeObject);
|
||||||
|
let url = `http://localhost:9000/e2e.html?graph=${utf8ToB64(objStr)}`;
|
||||||
|
if (api) {
|
||||||
|
url = `http://localhost:9000/xss.html?graph=${graphStr}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.listUrl) {
|
||||||
|
cy.log(options.listId, ' ', url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const imgSnapshotTest = (
|
||||||
|
graphStr: string,
|
||||||
|
_options: CypressMermaidConfig = {},
|
||||||
|
api = false,
|
||||||
|
validation?: any
|
||||||
|
): void => {
|
||||||
|
cy.log(JSON.stringify(_options));
|
||||||
|
const options: CypressMermaidConfig = Object.assign(_options);
|
||||||
|
if (!options.fontFamily) {
|
||||||
|
options.fontFamily = 'courier';
|
||||||
|
}
|
||||||
|
if (!options.sequence) {
|
||||||
|
options.sequence = {};
|
||||||
|
}
|
||||||
|
if (!options.sequence || (options.sequence && !options.sequence.actorFontFamily)) {
|
||||||
|
options.sequence.actorFontFamily = 'courier';
|
||||||
|
}
|
||||||
|
if (options.sequence && !options.sequence.noteFontFamily) {
|
||||||
|
options.sequence.noteFontFamily = 'courier';
|
||||||
|
}
|
||||||
|
options.sequence.actorFontFamily = 'courier';
|
||||||
|
options.sequence.noteFontFamily = 'courier';
|
||||||
|
options.sequence.messageFontFamily = 'courier';
|
||||||
|
if (options.sequence && !options.sequence.actorFontFamily) {
|
||||||
|
options.sequence.actorFontFamily = 'courier';
|
||||||
|
}
|
||||||
|
if (!options.fontSize) {
|
||||||
|
options.fontSize = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url: string = mermaidUrl(graphStr, options, api);
|
||||||
|
openURLAndVerifyRendering(url, options, validation);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const urlSnapshotTest = (
|
||||||
|
url: string,
|
||||||
|
_options: CypressMermaidConfig,
|
||||||
|
_api = false,
|
||||||
|
validation?: any
|
||||||
|
): void => {
|
||||||
|
const options: CypressMermaidConfig = Object.assign(_options);
|
||||||
|
openURLAndVerifyRendering(url, options, validation);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderGraph = (
|
||||||
|
graphStr: string,
|
||||||
|
options: CypressMermaidConfig = {},
|
||||||
|
api = false
|
||||||
|
): void => {
|
||||||
|
const url: string = mermaidUrl(graphStr, options, api);
|
||||||
|
openURLAndVerifyRendering(url, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const openURLAndVerifyRendering = (
|
||||||
|
url: string,
|
||||||
|
options: CypressMermaidConfig,
|
||||||
|
validation?: any
|
||||||
|
): void => {
|
||||||
|
const useAppli: boolean = Cypress.env('useAppli');
|
||||||
|
const name: string = (options.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-');
|
||||||
|
|
||||||
|
if (useAppli) {
|
||||||
|
cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`);
|
||||||
|
cy.eyesOpen({
|
||||||
|
appName: 'Mermaid',
|
||||||
|
testName: name,
|
||||||
|
batchName: Cypress.spec.name,
|
||||||
|
batchId: batchId + Cypress.spec.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.visit(url);
|
||||||
|
cy.window().should('have.property', 'rendered', true);
|
||||||
|
cy.get('svg').should('be.visible');
|
||||||
|
|
||||||
|
if (validation) {
|
||||||
|
cy.get('svg').should(validation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useAppli) {
|
||||||
|
cy.log(`Check eyes ${Cypress.spec.name}`);
|
||||||
|
cy.eyesCheckWindow('Click!');
|
||||||
|
cy.log(`Closing eyes ${Cypress.spec.name}`);
|
||||||
|
cy.eyesClose();
|
||||||
|
} else {
|
||||||
|
cy.matchImageSnapshot(name);
|
||||||
|
}
|
||||||
|
};
|
@@ -1,4 +1,4 @@
|
|||||||
import { renderGraph } from '../../helpers/util.js';
|
import { renderGraph } from '../../helpers/util.ts';
|
||||||
describe('Configuration', () => {
|
describe('Configuration', () => {
|
||||||
describe('arrowMarkerAbsolute', () => {
|
describe('arrowMarkerAbsolute', () => {
|
||||||
it('should handle default value false of arrowMarkerAbsolute', () => {
|
it('should handle default value false of arrowMarkerAbsolute', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { urlSnapshotTest } from '../../helpers/util.js';
|
import { urlSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('mermaid', () => {
|
describe('mermaid', () => {
|
||||||
describe('registerDiagram', () => {
|
describe('registerDiagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { urlSnapshotTest, openURLAndVerifyRendering } from '../../helpers/util.js';
|
import { urlSnapshotTest, openURLAndVerifyRendering } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('CSS injections', () => {
|
describe('CSS injections', () => {
|
||||||
it('should not allow CSS injections outside of the diagram', () => {
|
it('should not allow CSS injections outside of the diagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { mermaidUrl } from '../../helpers/util.js';
|
import { mermaidUrl } from '../../helpers/util.ts';
|
||||||
describe('XSS', () => {
|
describe('XSS', () => {
|
||||||
it('should handle xss in tags', () => {
|
it('should handle xss in tags', () => {
|
||||||
const str =
|
const str =
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Git Graph diagram', () => {
|
describe('Git Graph diagram', () => {
|
||||||
it('1: should render a simple gitgraph with commit on main branch', () => {
|
it('1: should render a simple gitgraph with commit on main branch', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('C4 diagram', () => {
|
describe('C4 diagram', () => {
|
||||||
it('should render a simple C4Context diagram', () => {
|
it('should render a simple C4Context diagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
describe('Class diagram V2', () => {
|
describe('Class diagram V2', () => {
|
||||||
it('0: should render a simple class diagram', () => {
|
it('0: should render a simple class diagram', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Class diagram', () => {
|
describe('Class diagram', () => {
|
||||||
it('1: should render a simple class diagram', () => {
|
it('1: should render a simple class diagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Configuration and directives - nodes should be light blue', () => {
|
describe('Configuration and directives - nodes should be light blue', () => {
|
||||||
it('No config - use default', () => {
|
it('No config - use default', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Current diagram', () => {
|
describe('Current diagram', () => {
|
||||||
it('should render a state with states in it', () => {
|
it('should render a state with states in it', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Flowchart', () => {
|
describe('Flowchart', () => {
|
||||||
it('34: testing the label width in percy', () => {
|
it('34: testing the label width in percy', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Entity Relationship Diagram', () => {
|
describe('Entity Relationship Diagram', () => {
|
||||||
it('should render a simple ER diagram', () => {
|
it('should render a simple ER diagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe.skip('Flowchart ELK', () => {
|
describe.skip('Flowchart ELK', () => {
|
||||||
it('1-elk: should render a simple flowchart', () => {
|
it('1-elk: should render a simple flowchart', () => {
|
||||||
@@ -681,7 +681,7 @@ title: Simple flowchart
|
|||||||
flowchart-elk TD
|
flowchart-elk TD
|
||||||
A --> B
|
A --> B
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('elk: should include classes on the edges', () => {
|
it('elk: should include classes on the edges', () => {
|
||||||
@@ -710,7 +710,7 @@ flowchart-elk LR
|
|||||||
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
classDef someclass fill:#f96
|
classDef someclass fill:#f96
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('With formatting in a node', () => {
|
it('With formatting in a node', () => {
|
||||||
@@ -726,7 +726,7 @@ flowchart-elk LR
|
|||||||
b --> d(The dog in the hog)
|
b --> d(The dog in the hog)
|
||||||
c --> d
|
c --> d
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('New line in node and formatted edge label', () => {
|
it('New line in node and formatted edge label', () => {
|
||||||
@@ -736,7 +736,7 @@ flowchart-elk LR
|
|||||||
b("\`The dog in **the** hog.(1)
|
b("\`The dog in **the** hog.(1)
|
||||||
NL\`") --"\`1o **bold**\`"--> c
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Wrapping long text with a new line', () => {
|
it('Wrapping long text with a new line', () => {
|
||||||
@@ -749,7 +749,7 @@ Word!
|
|||||||
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`) --> c
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`) --> c
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Sub graphs and markdown strings', () => {
|
it('Sub graphs and markdown strings', () => {
|
||||||
@@ -766,7 +766,7 @@ subgraph "\`**Two**\`"
|
|||||||
end
|
end
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -782,7 +782,7 @@ flowchart-elk LR
|
|||||||
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
classDef someclass fill:#f96
|
classDef someclass fill:#f96
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('With formatting in a node', () => {
|
it('With formatting in a node', () => {
|
||||||
@@ -798,7 +798,7 @@ flowchart-elk LR
|
|||||||
b --> d(The dog in the hog)
|
b --> d(The dog in the hog)
|
||||||
c --> d
|
c --> d
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('New line in node and formatted edge label', () => {
|
it('New line in node and formatted edge label', () => {
|
||||||
@@ -808,7 +808,7 @@ flowchart-elk LR
|
|||||||
b("\`The dog in **the** hog.(1)
|
b("\`The dog in **the** hog.(1)
|
||||||
NL\`") --"\`1o **bold**\`"--> c
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Wrapping long text with a new line', () => {
|
it('Wrapping long text with a new line', () => {
|
||||||
@@ -821,7 +821,7 @@ Word!
|
|||||||
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Sub graphs and markdown strings', () => {
|
it('Sub graphs and markdown strings', () => {
|
||||||
@@ -838,7 +838,7 @@ subgraph "\`**Two**\`"
|
|||||||
end
|
end
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Flowchart v2', () => {
|
describe('Flowchart v2', () => {
|
||||||
it('1: should render a simple flowchart', () => {
|
it('1: should render a simple flowchart', () => {
|
||||||
@@ -671,7 +671,7 @@ title: Simple flowchart
|
|||||||
flowchart TD
|
flowchart TD
|
||||||
A --> B
|
A --> B
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('3192: It should be possieble to render flowcharts with invisible edges', () => {
|
it('3192: It should be possieble to render flowcharts with invisible edges', () => {
|
||||||
@@ -682,7 +682,7 @@ title: Simple flowchart with invisible edges
|
|||||||
flowchart TD
|
flowchart TD
|
||||||
A ~~~ B
|
A ~~~ B
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('4023: Should render html labels with images and-or text correctly', () => {
|
it('4023: Should render html labels with images and-or text correctly', () => {
|
||||||
@@ -716,7 +716,7 @@ flowchart LR
|
|||||||
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
classDef someclass fill:#f96
|
classDef someclass fill:#f96
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('With formatting in a node', () => {
|
it('With formatting in a node', () => {
|
||||||
@@ -732,7 +732,7 @@ flowchart LR
|
|||||||
b --> d(The dog in the hog)
|
b --> d(The dog in the hog)
|
||||||
c --> d
|
c --> d
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('New line in node and formatted edge label', () => {
|
it('New line in node and formatted edge label', () => {
|
||||||
@@ -742,7 +742,7 @@ flowchart LR
|
|||||||
b("\`The dog in **the** hog.(1)
|
b("\`The dog in **the** hog.(1)
|
||||||
NL\`") --"\`1o **bold**\`"--> c
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Wrapping long text with a new line', () => {
|
it('Wrapping long text with a new line', () => {
|
||||||
@@ -755,7 +755,7 @@ Word!
|
|||||||
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Sub graphs and markdown strings', () => {
|
it('Sub graphs and markdown strings', () => {
|
||||||
@@ -772,7 +772,7 @@ subgraph "\`**Two**\`"
|
|||||||
end
|
end
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -788,7 +788,7 @@ flowchart LR
|
|||||||
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
style id2 fill:#bbf,stroke:#f66,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
|
||||||
classDef someclass fill:#f96
|
classDef someclass fill:#f96
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('With formatting in a node', () => {
|
it('With formatting in a node', () => {
|
||||||
@@ -804,7 +804,7 @@ flowchart LR
|
|||||||
b --> d(The dog in the hog)
|
b --> d(The dog in the hog)
|
||||||
c --> d
|
c --> d
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('New line in node and formatted edge label', () => {
|
it('New line in node and formatted edge label', () => {
|
||||||
@@ -814,7 +814,7 @@ flowchart LR
|
|||||||
b("\`The dog in **the** hog.(1)
|
b("\`The dog in **the** hog.(1)
|
||||||
NL\`") --"\`1o **bold**\`"--> c
|
NL\`") --"\`1o **bold**\`"--> c
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Wrapping long text with a new line', () => {
|
it('Wrapping long text with a new line', () => {
|
||||||
@@ -827,7 +827,7 @@ Word!
|
|||||||
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. Another line with many, many words. \`") --> c
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('Sub graphs and markdown strings', () => {
|
it('Sub graphs and markdown strings', () => {
|
||||||
@@ -844,7 +844,7 @@ subgraph "\`**Two**\`"
|
|||||||
end
|
end
|
||||||
|
|
||||||
`,
|
`,
|
||||||
{ titleTopMargin: 0 }
|
{ flowchart: { titleTopMargin: 0 } }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Graph', () => {
|
describe('Graph', () => {
|
||||||
it('1: should render a simple flowchart no htmlLabels', () => {
|
it('1: should render a simple flowchart no htmlLabels', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Gantt diagram', () => {
|
describe('Gantt diagram', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Git Graph diagram', () => {
|
describe('Git Graph diagram', () => {
|
||||||
it('1: should render a simple gitgraph with commit on main branch', () => {
|
it('1: should render a simple gitgraph with commit on main branch', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('info diagram', () => {
|
describe('info diagram', () => {
|
||||||
it('should handle an info definition', () => {
|
it('should handle an info definition', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('User journey diagram', () => {
|
describe('User journey diagram', () => {
|
||||||
it('Simple test', () => {
|
it('Simple test', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the SVG Element has a Mindmap root
|
* Check whether the SVG Element has a Mindmap root
|
||||||
@@ -242,8 +242,7 @@ mindmap
|
|||||||
a second line 😎\`]
|
a second line 😎\`]
|
||||||
id2[\`The dog in **the** hog... a *very long text* about it
|
id2[\`The dog in **the** hog... a *very long text* about it
|
||||||
Word!\`]
|
Word!\`]
|
||||||
`,
|
`
|
||||||
{ titleTopMargin: 0 }
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Pie Chart', () => {
|
describe('Pie Chart', () => {
|
||||||
it('should render a simple pie diagram', () => {
|
it('should render a simple pie diagram', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Quadrant Chart', () => {
|
describe('Quadrant Chart', () => {
|
||||||
it('should render if only chart type is provided', () => {
|
it('should render if only chart type is provided', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Requirement diagram', () => {
|
describe('Requirement diagram', () => {
|
||||||
it('sample', () => {
|
it('sample', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Sankey Diagram', () => {
|
describe('Sankey Diagram', () => {
|
||||||
it('should render a simple example', () => {
|
it('should render a simple example', () => {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/// <reference types="Cypress" />
|
/// <reference types="Cypress" />
|
||||||
|
|
||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
context('Sequence diagram', () => {
|
context('Sequence diagram', () => {
|
||||||
it('should render a sequence diagram with boxes', () => {
|
it('should render a sequence diagram with boxes', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('State diagram', () => {
|
describe('State diagram', () => {
|
||||||
it('v2 should render a simple info', () => {
|
it('v2 should render a simple info', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest, renderGraph } from '../../helpers/util.js';
|
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('State diagram', () => {
|
describe('State diagram', () => {
|
||||||
it('should render a simple state diagrams', () => {
|
it('should render a simple state diagrams', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('themeCSS balancing, it', () => {
|
describe('themeCSS balancing, it', () => {
|
||||||
it('should not allow unbalanced CSS definitions', () => {
|
it('should not allow unbalanced CSS definitions', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Timeline diagram', () => {
|
describe('Timeline diagram', () => {
|
||||||
it('1: should render a simple timeline with no specific sections', () => {
|
it('1: should render a simple timeline with no specific sections', () => {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { imgSnapshotTest } from '../../helpers/util.js';
|
import { imgSnapshotTest } from '../../helpers/util.ts';
|
||||||
|
|
||||||
describe('Zen UML', () => {
|
describe('Zen UML', () => {
|
||||||
it('Basic Zen UML diagram', () => {
|
it('Basic Zen UML diagram', () => {
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2020",
|
"target": "es2020",
|
||||||
"lib": ["es2020", "dom"],
|
"lib": ["es2020", "dom"],
|
||||||
"types": ["cypress", "node"]
|
"types": ["cypress", "node"],
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["**/*.ts"]
|
"include": ["**/*.ts"]
|
||||||
}
|
}
|
||||||
|
@@ -30,11 +30,20 @@
|
|||||||
* @todo Write a test file for this. (Will need to be able to deal .mts file. Jest has trouble with
|
* @todo Write a test file for this. (Will need to be able to deal .mts file. Jest has trouble with
|
||||||
* it.)
|
* it.)
|
||||||
*/
|
*/
|
||||||
|
// @ts-ignore: we're importing internal jsonschema2md functions
|
||||||
|
import { default as schemaLoader } from '@adobe/jsonschema2md/lib/schemaProxy.js';
|
||||||
|
// @ts-ignore: we're importing internal jsonschema2md functions
|
||||||
|
import { default as traverseSchemas } from '@adobe/jsonschema2md/lib/traverseSchema.js';
|
||||||
|
// @ts-ignore: we're importing internal jsonschema2md functions
|
||||||
|
import { default as buildMarkdownFromSchema } from '@adobe/jsonschema2md/lib/markdownBuilder.js';
|
||||||
|
// @ts-ignore: we're importing internal jsonschema2md functions
|
||||||
|
import { default as jsonSchemaReadmeBuilder } from '@adobe/jsonschema2md/lib/readmeBuilder.js';
|
||||||
import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync, rmdirSync } from 'fs';
|
import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync, rmdirSync } from 'fs';
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { globby } from 'globby';
|
import { globby } from 'globby';
|
||||||
import { JSDOM } from 'jsdom';
|
import { JSDOM } from 'jsdom';
|
||||||
import type { Code, ListItem, Root, Text } from 'mdast';
|
import { dump, load, JSON_SCHEMA } from 'js-yaml';
|
||||||
|
import type { Code, ListItem, Root, Text, YAML } from 'mdast';
|
||||||
import { posix, dirname, relative, join } from 'path';
|
import { posix, dirname, relative, join } from 'path';
|
||||||
import prettier from 'prettier';
|
import prettier from 'prettier';
|
||||||
import { remark } from 'remark';
|
import { remark } from 'remark';
|
||||||
@@ -209,6 +218,8 @@ interface TransformMarkdownAstOptions {
|
|||||||
originalFilename: string;
|
originalFilename: string;
|
||||||
/** If `true`, add a warning that the file is autogenerated */
|
/** If `true`, add a warning that the file is autogenerated */
|
||||||
addAutogeneratedWarning?: boolean;
|
addAutogeneratedWarning?: boolean;
|
||||||
|
/** If `true`, adds an `editLink: "https://..."` YAML frontmatter field */
|
||||||
|
addEditLink?: boolean;
|
||||||
/**
|
/**
|
||||||
* If `true`, remove the YAML metadata from the Markdown input.
|
* If `true`, remove the YAML metadata from the Markdown input.
|
||||||
* Generally, YAML metadata is only used for Vitepress.
|
* Generally, YAML metadata is only used for Vitepress.
|
||||||
@@ -231,6 +242,7 @@ interface TransformMarkdownAstOptions {
|
|||||||
export function transformMarkdownAst({
|
export function transformMarkdownAst({
|
||||||
originalFilename,
|
originalFilename,
|
||||||
addAutogeneratedWarning,
|
addAutogeneratedWarning,
|
||||||
|
addEditLink,
|
||||||
removeYAML,
|
removeYAML,
|
||||||
}: TransformMarkdownAstOptions) {
|
}: TransformMarkdownAstOptions) {
|
||||||
return (tree: Root, _file?: any): Root => {
|
return (tree: Root, _file?: any): Root => {
|
||||||
@@ -270,6 +282,27 @@ export function transformMarkdownAst({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addEditLink) {
|
||||||
|
// add originalFilename as custom editLink in YAML frontmatter
|
||||||
|
let yamlFrontMatter: YAML;
|
||||||
|
if (astWithTransformedBlocks.children[0].type === 'yaml') {
|
||||||
|
yamlFrontMatter = astWithTransformedBlocks.children[0];
|
||||||
|
} else {
|
||||||
|
yamlFrontMatter = {
|
||||||
|
type: 'yaml',
|
||||||
|
value: '',
|
||||||
|
};
|
||||||
|
astWithTransformedBlocks.children.unshift(yamlFrontMatter);
|
||||||
|
}
|
||||||
|
const filePathFromRoot = posix.join('packages/mermaid', originalFilename);
|
||||||
|
yamlFrontMatter.value = dump({
|
||||||
|
...(load(yamlFrontMatter.value, { schema: JSON_SCHEMA }) as
|
||||||
|
| Record<string, unknown>
|
||||||
|
| undefined),
|
||||||
|
editLink: `https://github.com/mermaid-js/mermaid/edit/develop/${filePathFromRoot}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (removeYAML) {
|
if (removeYAML) {
|
||||||
const firstNode = astWithTransformedBlocks.children[0];
|
const firstNode = astWithTransformedBlocks.children[0];
|
||||||
if (firstNode.type == 'yaml') {
|
if (firstNode.type == 'yaml') {
|
||||||
@@ -306,6 +339,7 @@ const transformMarkdown = (file: string) => {
|
|||||||
// mermaid project specific plugin
|
// mermaid project specific plugin
|
||||||
originalFilename: file,
|
originalFilename: file,
|
||||||
addAutogeneratedWarning: !noHeader,
|
addAutogeneratedWarning: !noHeader,
|
||||||
|
addEditLink: noHeader,
|
||||||
removeYAML: !noHeader,
|
removeYAML: !noHeader,
|
||||||
})
|
})
|
||||||
.processSync(doc)
|
.processSync(doc)
|
||||||
@@ -323,16 +357,6 @@ const transformMarkdown = (file: string) => {
|
|||||||
copyTransformedContents(file, !verifyOnly, formatted);
|
copyTransformedContents(file, !verifyOnly, formatted);
|
||||||
};
|
};
|
||||||
|
|
||||||
import { load, JSON_SCHEMA } from 'js-yaml';
|
|
||||||
// @ts-ignore: we're importing internal jsonschema2md functions
|
|
||||||
import { default as schemaLoader } from '@adobe/jsonschema2md/lib/schemaProxy.js';
|
|
||||||
// @ts-ignore: we're importing internal jsonschema2md functions
|
|
||||||
import { default as traverseSchemas } from '@adobe/jsonschema2md/lib/traverseSchema.js';
|
|
||||||
// @ts-ignore: we're importing internal jsonschema2md functions
|
|
||||||
import { default as buildMarkdownFromSchema } from '@adobe/jsonschema2md/lib/markdownBuilder.js';
|
|
||||||
// @ts-ignore: we're importing internal jsonschema2md functions
|
|
||||||
import { default as jsonSchemaReadmeBuilder } from '@adobe/jsonschema2md/lib/readmeBuilder.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the given JSON Schema into Markdown documentation
|
* Transforms the given JSON Schema into Markdown documentation
|
||||||
*/
|
*/
|
||||||
@@ -420,16 +444,18 @@ async function transormJsonSchema(file: string) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const transformed = remark()
|
const transformer = remark()
|
||||||
.use(remarkGfm)
|
.use(remarkGfm)
|
||||||
.use(remarkFrontmatter, ['yaml']) // support YAML front-matter in Markdown
|
.use(remarkFrontmatter, ['yaml']) // support YAML front-matter in Markdown
|
||||||
.use(transformMarkdownAst, {
|
.use(transformMarkdownAst, {
|
||||||
// mermaid project specific plugin
|
// mermaid project specific plugin
|
||||||
originalFilename: file,
|
originalFilename: file,
|
||||||
addAutogeneratedWarning: !noHeader,
|
addAutogeneratedWarning: !noHeader,
|
||||||
|
addEditLink: noHeader,
|
||||||
removeYAML: !noHeader,
|
removeYAML: !noHeader,
|
||||||
})
|
});
|
||||||
.stringify(markdownAst as Root);
|
|
||||||
|
const transformed = transformer.stringify(await transformer.run(markdownAst as Root));
|
||||||
|
|
||||||
const formatted = prettier.format(transformed, {
|
const formatted = prettier.format(transformed, {
|
||||||
parser: 'markdown',
|
parser: 'markdown',
|
||||||
|
@@ -105,6 +105,29 @@ This Markdown should be kept.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should add an editLink in the YAML frontmatter if `addEditLink: true`', async () => {
|
||||||
|
const contents = `---
|
||||||
|
title: Flowcharts Syntax
|
||||||
|
---
|
||||||
|
|
||||||
|
This Markdown should be kept.
|
||||||
|
`;
|
||||||
|
const withYaml = (
|
||||||
|
await remarkBuilder()
|
||||||
|
.use(transformMarkdownAst, { originalFilename, addEditLink: true })
|
||||||
|
.process(contents)
|
||||||
|
).toString();
|
||||||
|
expect(withYaml).toEqual(`---
|
||||||
|
title: Flowcharts Syntax
|
||||||
|
editLink: >-
|
||||||
|
https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/example-input-filename.md
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
This Markdown should be kept.
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
describe('transformToBlockQuote', () => {
|
describe('transformToBlockQuote', () => {
|
||||||
// TODO Is there a way to test this with --vitepress given as a process argument?
|
// TODO Is there a way to test this with --vitepress given as a process argument?
|
||||||
|
|
||||||
|
@@ -35,7 +35,12 @@ export default defineConfig({
|
|||||||
themeConfig: {
|
themeConfig: {
|
||||||
nav: nav(),
|
nav: nav(),
|
||||||
editLink: {
|
editLink: {
|
||||||
pattern: 'https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/src/docs/:path',
|
pattern: ({ filePath, frontmatter }) => {
|
||||||
|
if (typeof frontmatter.editLink === 'string') {
|
||||||
|
return frontmatter.editLink;
|
||||||
|
}
|
||||||
|
return `https://github.com/mermaid-js/mermaid/edit/develop/packages/mermaid/src/docs/${filePath}`;
|
||||||
|
},
|
||||||
text: 'Edit this page on GitHub',
|
text: 'Edit this page on GitHub',
|
||||||
},
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
|
Reference in New Issue
Block a user