@neverprepared/mcp-markdown-to-confluence 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +23 -6
- package/dist/kroki/KrokiDiagramPlugin.js +6 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,10 +18,29 @@ const KROKI_URL = process.env.KROKI_URL ?? 'http://localhost:8371';
|
|
|
18
18
|
// Kroki client
|
|
19
19
|
// ---------------------------------------------------------------------------
|
|
20
20
|
const krokiClient = new KrokiClient(KROKI_URL);
|
|
21
|
+
// Diagram types and their preferred output format
|
|
22
|
+
// PNG is preferred when supported; SVG is the universal fallback
|
|
23
|
+
const KROKI_DIAGRAM_CONFIGS = [
|
|
24
|
+
{ type: 'plantuml', format: 'png' },
|
|
25
|
+
{ type: 'graphviz', format: 'png' },
|
|
26
|
+
{ type: 'dot', format: 'png' },
|
|
27
|
+
{ type: 'ditaa', format: 'svg' },
|
|
28
|
+
{ type: 'nomnoml', format: 'svg' },
|
|
29
|
+
{ type: 'd2', format: 'svg' },
|
|
30
|
+
{ type: 'dbml', format: 'svg' },
|
|
31
|
+
{ type: 'erd', format: 'svg' },
|
|
32
|
+
{ type: 'svgbob', format: 'svg' },
|
|
33
|
+
{ type: 'pikchr', format: 'svg' },
|
|
34
|
+
{ type: 'bytefield', format: 'svg' },
|
|
35
|
+
{ type: 'wavedrom', format: 'svg' },
|
|
36
|
+
{ type: 'vega', format: 'svg' },
|
|
37
|
+
{ type: 'vega-lite', format: 'svg' },
|
|
38
|
+
{ type: 'bpmn', format: 'svg' },
|
|
39
|
+
{ type: 'c4plantuml', format: 'png' },
|
|
40
|
+
];
|
|
21
41
|
const SUPPORTED_DIAGRAM_TYPES = [
|
|
22
|
-
'mermaid',
|
|
23
|
-
|
|
24
|
-
'excalidraw', 'bpmn', 'erd', 'dbml', 'c4plantuml',
|
|
42
|
+
'mermaid',
|
|
43
|
+
...KROKI_DIAGRAM_CONFIGS.map((c) => c.type),
|
|
25
44
|
];
|
|
26
45
|
// ---------------------------------------------------------------------------
|
|
27
46
|
// Confluence client
|
|
@@ -140,9 +159,7 @@ async function publishMarkdown(markdown, title, spaceKey, pageId, parentId, skip
|
|
|
140
159
|
// Run ADF processing pipeline (renders diagrams via Kroki)
|
|
141
160
|
const finalAdf = await executeADFProcessingPipeline([
|
|
142
161
|
new MermaidRendererPlugin(new KrokiMermaidRenderer(krokiClient)),
|
|
143
|
-
...
|
|
144
|
-
.filter((t) => t !== 'mermaid')
|
|
145
|
-
.map((t) => new KrokiDiagramPlugin(t, krokiClient)),
|
|
162
|
+
...KROKI_DIAGRAM_CONFIGS.map((c) => new KrokiDiagramPlugin(c.type, krokiClient, c.format)),
|
|
146
163
|
], adf, publisherFunctions);
|
|
147
164
|
// Update the page with the final ADF
|
|
148
165
|
const updateParams = {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { filter, traverse } from '@atlaskit/adf-utils/traverse';
|
|
2
2
|
import SparkMD5 from 'spark-md5';
|
|
3
|
-
function getDiagramFileName(diagramType, content) {
|
|
3
|
+
function getDiagramFileName(diagramType, content, outputFormat) {
|
|
4
4
|
const text = content ?? `${diagramType} placeholder`;
|
|
5
5
|
const hash = SparkMD5.hash(text);
|
|
6
|
-
const
|
|
6
|
+
const ext = outputFormat === 'png' ? 'png' : 'svg';
|
|
7
|
+
const uploadFilename = `RenderedKrokiChart-${diagramType}-${hash}.${ext}`;
|
|
7
8
|
return { uploadFilename, text };
|
|
8
9
|
}
|
|
9
10
|
export class KrokiDiagramPlugin {
|
|
10
11
|
diagramType;
|
|
11
12
|
client;
|
|
12
13
|
outputFormat;
|
|
13
|
-
constructor(diagramType, client, outputFormat = '
|
|
14
|
+
constructor(diagramType, client, outputFormat = 'svg') {
|
|
14
15
|
this.diagramType = diagramType;
|
|
15
16
|
this.client = client;
|
|
16
17
|
this.outputFormat = outputFormat;
|
|
@@ -19,7 +20,7 @@ export class KrokiDiagramPlugin {
|
|
|
19
20
|
const nodes = filter(adf, (node) => node.type === 'codeBlock' &&
|
|
20
21
|
(node.attrs || {})?.['language'] === this.diagramType);
|
|
21
22
|
const charts = new Set(nodes.map((node) => {
|
|
22
|
-
const details = getDiagramFileName(this.diagramType, node?.content?.at(0)?.text);
|
|
23
|
+
const details = getDiagramFileName(this.diagramType, node?.content?.at(0)?.text, this.outputFormat);
|
|
23
24
|
return {
|
|
24
25
|
name: details.uploadFilename,
|
|
25
26
|
data: details.text,
|
|
@@ -52,7 +53,7 @@ export class KrokiDiagramPlugin {
|
|
|
52
53
|
if (!content) {
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
|
-
const filename = getDiagramFileName(this.diagramType, content);
|
|
56
|
+
const filename = getDiagramFileName(this.diagramType, content, this.outputFormat);
|
|
56
57
|
if (!imageMap[filename.uploadFilename]) {
|
|
57
58
|
return;
|
|
58
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neverprepared/mcp-markdown-to-confluence",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "MCP server for converting markdown to Confluence ADF and publishing pages with diagram support via Kroki",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|