@hivegpt/hiveai-angular 0.0.61 → 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,42 +1266,28 @@
1266
1266
  };
1267
1267
  // events/${eventId}/users-connections
1268
1268
  // Simple Markdown to HTML parser
1269
- ChatDrawerComponent.prototype.simpleMarkdownParser = function (markdownContent) {
1270
- if (!markdownContent)
1269
+ ChatDrawerComponent.prototype.simpleMarkdownParser = function (markdown) {
1270
+ if (!markdown || !(markdown.length > 0)) {
1271
1271
  return '';
1272
- var html = String(markdownContent).trim(); // Ensure it's treated as a string and trim any extra spaces
1273
- // Convert headings
1274
- html = html.replace(/^(###### (.*))$/gim, '<h6>$2</h6>');
1275
- html = html.replace(/^(##### (.*))$/gim, '<h5>$2</h5>');
1276
- html = html.replace(/^(#### (.*))$/gim, '<h4>$2</h4>');
1277
- html = html.replace(/^(### (.*))$/gim, '<h3>$2</h3>');
1278
- html = html.replace(/^(## (.*))$/gim, '<h2>$2</h2>');
1279
- html = html.replace(/^(# (.*))$/gim, '<h1>$2</h1>');
1280
- // Convert bold and italic
1281
- html = html.replace(/\*\*\*(.*?)\*\*\*/gim, '<em><strong>$1</strong></em>');
1282
- html = html.replace(/\*\*(.*?)\*\*/gim, '<strong>$1</strong>');
1283
- html = html.replace(/\*(.*?)\*/gim, '<em>$1</em>');
1284
- // Convert links
1285
- html = html.replace(/\[(.*?)\]\((.*?)\)/gim, '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>');
1286
- // Convert unordered lists
1287
- html = html.replace(/^\* (.*)$/gim, '<ul><li>$1</li></ul>');
1288
- html = html.replace(/^\- (.*)$/gim, '<ul><li>$1</li></ul>');
1289
- html = html.replace(/^\+ (.*)$/gim, '<ul><li>$1</li></ul>');
1290
- // Convert ordered lists
1291
- html = html.replace(/^\d+\. (.*)$/gim, '<ol><li>$1</li></ol>');
1292
- // Combine multiple list items in one list element
1293
- html = html.replace(/(<ul><li>.*<\/li><\/ul>)/gim, function (match) {
1294
- return "<ul>" + match.replace(/<\/li><li>/gim, '</li><li>') + "</ul>";
1295
- });
1296
- html = html.replace(/(<ol><li>.*<\/li><\/ol>)/gim, function (match) {
1297
- return "<ol>" + match.replace(/<\/li><li>/gim, '</li><li>') + "</ol>";
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 + ">";
1298
1277
  });
1299
- return html.trim();
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;
1300
1287
  };
1301
1288
  // Convert Markdown to SafeHtml
1302
1289
  ChatDrawerComponent.prototype.handleMarkdown = function (markdownContent) {
1303
- var htmlContent = this.simpleMarkdownParser(markdownContent);
1304
- return this.sanitizer.bypassSecurityTrustHtml(htmlContent);
1290
+ return this.sanitizer.bypassSecurityTrustHtml(markdownContent);
1305
1291
  };
1306
1292
  return ChatDrawerComponent;
1307
1293
  }());