@hivegpt/hiveai-angular 0.0.60 → 0.0.62

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.
@@ -1266,38 +1266,28 @@
1266
1266
  };
1267
1267
  // events/${eventId}/users-connections
1268
1268
  // Simple Markdown to HTML parser
1269
- // Simple Markdown to HTML parser
1270
- ChatDrawerComponent.prototype.simpleMarkdownParser = function (markdownContent) {
1271
- if (!markdownContent)
1269
+ ChatDrawerComponent.prototype.simpleMarkdownParser = function (markdown) {
1270
+ if (!markdown || !(markdown.length > 0)) {
1272
1271
  return '';
1273
- var html = String(markdownContent).trim(); // Ensure it's treated as a string and trim any extra spaces
1274
- // Convert headings
1275
- html = html.replace(/^(###### .*)$/gim, '<h6>$1</h6>');
1276
- html = html.replace(/^(##### .*)$/gim, '<h5>$1</h5>');
1277
- html = html.replace(/^(#### .*)$/gim, '<h4>$1</h4>');
1278
- html = html.replace(/^(### .*)$/gim, '<h3>$1</h3>');
1279
- html = html.replace(/^(## .*)$/gim, '<h2>$1</h2>');
1280
- html = html.replace(/^(# .*)$/gim, '<h1>$1</h1>');
1281
- // Convert bold and italic
1282
- html = html.replace(/\*\*\*(.*?)\*\*\*/gim, '<em><strong>$1</strong></em>');
1283
- html = html.replace(/\*\*(.*?)\*\*/gim, '<strong>$1</strong>');
1284
- html = html.replace(/\*(.*?)\*/gim, '<em>$1</em>');
1285
- // Convert links
1286
- html = html.replace(/\[(.*?)\]\((.*?)\)/gim, '<a href="$2">$1</a>');
1287
- // Convert unordered lists
1288
- html = html.replace(/^\* (.*)/gim, '<ul><li>$1</li></ul>');
1289
- html = html.replace(/^\- (.*)/gim, '<ul><li>$1</li></ul>');
1290
- html = html.replace(/^\+ (.*)/gim, '<ul><li>$1</li></ul>');
1291
- // Convert ordered lists
1292
- html = html.replace(/^\d+\. (.*)/gim, '<ol><li>$1</li></ol>');
1293
- // Convert line breaks
1294
- html = html.replace(/\n/gim, '<br/>');
1295
- return html.trim();
1272
+ }
1273
+ // Convert Markdown headers to HTML headers
1274
+ var html = markdown.replace(/^(#{1,6})\s+(.*)$/gm, function (match, hashes, text) {
1275
+ var level = hashes.length;
1276
+ return "<h" + level + ">" + text + "</h" + level + ">";
1277
+ });
1278
+ // Convert Markdown links to HTML links
1279
+ html = html.replace(/\[([^\]]+)]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
1280
+ // Convert Markdown bold to HTML strong
1281
+ html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
1282
+ // Convert new lines to <br> tags
1283
+ html = html.replace(/(?:\r\n|\r|\n)/g, '<br>');
1284
+ // Optional: Sanitize the HTML to prevent XSS
1285
+ var sanitizedHtml = this.sanitizeHtml(html);
1286
+ return sanitizedHtml;
1296
1287
  };
1297
1288
  // Convert Markdown to SafeHtml
1298
1289
  ChatDrawerComponent.prototype.handleMarkdown = function (markdownContent) {
1299
- var htmlContent = this.simpleMarkdownParser(markdownContent);
1300
- return this.sanitizer.bypassSecurityTrustHtml(htmlContent);
1290
+ return this.sanitizer.bypassSecurityTrustHtml(markdownContent);
1301
1291
  };
1302
1292
  return ChatDrawerComponent;
1303
1293
  }());