@j0hanz/superfetch 2.4.0 → 2.4.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.
@@ -149,6 +149,21 @@ function normalizeListsAndSpacing(text) {
149
149
  // Collapse excessive blank lines
150
150
  return text.replace(/\n{3,}/g, '\n\n');
151
151
  }
152
+ function fixConcatenatedProperties(text) {
153
+ const quotedValuePattern = /([a-z_][a-z0-9_]{0,30}\??:\s+)([\u0022\u201C][^\u0022\u201C\u201D]*[\u0022\u201D])([a-z_][a-z0-9_]{0,30}\??:)/g;
154
+ let result = text;
155
+ let iterations = 0;
156
+ const maxIterations = 3;
157
+ while (iterations < maxIterations) {
158
+ const before = result;
159
+ result = result.replace(quotedValuePattern, '$1$2\n\n$3');
160
+ if (result === before) {
161
+ break;
162
+ }
163
+ iterations++;
164
+ }
165
+ return result;
166
+ }
152
167
  const CLEANUP_STEPS = [
153
168
  fixOrphanHeadings,
154
169
  removeEmptyHeadings,
@@ -157,6 +172,7 @@ const CLEANUP_STEPS = [
157
172
  removeTocBlocks,
158
173
  tidyLinksAndEscapes,
159
174
  normalizeListsAndSpacing,
175
+ fixConcatenatedProperties,
160
176
  ];
161
177
  // ─────────────────────────────────────────────────────────────────────────────
162
178
  // Public API
package/dist/mcp.js CHANGED
@@ -22,7 +22,13 @@ function createServerInfo() {
22
22
  return {
23
23
  name: config.server.name,
24
24
  version: config.server.version,
25
- ...(localIcon ? { icons: [{ src: localIcon, sizes: ['any'] }] } : {}),
25
+ ...(localIcon
26
+ ? {
27
+ icons: [
28
+ { src: localIcon, mimeType: 'image/svg+xml', sizes: ['any'] },
29
+ ],
30
+ }
31
+ : {}),
26
32
  };
27
33
  }
28
34
  function createServerCapabilities() {
@@ -63,7 +69,7 @@ export function createMcpServer() {
63
69
  instructions,
64
70
  });
65
71
  setMcpServer(server);
66
- registerTools(server);
72
+ registerTools(server, getLocalIconData());
67
73
  registerCachedContentResource(server);
68
74
  registerInstructionsResource(server, instructions);
69
75
  return server;
package/dist/tools.d.ts CHANGED
@@ -125,5 +125,5 @@ type MarkdownPipelineResult = MarkdownTransformResult & {
125
125
  export declare function parseCachedMarkdownResult(cached: string): MarkdownPipelineResult | undefined;
126
126
  export declare function fetchUrlToolHandler(input: FetchUrlInput, extra?: ToolHandlerExtra): Promise<ToolResponseBase>;
127
127
  export declare function withRequestContextIfMissing<TParams, TResult, TExtra = unknown>(handler: (params: TParams, extra?: TExtra) => Promise<TResult>): (params: TParams, extra?: TExtra) => Promise<TResult>;
128
- export declare function registerTools(server: McpServer): void;
128
+ export declare function registerTools(server: McpServer, serverIcon?: string): void;
129
129
  export {};
package/dist/tools.js CHANGED
@@ -482,12 +482,23 @@ function resolveRequestIdFromExtra(extra) {
482
482
  return String(requestId);
483
483
  return undefined;
484
484
  }
485
- export function registerTools(server) {
485
+ export function registerTools(server, serverIcon) {
486
486
  server.registerTool(TOOL_DEFINITION.name, {
487
487
  title: TOOL_DEFINITION.title,
488
488
  description: TOOL_DEFINITION.description,
489
489
  inputSchema: TOOL_DEFINITION.inputSchema,
490
490
  outputSchema: TOOL_DEFINITION.outputSchema,
491
491
  annotations: TOOL_DEFINITION.annotations,
492
+ ...(serverIcon
493
+ ? {
494
+ icons: [
495
+ {
496
+ src: serverIcon,
497
+ mimeType: 'image/svg+xml',
498
+ sizes: ['any'],
499
+ },
500
+ ],
501
+ }
502
+ : {}),
492
503
  }, withRequestContextIfMissing(TOOL_DEFINITION.handler));
493
504
  }
package/dist/transform.js CHANGED
@@ -519,6 +519,36 @@ function createCustomTranslators() {
519
519
  .join('\n');
520
520
  return { content: items ? `\n${items}\n\n` : '' };
521
521
  },
522
+ div: (ctx) => {
523
+ if (!isObject(ctx) || !isObject(ctx.node)) {
524
+ return {};
525
+ }
526
+ const node = ctx.node;
527
+ const className = typeof node.attribs?.class === 'string' ? node.attribs.class : '';
528
+ if (!className.includes('type')) {
529
+ return {};
530
+ }
531
+ return {
532
+ postprocess: ({ content }) => {
533
+ const lines = content.split('\n');
534
+ const separated = [];
535
+ for (let i = 0; i < lines.length; i++) {
536
+ const line = lines[i] ?? '';
537
+ const nextLine = i < lines.length - 1 ? (lines[i + 1] ?? '') : '';
538
+ separated.push(line);
539
+ if (line.trim() &&
540
+ nextLine.trim() &&
541
+ line.includes(':') &&
542
+ nextLine.includes(':') &&
543
+ !line.startsWith(' ') &&
544
+ !nextLine.startsWith(' ')) {
545
+ separated.push('');
546
+ }
547
+ }
548
+ return separated.join('\n');
549
+ },
550
+ };
551
+ },
522
552
  kbd: () => ({
523
553
  postprocess: ({ content }) => `\`${content}\``,
524
554
  }),
@@ -531,7 +561,8 @@ function createCustomTranslators() {
531
561
  sup: () => ({
532
562
  postprocess: ({ content }) => `^${content}^`,
533
563
  }),
534
- // Fix #6: Handle <pre> without <code> - wrap in fenced code block
564
+ // Note: section translator removed in favor of HTML preprocessing
565
+ // See preprocessPropertySections() for the fix to TypeDoc section spacing
535
566
  pre: (ctx) => buildPreTranslator(ctx),
536
567
  };
537
568
  }
@@ -548,13 +579,18 @@ function getMarkdownConverter() {
548
579
  markdownInstance ??= createMarkdownInstance();
549
580
  return markdownInstance;
550
581
  }
582
+ function preprocessPropertySections(html) {
583
+ const result = html.replace(/<\/section>\s*(<section[^>]*class="[^"]*tsd-panel[^"]*tsd-member[^"]*"[^>]*>)/g, '</section><p>&nbsp;</p>$1');
584
+ return result;
585
+ }
551
586
  function translateHtmlToMarkdown(html, url, signal, document, skipNoiseRemoval) {
552
587
  throwIfAborted(signal, url, 'markdown:begin');
553
588
  const cleanedHtml = skipNoiseRemoval
554
589
  ? html
555
590
  : runTransformStage(url, 'markdown:noise', () => removeNoiseFromHtml(html, document, url));
556
591
  throwIfAborted(signal, url, 'markdown:cleaned');
557
- const content = runTransformStage(url, 'markdown:translate', () => getMarkdownConverter().translate(cleanedHtml).trim());
592
+ const preprocessedHtml = runTransformStage(url, 'markdown:preprocess', () => preprocessPropertySections(cleanedHtml));
593
+ const content = runTransformStage(url, 'markdown:translate', () => getMarkdownConverter().translate(preprocessedHtml).trim());
558
594
  throwIfAborted(signal, url, 'markdown:translated');
559
595
  return cleanupMarkdownArtifacts(content);
560
596
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/superfetch",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "mcpName": "io.github.j0hanz/superfetch",
5
5
  "description": "Intelligent web content fetcher MCP server that converts HTML to clean, AI-readable Markdown",
6
6
  "type": "module",