@memori.ai/memori-react 7.11.0 → 7.11.1

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.
@@ -33,7 +33,7 @@ import markedExtendedTables from '../../helpers/markedExtendedTables';
33
33
  marked.use({
34
34
  async: false,
35
35
  gfm: true,
36
- pedantic: true,
36
+ pedantic: false,
37
37
  renderer: {
38
38
  link: ({ href, title, text }) => {
39
39
  const cleanHref = cleanUrl(href);
@@ -81,37 +81,34 @@ const parseSquaredBrackets = (text: string) => {
81
81
 
82
82
  const renderMsg = (text: string, useMathFormatting = false) => {
83
83
  try {
84
- let parsedText = DOMPurify.sanitize(
85
- (
86
- marked.parse(
87
- text
88
- // remove leading and trailing whitespaces
89
- .trim()
90
- // remove markdown links
91
- .replaceAll(
92
- /\[([^\]]+)\]\(([^\)]+)\)/g,
93
- '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
94
- )
95
- // remove markdown multiline code blocks but keep the content
96
- .replaceAll(/```markdown([^```]+)```/g, '$1')
97
- .replaceAll('($', '( $')
98
- .replaceAll(':$', ': $')
99
- .replaceAll('\frac', '\\frac')
100
- .replaceAll('\beta', '\\beta')
101
- .replaceAll('cdot', '\\cdot')
102
- ) as string
103
- )
104
- .trim()
105
- .replace(/\n/g, '<br>'),
106
- {
107
- ADD_ATTR: ['target'],
108
- }
109
- );
84
+ let parsedText = (
85
+ marked.parse(
86
+ text
87
+ // remove leading and trailing whitespaces
88
+ .trim()
89
+ // remove markdown links
90
+ .replaceAll(
91
+ /\[([^\]]+)\]\(([^\)]+)\)/g,
92
+ '<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'
93
+ )
94
+ // remove markdown multiline code blocks but keep the content
95
+ .replaceAll(/```markdown([^```]+)```/g, '$1')
96
+ .replaceAll('($', '( $')
97
+ .replaceAll(':$', ': $')
98
+ .replaceAll('\frac', '\\frac')
99
+ .replaceAll('\beta', '\\beta')
100
+ .replaceAll('cdot', '\\cdot')
101
+ ) as string
102
+ ).trim();
110
103
 
111
104
  if (useMathFormatting) {
112
- parsedText = parseSquaredBrackets(parsedText);
105
+ parsedText = parseSquaredBrackets(parsedText.replace(/\n/g, '<br>'));
113
106
  }
114
107
 
108
+ parsedText = DOMPurify.sanitize(parsedText, {
109
+ ADD_ATTR: ['target'],
110
+ });
111
+
115
112
  return (
116
113
  parsedText
117
114
  // replace consecutive <br> with a single <br>