test('Test for backticks with no content', () => {
const testString = '` `';
diff --git a/__tests__/ExpensiMark-Markdown-test.js b/__tests__/ExpensiMark-Markdown-test.js
index 297c8971..1ebfd21a 100644
--- a/__tests__/ExpensiMark-Markdown-test.js
+++ b/__tests__/ExpensiMark-Markdown-test.js
@@ -7,10 +7,12 @@ test('Test bold HTML replacement', () => {
const boldTestStartString = 'This is a sentence, and it has some punctuation, words, and spaces. '
+ 'test * testing* test*test*test. * testing * *testing * '
+ 'This is a sentence, and it has some punctuation, words, and spaces. '
+ + 'This is a bold sentence with style '
+ 'test * testing* test*test*test. * testing * *testing *';
const boldTestReplacedString = 'This is a *sentence,* and it has some *punctuation, words, and spaces*. '
+ '*test* * testing* test*test*test. * testing * *testing * '
+ 'This is a *sentence,* and it has some *punctuation, words, and spaces*. '
+ + 'This is a *bold sentence with style* '
+ '*test* * testing* test*test*test. * testing * *testing *';
expect(parser.htmlToMarkdown(boldTestStartString)).toBe(boldTestReplacedString);
diff --git a/lib/ExpensiMark.ts b/lib/ExpensiMark.ts
index 4310f88e..48e05b0d 100644
--- a/lib/ExpensiMark.ts
+++ b/lib/ExpensiMark.ts
@@ -190,8 +190,8 @@ export default class ExpensiMark {
// Use the url escaped version of a backtick (`) symbol. Mobile platforms do not support lookbehinds,
// so capture the first and third group and place them in the replacement.
// but we should not replace backtick symbols if they include tags between them.
- regex: /(\B|_|)`(.*?(?![`])\S.*?)`(\B|_|)(?!`|[^<]*<\/pre>|[^<]*<\/video>)/gm,
- replacement: '$1$2
$3',
+ regex: /(\B|_|)`((?:`)*)(?!`)(.*?\S+?.*?)(?|[^<]*<\/video>)/gm,
+ replacement: '$1$2$3$4
$6',
},
/**
@@ -576,13 +576,14 @@ export default class ExpensiMark {
};
// Determine if the outer tag is bold
- const styleAttributeMatch = match.match(/style="(.*?)"/);
+ const fontWeightRegex = /style="([^"]*?\bfont-weight:\s*(\d+|bold|normal)[^"]*?)"/;
+ const styleAttributeMatch = match.match(fontWeightRegex);
const isFontWeightBold = isBoldFromStyle(styleAttributeMatch ? styleAttributeMatch[1] : null);
const isBold = styleAttributeMatch ? isFontWeightBold : tagName === 'b' || tagName === 'strong';
// Process nested spans with potential bold style
const processedInnerContent = innerContent.replace(/])*>([\s\S]*?)<\/span>/gi, (nestedMatch, nestedContent) => {
- const nestedStyleMatch = nestedMatch.match(/style="(.*?)"/);
+ const nestedStyleMatch = nestedMatch.match(fontWeightRegex);
const isNestedBold = isBoldFromStyle(nestedStyleMatch ? nestedStyleMatch[1] : null);
return updateSpacesAndWrapWithAsterisksIfBold(nestedContent, isNestedBold);
});
diff --git a/package-lock.json b/package-lock.json
index d9ad2650..fcb3ee42 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "expensify-common",
- "version": "2.0.76",
+ "version": "2.0.79",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "expensify-common",
- "version": "2.0.76",
+ "version": "2.0.79",
"license": "MIT",
"dependencies": {
"awesome-phonenumber": "^5.4.0",
@@ -33,7 +33,7 @@
"@types/react-dom": "^18.3.0",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^7.18.0",
- "@typescript-eslint/parser": "^7.17.0",
+ "@typescript-eslint/parser": "^7.18.0",
"babel-jest": "^29.0.0",
"babelify": "10.0.0",
"eslint": "^8.57.0",
@@ -3139,16 +3139,16 @@
}
},
"node_modules/@typescript-eslint/parser": {
- "version": "7.17.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.17.0.tgz",
- "integrity": "sha512-puiYfGeg5Ydop8eusb/Hy1k7QmOU6X3nvsqCgzrB2K4qMavK//21+PzNE8qeECgNOIoertJPUC1SpegHDI515A==",
+ "version": "7.18.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.18.0.tgz",
+ "integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
"dev": true,
"license": "BSD-2-Clause",
"dependencies": {
- "@typescript-eslint/scope-manager": "7.17.0",
- "@typescript-eslint/types": "7.17.0",
- "@typescript-eslint/typescript-estree": "7.17.0",
- "@typescript-eslint/visitor-keys": "7.17.0",
+ "@typescript-eslint/scope-manager": "7.18.0",
+ "@typescript-eslint/types": "7.18.0",
+ "@typescript-eslint/typescript-estree": "7.18.0",
+ "@typescript-eslint/visitor-keys": "7.18.0",
"debug": "^4.3.4"
},
"engines": {
@@ -3167,124 +3167,6 @@
}
}
},
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
- "version": "7.17.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.17.0.tgz",
- "integrity": "sha512-0P2jTTqyxWp9HiKLu/Vemr2Rg1Xb5B7uHItdVZ6iAenXmPo4SZ86yOPCJwMqpCyaMiEHTNqizHfsbmCFT1x9SA==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@typescript-eslint/types": "7.17.0",
- "@typescript-eslint/visitor-keys": "7.17.0"
- },
- "engines": {
- "node": "^18.18.0 || >=20.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
- "version": "7.17.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.17.0.tgz",
- "integrity": "sha512-a29Ir0EbyKTKHnZWbNsrc/gqfIBqYPwj3F2M+jWE/9bqfEHg0AMtXzkbUkOG6QgEScxh2+Pz9OXe11jHDnHR7A==",
- "dev": true,
- "license": "MIT",
- "engines": {
- "node": "^18.18.0 || >=20.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
- "version": "7.17.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.17.0.tgz",
- "integrity": "sha512-72I3TGq93t2GoSBWI093wmKo0n6/b7O4j9o8U+f65TVD0FS6bI2180X5eGEr8MA8PhKMvYe9myZJquUT2JkCZw==",
- "dev": true,
- "license": "BSD-2-Clause",
- "dependencies": {
- "@typescript-eslint/types": "7.17.0",
- "@typescript-eslint/visitor-keys": "7.17.0",
- "debug": "^4.3.4",
- "globby": "^11.1.0",
- "is-glob": "^4.0.3",
- "minimatch": "^9.0.4",
- "semver": "^7.6.0",
- "ts-api-utils": "^1.3.0"
- },
- "engines": {
- "node": "^18.18.0 || >=20.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- },
- "peerDependenciesMeta": {
- "typescript": {
- "optional": true
- }
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
- "version": "7.17.0",
- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.17.0.tgz",
- "integrity": "sha512-RVGC9UhPOCsfCdI9pU++K4nD7to+jTcMIbXTSOcrLqUEW6gF2pU1UUbYJKc9cvcRSK1UDeMJ7pdMxf4bhMpV/A==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@typescript-eslint/types": "7.17.0",
- "eslint-visitor-keys": "^3.4.3"
- },
- "engines": {
- "node": "^18.18.0 || >=20.0.0"
- },
- "funding": {
- "type": "opencollective",
- "url": "https://opencollective.com/typescript-eslint"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "balanced-match": "^1.0.0"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/eslint-visitor-keys": {
- "version": "3.4.3",
- "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
- "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
- "dev": true,
- "license": "Apache-2.0",
- "engines": {
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/eslint"
- }
- },
- "node_modules/@typescript-eslint/parser/node_modules/minimatch": {
- "version": "9.0.5",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
- "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
- "dev": true,
- "license": "ISC",
- "dependencies": {
- "brace-expansion": "^2.0.1"
- },
- "engines": {
- "node": ">=16 || 14 >=14.17"
- },
- "funding": {
- "url": "https://github.com/sponsors/isaacs"
- }
- },
"node_modules/@typescript-eslint/scope-manager": {
"version": "7.18.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.18.0.tgz",
diff --git a/package.json b/package.json
index 552cde35..102cfa13 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "expensify-common",
- "version": "2.0.76",
+ "version": "2.0.79",
"author": "Expensify, Inc.",
"description": "Expensify libraries and components shared across different repos",
"homepage": "https://expensify.com",
@@ -52,7 +52,7 @@
"@types/react-dom": "^18.3.0",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^7.18.0",
- "@typescript-eslint/parser": "^7.17.0",
+ "@typescript-eslint/parser": "^7.18.0",
"babel-jest": "^29.0.0",
"babelify": "10.0.0",
"eslint": "^8.57.0",