Issue: keyword usage not works for Cyrillic keywords/content #721

This commit is contained in:
Elio Struyf
2024-01-11 14:11:02 +01:00
parent 91f127ef94
commit 430ce8940c
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -10,6 +10,7 @@
### 🐞 Fixes
- [#721](https://github.com/estruyf/vscode-front-matter/issues/721): Fix keywords regex to support unicode characters
- [#725](https://github.com/estruyf/vscode-front-matter/issues/725): Fix for opening menu of pinned items
## [9.4.0] - 2023-12-12 - [Release notes](https://beta.frontmatter.codes/updates/v9.4.0)
@@ -28,7 +28,7 @@ const SeoKeywordInfo: React.FunctionComponent<ISeoKeywordInfoProps> = ({
return null;
}
const pattern = new RegExp('\\b' + keyword.toLowerCase() + '\\b', 'ig');
const pattern = new RegExp(`(^${keyword.toLowerCase()}(?=\\s|$))|(\\s${keyword.toLowerCase()}(?=\\s|$))`, 'ig');
const count = (content.match(pattern) || []).length;
const density = (count / wordCount) * 100;
const densityTitle = l10n.t(LocalizationKey.panelSeoKeywordInfoDensity, `${density.toFixed(2)}%`);