md-annotator-opencode 0.6.0 → 0.8.0

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 CHANGED
@@ -26965,12 +26965,28 @@ function getHeartbeatTimeoutMs() {
26965
26965
  }
26966
26966
  return DEFAULT_HEARTBEAT_TIMEOUT_MS;
26967
26967
  }
26968
+ function getPlantumlServerUrl() {
26969
+ const envUrl = process.env.PLANTUML_SERVER_URL;
26970
+ if (envUrl) {
26971
+ return envUrl.replace(/\/+$/, "");
26972
+ }
26973
+ return "https://www.plantuml.com/plantuml";
26974
+ }
26975
+ function getKrokiServerUrl() {
26976
+ const envUrl = process.env.KROKI_SERVER_URL;
26977
+ if (envUrl) {
26978
+ return envUrl.replace(/\/+$/, "");
26979
+ }
26980
+ return "https://kroki.io";
26981
+ }
26968
26982
  var config = {
26969
26983
  port: getServerPort(),
26970
26984
  browser: process.env.MD_ANNOTATOR_BROWSER || null,
26971
26985
  heartbeatTimeoutMs: getHeartbeatTimeoutMs(),
26972
26986
  forceExitTimeoutMs: 5e3,
26973
- jsonLimit: "10mb"
26987
+ jsonLimit: "10mb",
26988
+ plantumlServerUrl: getPlantumlServerUrl(),
26989
+ krokiServerUrl: getKrokiServerUrl()
26974
26990
  };
26975
26991
 
26976
26992
  // ../../server/routes.js
@@ -27028,16 +27044,37 @@ function formatAnnotation(ann, block, heading) {
27028
27044
  `;
27029
27045
  } else {
27030
27046
  output2 += `> ${(ann.text ?? "").replace(/\n/g, "\n> ")}
27047
+ `;
27048
+ }
27049
+ return output2 + "\n";
27050
+ }
27051
+ if (ann.targetType === "pinpoint") {
27052
+ const isDeletion = ann.type === "DELETION";
27053
+ const label = isDeletion ? "Remove block" : "Comment on block";
27054
+ let output2 = `${heading} ${label} (Line ${blockStartLine})
27055
+ `;
27056
+ const preview = ((block == null ? void 0 : block.content) || ann.originalText || "").slice(0, 200);
27057
+ output2 += `\`\`\`
27058
+ ${preview}
27059
+ \`\`\`
27060
+ `;
27061
+ if (isDeletion) {
27062
+ output2 += `> User wants this block removed from the document.
27063
+ `;
27064
+ } else {
27065
+ output2 += `> ${(ann.text ?? "").replace(/\n/g, "\n> ")}
27031
27066
  `;
27032
27067
  }
27033
27068
  return output2 + "\n";
27034
27069
  }
27035
27070
  if (ann.targetType === "diagram") {
27036
27071
  const isDeletion = ann.type === "DELETION";
27037
- const label = isDeletion ? "Remove Mermaid diagram" : "Comment on Mermaid diagram";
27072
+ const diagramLang = (block == null ? void 0 : block.language) === "plantuml" ? "PlantUML" : "Mermaid";
27073
+ const fence = (block == null ? void 0 : block.language) === "plantuml" ? "plantuml" : "mermaid";
27074
+ const label = isDeletion ? `Remove ${diagramLang} diagram` : `Comment on ${diagramLang} diagram`;
27038
27075
  let output2 = `${heading} ${label} (Line ${blockStartLine})
27039
27076
  `;
27040
- output2 += `\`\`\`mermaid
27077
+ output2 += `\`\`\`${fence}
27041
27078
  ${(block == null ? void 0 : block.content) || ann.originalText}
27042
27079
  \`\`\`
27043
27080
  `;
@@ -27272,7 +27309,7 @@ function createApiRouter(filePaths, resolveDecision, origin = "cli", stores = []
27272
27309
  };
27273
27310
  })
27274
27311
  );
27275
- res.json(success({ files, origin }));
27312
+ res.json(success({ files, origin, config: { plantumlServerUrl: config.plantumlServerUrl, krokiServerUrl: config.krokiServerUrl } }));
27276
27313
  } catch (error) {
27277
27314
  res.status(500).json(failure(error.message));
27278
27315
  }
@@ -27439,6 +27476,20 @@ var HTML_VOID_TAGS = /* @__PURE__ */ new Set([
27439
27476
  "track",
27440
27477
  "wbr"
27441
27478
  ]);
27479
+ var HTML_MIXED_CONTENT_TAGS = /* @__PURE__ */ new Set([
27480
+ "div",
27481
+ "section",
27482
+ "details",
27483
+ "aside",
27484
+ "article",
27485
+ "figure",
27486
+ "figcaption",
27487
+ "header",
27488
+ "footer",
27489
+ "main",
27490
+ "nav",
27491
+ "center"
27492
+ ]);
27442
27493
  function parseMarkdownToBlocks(markdown) {
27443
27494
  var _a, _b;
27444
27495
  const lines = markdown.split("\n");
@@ -27613,10 +27664,52 @@ function parseMarkdownToBlocks(markdown) {
27613
27664
  flush();
27614
27665
  const tagName = tagMatch[1].toLowerCase();
27615
27666
  const htmlStartLine = currentLineNum;
27616
- const htmlLines = [line];
27617
27667
  const isSelfClosing = trimmed.endsWith("/>");
27618
27668
  const isVoid = HTML_VOID_TAGS.has(tagName);
27619
27669
  const hasSameLineClose = new RegExp(`</${tagName}\\s*>`, "i").test(trimmed);
27670
+ if (!isSelfClosing && !isVoid && !hasSameLineClose && HTML_MIXED_CONTENT_TAGS.has(tagName)) {
27671
+ const closePattern = new RegExp(`</${tagName}\\s*>`, "i");
27672
+ const openPattern = new RegExp(`<${tagName}[\\s>/]`, "i");
27673
+ const innerLines = [];
27674
+ let closingLine = null;
27675
+ let depth = 1;
27676
+ i++;
27677
+ while (i < lines.length) {
27678
+ if (openPattern.test(lines[i].trim())) {
27679
+ depth++;
27680
+ }
27681
+ if (closePattern.test(lines[i].trim())) {
27682
+ depth--;
27683
+ if (depth === 0) {
27684
+ closingLine = lines[i];
27685
+ break;
27686
+ }
27687
+ }
27688
+ innerLines.push(lines[i]);
27689
+ i++;
27690
+ }
27691
+ blocks.push({
27692
+ id: `block-${currentId++}`,
27693
+ type: "html",
27694
+ content: line,
27695
+ order: currentId,
27696
+ startLine: htmlStartLine
27697
+ });
27698
+ for (const inner of parseMarkdownToBlocks(innerLines.join("\n"))) {
27699
+ blocks.push({ ...inner, id: `block-${currentId++}`, order: currentId, startLine: htmlStartLine + inner.startLine });
27700
+ }
27701
+ if (closingLine) {
27702
+ blocks.push({
27703
+ id: `block-${currentId++}`,
27704
+ type: "html",
27705
+ content: closingLine,
27706
+ order: currentId,
27707
+ startLine: htmlStartLine + innerLines.length + 1
27708
+ });
27709
+ }
27710
+ continue;
27711
+ }
27712
+ const htmlLines = [line];
27620
27713
  if (!isSelfClosing && !isVoid && !hasSameLineClose) {
27621
27714
  const closePattern = new RegExp(`</${tagName}\\s*>`, "i");
27622
27715
  const openPattern = new RegExp(`<${tagName}[\\s>/]`, "i");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-annotator-opencode",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "OpenCode plugin for interactive markdown annotation",
5
5
  "license": "MIT",
6
6
  "type": "module",