expensify-common 2.0.39 → 2.0.41

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.
@@ -449,7 +449,29 @@ class ExpensiMark {
449
449
  {
450
450
  name: 'bold',
451
451
  regex: /<(b|strong)(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)<\/\1>(?![^<]*(<\/pre>|<\/code>))/gi,
452
- replacement: '*$2*',
452
+ replacement: (extras, match, tagName, innerContent) => {
453
+ // To check if style attribute contains bold font-weight
454
+ const isBoldFromStyle = (style) => {
455
+ return style ? style.replace(/\s/g, '').includes('font-weight:bold;') || style.replace(/\s/g, '').includes('font-weight:700;') : false;
456
+ };
457
+ const updateSpacesAndWrapWithAsterisksIfBold = (content, isBold) => {
458
+ const trimmedContent = content.trim();
459
+ const leadingSpace = content.startsWith(' ') ? ' ' : '';
460
+ const trailingSpace = content.endsWith(' ') ? ' ' : '';
461
+ return isBold ? `${leadingSpace}*${trimmedContent}*${trailingSpace}` : content;
462
+ };
463
+ // Determine if the outer tag is bold
464
+ const styleAttributeMatch = match.match(/style="(.*?)"/);
465
+ const isFontWeightBold = isBoldFromStyle(styleAttributeMatch ? styleAttributeMatch[1] : null);
466
+ const isBold = styleAttributeMatch ? isFontWeightBold : tagName === 'b' || tagName === 'strong';
467
+ // Process nested spans with potential bold style
468
+ const processedInnerContent = innerContent.replace(/<span(?:"[^"]*"|'[^']*'|[^'">])*>([\s\S]*?)<\/span>/gi, (nestedMatch, nestedContent) => {
469
+ const nestedStyleMatch = nestedMatch.match(/style="(.*?)"/);
470
+ const isNestedBold = isBoldFromStyle(nestedStyleMatch ? nestedStyleMatch[1] : null);
471
+ return updateSpacesAndWrapWithAsterisksIfBold(nestedContent, isNestedBold);
472
+ });
473
+ return updateSpacesAndWrapWithAsterisksIfBold(processedInnerContent, isBold);
474
+ },
453
475
  },
454
476
  {
455
477
  name: 'strikethrough',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expensify-common",
3
- "version": "2.0.39",
3
+ "version": "2.0.41",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",
@@ -40,7 +40,7 @@
40
40
  "react-dom": "16.12.0",
41
41
  "semver": "^7.6.2",
42
42
  "simply-deferred": "git+https://github.com/Expensify/simply-deferred.git#77a08a95754660c7bd6e0b6979fdf84e8e831bf5",
43
- "ua-parser-js": "^1.0.37"
43
+ "ua-parser-js": "^1.0.38"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@babel/preset-env": "^7.24.5",