@hivegpt/hiveai-angular 0.0.61 → 0.0.63

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.
@@ -1265,43 +1265,24 @@
1265
1265
  }));
1266
1266
  };
1267
1267
  // events/${eventId}/users-connections
1268
- // Simple Markdown to HTML parser
1269
- ChatDrawerComponent.prototype.simpleMarkdownParser = function (markdownContent) {
1270
- if (!markdownContent)
1268
+ ChatDrawerComponent.prototype.handleMarkdown = function (markdown) {
1269
+ if (!markdown || !(markdown.length > 0)) {
1271
1270
  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>";
1271
+ }
1272
+ // Convert Markdown headers to HTML headers
1273
+ var html = markdown.replace(/^(#{1,6})\s+(.*)$/gm, function (match, hashes, text) {
1274
+ var level = hashes.length;
1275
+ return "<h" + level + ">" + text + "</h" + level + ">";
1298
1276
  });
1299
- return html.trim();
1300
- };
1301
- // Convert Markdown to SafeHtml
1302
- ChatDrawerComponent.prototype.handleMarkdown = function (markdownContent) {
1303
- var htmlContent = this.simpleMarkdownParser(markdownContent);
1304
- return this.sanitizer.bypassSecurityTrustHtml(htmlContent);
1277
+ // Convert Markdown links to HTML links
1278
+ html = html.replace(/\[([^\]]+)]\(([^)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
1279
+ // Convert Markdown bold to HTML strong
1280
+ html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
1281
+ // Convert new lines to <br> tags
1282
+ html = html.replace(/(?:\r\n|\r|\n)/g, '<br>');
1283
+ // Optional: Sanitize the HTML to prevent XSS
1284
+ var sanitizedHtml = this.sanitizeHtml(html);
1285
+ return sanitizedHtml;
1305
1286
  };
1306
1287
  return ChatDrawerComponent;
1307
1288
  }());