@revenuecat/purchases-ui-js 4.5.1 → 4.5.2

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.
@@ -61,6 +61,11 @@ export function getTextWrapperInlineStyles(colorMode, _restProps, size, backgrou
61
61
  export function getHtmlFromMarkdown(text) {
62
62
  if (!text)
63
63
  return "";
64
+ const escapedMarkdownCharacters = [];
65
+ const textWithEscapedMarkdownPlaceholders = text.replaceAll(/\\([\\`*_[\]{}()#+\-.!~])/g, (_, escapedCharacter) => {
66
+ escapedMarkdownCharacters.push(escapedCharacter);
67
+ return `\0RC_ESCAPED_MARKDOWN_${escapedMarkdownCharacters.length - 1}\0`;
68
+ });
64
69
  const regexpDictionary = {
65
70
  newLine: { regexp: /\\\n/g, output: "<br/>" },
66
71
  bold: { regexp: /\*\*(.*?)\*\*/g, output: "<b>$1</b>" },
@@ -75,7 +80,8 @@ export function getHtmlFromMarkdown(text) {
75
80
  output: "<a href=$2 target='_blank' rel='noopener noreferrer'>$1</a>",
76
81
  },
77
82
  };
78
- return Object.values(regexpDictionary).reduce((parsedText, { regexp, output }) => {
83
+ const parsedText = Object.values(regexpDictionary).reduce((parsedText, { regexp, output }) => {
79
84
  return parsedText.replaceAll(regexp, output);
80
- }, text);
85
+ }, textWithEscapedMarkdownPlaceholders);
86
+ return escapedMarkdownCharacters.reduce((restoredText, escapedMarkdownCharacter, index) => restoredText.replaceAll(`\0RC_ESCAPED_MARKDOWN_${index}\0`, escapedMarkdownCharacter), parsedText);
81
87
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@revenuecat/purchases-ui-js",
3
3
  "description": "Web components for Paywalls. Powered by RevenueCat",
4
4
  "private": false,
5
- "version": "4.5.1",
5
+ "version": "4.5.2",
6
6
  "author": {
7
7
  "name": "RevenueCat, Inc."
8
8
  },