@karmaniverous/jeeves-server 3.1.0 → 3.1.2

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.
@@ -6,7 +6,7 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <meta name="robots" content="noindex, nofollow" />
8
8
  <title>Jeeves Server</title>
9
- <script type="module" crossorigin src="/app/assets/index-fY6PleHE.js"></script>
9
+ <script type="module" crossorigin src="/app/assets/index-Bk4tUE4j.js"></script>
10
10
  <link rel="stylesheet" crossorigin href="/app/assets/index-D-RC7ZS6.css">
11
11
  </head>
12
12
  <body>
@@ -83,6 +83,10 @@ export function parseMarkdown(markdown, options = {}) {
83
83
  const text = typeof args === 'object' ? args.text : args;
84
84
  const raw = typeof args === 'object' && args.raw ? args.raw : text;
85
85
  const level = typeof args === 'object' ? args.depth : 1;
86
+ // Parse inline tokens to render code spans, bold, italic, links, etc.
87
+ const renderedText = typeof args === 'object' && args.tokens
88
+ ? this.parser.parseInline(args.tokens)
89
+ : text;
86
90
  const slug = raw
87
91
  .toLowerCase()
88
92
  .replace(/<[^>]+>/g, '')
@@ -90,8 +94,12 @@ export function parseMarkdown(markdown, options = {}) {
90
94
  .replace(/\s+/g, '-')
91
95
  .replace(/-+/g, '-')
92
96
  .replace(/^-|-$/g, '');
93
- headings.push({ level, text: text.replace(/<[^>]+>/g, ''), slug });
94
- return `<h${String(level)} id="${slug}">${text} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
97
+ headings.push({
98
+ level,
99
+ text: renderedText.replace(/<[^>]+>/g, ''),
100
+ slug,
101
+ });
102
+ return `<h${String(level)} id="${slug}">${renderedText} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
95
103
  };
96
104
  // Rewrite relative image src to /path/ URLs
97
105
  if (options.basePath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karmaniverous/jeeves-server",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Secure file browser, markdown viewer, and webhook gateway with PDF/DOCX export and expiring share links",
5
5
  "keywords": [
6
6
  "fastify",
@@ -4,6 +4,7 @@
4
4
 
5
5
  import fs from 'node:fs';
6
6
 
7
+ import type { Token } from 'marked';
7
8
  import { marked } from 'marked';
8
9
 
9
10
  import { registerDiagram } from './embeddedDiagrams.js';
@@ -105,12 +106,25 @@ export function parseMarkdown(
105
106
  const renderer = new marked.Renderer();
106
107
 
107
108
  renderer.heading = function (
108
- args: string | { text: string; raw?: string; depth: number },
109
+ args:
110
+ | string
111
+ | {
112
+ text: string;
113
+ raw?: string;
114
+ depth: number;
115
+ tokens?: Token[];
116
+ },
109
117
  ) {
110
118
  const text = typeof args === 'object' ? args.text : args;
111
119
  const raw = typeof args === 'object' && args.raw ? args.raw : text;
112
120
  const level = typeof args === 'object' ? args.depth : 1;
113
121
 
122
+ // Parse inline tokens to render code spans, bold, italic, links, etc.
123
+ const renderedText =
124
+ typeof args === 'object' && args.tokens
125
+ ? this.parser.parseInline(args.tokens)
126
+ : text;
127
+
114
128
  const slug = raw
115
129
  .toLowerCase()
116
130
  .replace(/<[^>]+>/g, '')
@@ -119,9 +133,13 @@ export function parseMarkdown(
119
133
  .replace(/-+/g, '-')
120
134
  .replace(/^-|-$/g, '');
121
135
 
122
- headings.push({ level, text: text.replace(/<[^>]+>/g, ''), slug });
136
+ headings.push({
137
+ level,
138
+ text: renderedText.replace(/<[^>]+>/g, ''),
139
+ slug,
140
+ });
123
141
 
124
- return `<h${String(level)} id="${slug}">${text} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
142
+ return `<h${String(level)} id="${slug}">${renderedText} <a href="#${slug}" class="anchor">#</a></h${String(level)}>\n`;
125
143
  };
126
144
 
127
145
  // Rewrite relative image src to /path/ URLs