@buerokratt-ria/common-gui-components 0.0.29 → 0.0.30

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@ All changes to this project will be documented in this file.
4
4
 
5
5
  ## Template [MajorVersion.MediterraneanVersion.MinorVersion] - DD-MM-YYYY
6
6
 
7
+ ## [0.0.30] - 10-11-2025
8
+
9
+ - Enhanced Markdownify
10
+
7
11
  ## [0.0.29] - 03-11-2025
8
12
 
9
13
  - Added Language to chats/ended/download
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerokratt-ria/common-gui-components",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "Common GUI components and pre defined templates.",
5
5
  "main": "index.ts",
6
6
  "author": "ExiRai",
@@ -43,6 +43,25 @@ const LinkPreview: React.FC<{
43
43
 
44
44
  const hasSpecialFormat = (m: string) => m.includes("\n\n") && m.indexOf(".") > 0 && m.indexOf(":") > m.indexOf(".");
45
45
 
46
+ function formatMessage(message?: string): string {
47
+ if (!message) return "";
48
+
49
+ return message
50
+ .replace(/&#x([0-9A-Fa-f]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
51
+ .replace(/(^|\n)(\d{4})\.\s/g, (match, prefix, year) => {
52
+ const remainingText = message.substring(message.indexOf(match) + match.length);
53
+ const sentenceEnd = remainingText.indexOf("\n\n");
54
+ if (sentenceEnd !== -1) {
55
+ const currentSentence = remainingText.substring(0, sentenceEnd);
56
+ if (currentSentence.trim().endsWith(":")) {
57
+ return `${prefix}${year}. `;
58
+ }
59
+ }
60
+ return `${prefix}${year}\\. `;
61
+ })
62
+ .replace(/(?<=\n)\d+\.\s/g, hasSpecialFormat(message) ? "\n\n$&" : "$&");
63
+ }
64
+
46
65
  const Markdownify: React.FC<MarkdownifyProps> = ({ message, sanitizeLinks = false }) => (
47
66
  <div className={"reset"}>
48
67
  <Markdown
@@ -59,9 +78,7 @@ const Markdownify: React.FC<MarkdownifyProps> = ({ message, sanitizeLinks = fals
59
78
  disableParsingRawHTML: true,
60
79
  }}
61
80
  >
62
- {message
63
- ?.replace(/&#x([0-9A-Fa-f]+);/g, (_, hex) => String.fromCharCode(parseInt(hex, 16)))
64
- ?.replace(/(?<=\n)\d+\.\s/g, hasSpecialFormat(message) ? "\n\n$&" : "$&") ?? ""}
81
+ {formatMessage(message)}
65
82
  </Markdown>
66
83
  </div>
67
84
  );