mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-01 17:29:29 +05:30
Pure Mermaid translator: graph (nodes + edges) -> flowchart TD source.
5 node kinds (process/decision/terminator/subroutine/document) ->
Mermaid syntax ([..], {..}, ([..]), [[..]], [/../]).
3 edge kinds (solid/dotted/thick) -> Mermaid arrows (-->, -.->, ==>).
Label escaping: double quotes become #quot;, newlines become literal \n.
Also moves tests/fixtures per-test dirs to fixtures-epub / fixtures-css
so the shared tests/fixtures/ stays available for snapshot fixtures.
Amit Haridas
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const ExportCss = require('../src/main/ExportCss');
|
|
|
|
describe('ExportCss.build', () => {
|
|
// Per-test fixture dir (not the shared tests/fixtures/ used by snapshot fixtures).
|
|
const fakeFontPath = path.join(__dirname, 'fixtures-css', 'fake.woff2');
|
|
const fixture = Buffer.from('woff2-binary-fake-data');
|
|
|
|
beforeAll(() => {
|
|
fs.mkdirSync(path.dirname(fakeFontPath), { recursive: true });
|
|
fs.writeFileSync(fakeFontPath, fixture);
|
|
});
|
|
afterAll(() => fs.rmSync(path.dirname(fakeFontPath), { recursive: true, force: true }));
|
|
|
|
test('emits a self-contained CSS with embedded @font-face', () => {
|
|
const css = ExportCss.build({
|
|
activeFontPath: fakeFontPath,
|
|
family: 'JetBrains Mono',
|
|
weight: 400,
|
|
ligatures: false,
|
|
});
|
|
expect(css).toMatch(/@font-face\s*\{[^}]*src:\s*url\('data:font\/woff2;base64,/);
|
|
expect(css).toContain("font-family: 'JetBrains Mono'");
|
|
expect(css).toMatch(/font-feature-settings:[^;]*liga[^;]*0/);
|
|
});
|
|
|
|
test('falls back to family-only CSS when font path is missing', () => {
|
|
const css = ExportCss.build({
|
|
activeFontPath: null,
|
|
family: 'Fira Code',
|
|
weight: 700,
|
|
ligatures: true,
|
|
});
|
|
expect(css).not.toContain('data:font/woff2;');
|
|
expect(css).toContain("font-family: 'Fira Code'");
|
|
});
|
|
});
|