glad-web 1.0.38 → 1.0.39

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.
Files changed (2) hide show
  1. package/lib/web/claude.js +22 -8
  2. package/package.json +1 -1
package/lib/web/claude.js CHANGED
@@ -486,15 +486,29 @@
486
486
  }
487
487
 
488
488
  function inlineMarkdown(text) {
489
+ const protectedSegments = [];
490
+ const protect = value => `\uE000${protectedSegments.push(value) - 1}\uE001`;
491
+ const restore = value => value.replace(/\uE000(\d+)\uE001/g, (_match, index) => protectedSegments[Number(index)] || '');
492
+ const formatText = value => {
493
+ const codeSegments = [];
494
+ const protectCode = code => `\uE002${codeSegments.push(code) - 1}\uE003`;
495
+ const restoreCode = formatted => formatted.replace(/\uE002(\d+)\uE003/g, (_match, index) => codeSegments[Number(index)] || '');
496
+ let formatted = value.replace(/`([^`]+)`/g, (_match, code) => protectCode(`<code>${code}</code>`));
497
+ formatted = formatted.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
498
+ formatted = formatted.replace(/(^|[^\p{L}\p{N}_])__([^_\n]+)__(?![\p{L}\p{N}_])/gu, '$1<strong>$2</strong>');
499
+ formatted = formatted.replace(/\*([^*\n]+)\*/g, '<em>$1</em>');
500
+ formatted = formatted.replace(/(^|[^\p{L}\p{N}_])_([^_\n]+)_(?![\p{L}\p{N}_])/gu, '$1<em>$2</em>');
501
+ return restoreCode(formatted);
502
+ };
503
+
489
504
  let html = escapeHtml(text || '');
490
- html = html.replace(/`([^`]+)`/g, '<code>$1</code>');
491
- html = html.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
492
- html = html.replace(/__([^_]+)__/g, '<strong>$1</strong>');
493
- html = html.replace(/\*([^*\n]+)\*/g, '<em>$1</em>');
494
- html = html.replace(/_([^_\n]+)_/g, '<em>$1</em>');
495
- html = html.replace(/!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)/g, '<img src="$2" alt="$1">');
496
- html = html.replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
497
- return html;
505
+ html = html.replace(/`([^`]+)`|!\[([^\]]*)\]\((https?:\/\/[^)\s]+)\)|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,
506
+ (_match, code, alt, imageUrl, label, linkUrl) => {
507
+ if (code !== undefined) return protect(`<code>${code}</code>`);
508
+ if (imageUrl !== undefined) return protect(`<img src="${imageUrl}" alt="${alt}">`);
509
+ return protect(`<a href="${linkUrl}" target="_blank" rel="noopener noreferrer">${formatText(label)}</a>`);
510
+ });
511
+ return restore(formatText(html));
498
512
  }
499
513
 
500
514
  function parseMarkdownFenceOpener(line) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glad-web",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "Glad transforms terminal-based AI coding tools into a polished, mobile-friendly local Web interface.",
5
5
  "bin": {
6
6
  "glad": "bin/cli.js"