mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-10-02 01:29:32 +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
36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const JSZip = require('jszip');
|
|
const EpubFontEmbedder = require('../src/main/EpubFontEmbedder');
|
|
|
|
describe('EpubFontEmbedder.patchManifest', () => {
|
|
// Per-test fixture dir (not the shared tests/fixtures/ used by snapshot fixtures).
|
|
const fixturesDir = path.join(__dirname, 'fixtures-epub');
|
|
const epubPath = path.join(fixturesDir, 'fake.epub');
|
|
const fontPath = path.join(fixturesDir, 'fake.ttf');
|
|
|
|
beforeAll(async () => {
|
|
fs.mkdirSync(fixturesDir, { recursive: true });
|
|
fs.writeFileSync(fontPath, 'fake-ttf-binary');
|
|
const zip = new JSZip();
|
|
zip.file(
|
|
'OEBPS/content.opf',
|
|
'<?xml version="1.0"?><package xmlns="http://www.idpf.org/2007/opf"></package>'
|
|
);
|
|
fs.writeFileSync(epubPath, await zip.generateAsync({ type: 'nodebuffer' }));
|
|
});
|
|
|
|
afterAll(() => fs.rmSync(fixturesDir, { recursive: true, force: true }));
|
|
|
|
test('adds a manifest entry referencing the TTF when missing', async () => {
|
|
const patched = await EpubFontEmbedder.patchManifest(epubPath, [
|
|
{ path: fontPath, family: 'JetBrains Mono', weight: 400 },
|
|
]);
|
|
const out = fs.readFileSync(patched);
|
|
const zip = await JSZip.loadAsync(out);
|
|
const opf = await zip.file('OEBPS/content.opf').async('string');
|
|
expect(opf).toMatch(/<item[^>]*href="OEBPS\/fonts\/fake\.ttf"/);
|
|
expect(opf).toMatch(/<item[^>]*media-type="application\/x-font-ttf"/);
|
|
});
|
|
});
|