Add Wiki.js markdown export option
This commit is contained in:
@@ -21,7 +21,7 @@ for f in sample-manifest.json sample-guide.sfgz; do
|
||||
done
|
||||
|
||||
for dir in sample-data sample-exports/json sample-exports/markdown sample-exports/html-simple \
|
||||
sample-exports/html-rich sample-exports/pdf sample-exports/gif \
|
||||
sample-exports/wikijs sample-exports/html-rich sample-exports/pdf sample-exports/gif \
|
||||
sample-exports/image-bundle sample-exports/docx sample-exports/pptx; do
|
||||
if ! find "$SAMPLE_ROOT/$dir" -type f -print -quit | grep -q .; then
|
||||
echo "Sample export directory is empty: $dir" >&2
|
||||
@@ -34,7 +34,7 @@ const fs = require('node:fs');
|
||||
const manifest = JSON.parse(fs.readFileSync(process.env.MANIFEST_FILE, 'utf8'));
|
||||
if (manifest.format !== 'stepforge-sample-manifest') throw new Error('unexpected sample manifest format');
|
||||
if (!manifest.guideId) throw new Error('missing guideId');
|
||||
if (!manifest.exports || Object.keys(manifest.exports).length < 9) throw new Error('missing sample exports');
|
||||
if (!manifest.exports || Object.keys(manifest.exports).length < 10) throw new Error('missing sample exports');
|
||||
NODE
|
||||
|
||||
echo "sample artifacts OK"
|
||||
|
||||
@@ -376,6 +376,6 @@ test('a saved template changes exporter behavior through runExport', (t) => {
|
||||
const withTemplate = runExport('pdf', ast, path.join(root, 'out2'), tm.load('pdf', 'no-cover'));
|
||||
assert.ok(withTemplate.pageCount < withDefaults.pageCount, 'dropping cover+toc reduces pages');
|
||||
|
||||
assert.equal(Object.keys(EXPORTERS).length, 10, 'all ten formats wired');
|
||||
assert.equal(Object.keys(EXPORTERS).length, 11, 'all eleven formats wired');
|
||||
assert.throws(() => runExport('exe', ast, path.join(root, 'out3')));
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ const path = require('node:path');
|
||||
const { buildRenderAst, renderStepImage } = require('../../core/renderast');
|
||||
const { exportJson } = require('../../exporters/json');
|
||||
const { exportMarkdown } = require('../../exporters/markdown');
|
||||
const { exportWikiJs } = require('../../exporters/wikijs');
|
||||
const { exportHtmlSimple, exportHtmlRich } = require('../../exporters/html');
|
||||
const { exportConfluence } = require('../../exporters/confluence');
|
||||
const { htmlToMarkdown } = require('../../exporters/htmlmd');
|
||||
@@ -143,6 +144,32 @@ test('Markdown export: TOC anchors resolve, images exist, blocks rendered', (t)
|
||||
assert.equal(lines[warnIdx + 2], '> Admins only.');
|
||||
});
|
||||
|
||||
test('Wiki.js export: TOC is omitted, wiki callouts render, images exist', (t) => {
|
||||
const root = makeTmpDir('expwikijs');
|
||||
t.after(() => rmrf(root));
|
||||
const { store, guide } = buildFixtureGuide(path.join(root, 'data'));
|
||||
const out = path.join(root, 'out');
|
||||
|
||||
const ast = buildRenderAst(store, guide.guideId);
|
||||
const { file } = exportWikiJs(ast, out);
|
||||
const md = fs.readFileSync(file, 'utf8');
|
||||
|
||||
const lines = md.split('\n');
|
||||
assert.equal(lines[0], '# Configure AcmeSync backups');
|
||||
assert.ok(!lines.some((l) => l === '## Contents'));
|
||||
assert.ok(lines.some((l) => l.startsWith('## 1. Open AcmeSync settings')));
|
||||
assert.ok(lines.some((l) => l.startsWith('> **Access**')));
|
||||
assert.ok(lines.includes('> Admins only.'));
|
||||
assert.ok(lines.includes('{.is-warning}'));
|
||||
|
||||
const imgRefs = [...md.matchAll(/!\[[^\]]*\]\(([^)]+)\)/g)].map((m) => m[1]);
|
||||
assert.equal(imgRefs.length, 2);
|
||||
for (const rel of imgRefs) {
|
||||
const img = decodePng(fs.readFileSync(path.join(out, rel)));
|
||||
assert.equal(img.width, 320);
|
||||
}
|
||||
});
|
||||
|
||||
test('Confluence export writes storage-format XML and image attachments', (t) => {
|
||||
const root = makeTmpDir('expconf');
|
||||
t.after(() => rmrf(root));
|
||||
|
||||
Reference in New Issue
Block a user