Skip to content

Commit de5d8b9

Browse files
spadgeakiRyan Johnson
authored andcommitted
Added support for HTML entities (#29)
Common practise in translations is adding non-breakable spaces ( ). I would like to have them treated as any other HTML content in translation files.
1 parent c139cd8 commit de5d8b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getLocalizedElement = (key: string, translations: TranslatedLanguag
2020
};
2121

2222
export const hasHtmlTags = (value: string): boolean => {
23-
const pattern = /<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>/;
23+
const pattern = /(&[^\s]*;|<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>)/;
2424
return value.search(pattern) >= 0;
2525
};
2626

0 commit comments

Comments
 (0)