6 Commits

Author SHA1 Message Date
semantic-release-bot
4f575d9534 chore(release): 1.9.2
## [1.9.2](https://github.com/obsqrbtz/goose-highlighter/compare/v1.9.1...v1.9.2) (2025-11-14)

### Bug Fixes

* **highlight:** prevent creating extra <span>'s ([#1](https://github.com/obsqrbtz/goose-highlighter/issues/1)) ([affddd3](affddd3dbc))
2025-11-14 13:40:56 +03:00
affddd3dbc fix(highlight): prevent creating extra <span>'s (#1) 2025-11-14 13:40:43 +03:00
semantic-release-bot
c8334f9e68 chore(release): 1.9.1
## [1.9.1](https://github.com/obsqrbtz/goose-highlighter/compare/v1.9.0...v1.9.1) (2025-11-05)

### Bug Fixes

* remove halowen styling ([172aa75](172aa7583b))
2025-11-05 14:59:42 +03:00
172aa7583b fix: remove halowen styling 2025-11-05 14:59:27 +03:00
semantic-release-bot
6d7d9ac151 chore(release): 1.9.0
# [1.9.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.5...v1.9.0) (2025-10-31)

### Features

* haloween styling ([5ef380e](5ef380e544))
2025-10-31 11:17:28 +03:00
5ef380e544 feat: haloween styling 2025-10-31 11:17:08 +03:00
3 changed files with 48 additions and 7 deletions

View File

@@ -1,3 +1,24 @@
## [1.9.2](https://github.com/obsqrbtz/goose-highlighter/compare/v1.9.1...v1.9.2) (2025-11-14)
### Bug Fixes
* **highlight:** prevent creating extra <span>'s ([#1](https://github.com/obsqrbtz/goose-highlighter/issues/1)) ([affddd3](https://github.com/obsqrbtz/goose-highlighter/commit/affddd3dbc7de30100ca134ec65f4dc090275ca5))
## [1.9.1](https://github.com/obsqrbtz/goose-highlighter/compare/v1.9.0...v1.9.1) (2025-11-05)
### Bug Fixes
* remove halowen styling ([172aa75](https://github.com/obsqrbtz/goose-highlighter/commit/172aa7583b325761af43c780db4ac61dc4bda99b))
# [1.9.0](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.5...v1.9.0) (2025-10-31)
### Features
* haloween styling ([5ef380e](https://github.com/obsqrbtz/goose-highlighter/commit/5ef380e54447f45f7360dd4b7b84456aae55bfee))
## [1.8.5](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.4...v1.8.5) (2025-10-29) ## [1.8.5](https://github.com/obsqrbtz/goose-highlighter/compare/v1.8.4...v1.8.5) (2025-10-29)

View File

@@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "__MSG_extension_name__", "name": "__MSG_extension_name__",
"description": "__MSG_extension_description__", "description": "__MSG_extension_description__",
"version": "1.8.5", "version": "1.9.2",
"default_locale": "en", "default_locale": "en",
"permissions": [ "permissions": [
"scripting", "scripting",

View File

@@ -151,14 +151,34 @@ export class HighlightEngine {
for (const node of textNodes) { for (const node of textNodes) {
if (!node.nodeValue || !pattern.test(node.nodeValue)) continue; if (!node.nodeValue || !pattern.test(node.nodeValue)) continue;
const span = document.createElement('span'); const fragment = document.createDocumentFragment();
span.innerHTML = node.nodeValue.replace(pattern, (match) => { const text = node.nodeValue;
const lookup = matchCase ? match : match.toLowerCase(); let lastIndex = 0;
const className = this.wordStyleMap.get(lookup) || 'highlighted-word-0';
return `<span data-gh class="${className}">${match}</span>`;
});
node.parentNode?.replaceChild(span, node); pattern.lastIndex = 0;
let match;
while ((match = pattern.exec(text)) !== null) {
if (match.index > lastIndex) {
fragment.appendChild(document.createTextNode(text.substring(lastIndex, match.index)));
}
const lookup = matchCase ? match[0] : match[0].toLowerCase();
const className = this.wordStyleMap.get(lookup) || 'highlighted-word-0';
const highlightSpan = document.createElement('span');
highlightSpan.setAttribute('data-gh', '');
highlightSpan.className = className;
highlightSpan.textContent = match[0];
fragment.appendChild(highlightSpan);
lastIndex = pattern.lastIndex;
}
if (lastIndex < text.length) {
fragment.appendChild(document.createTextNode(text.substring(lastIndex)));
}
node.parentNode?.replaceChild(fragment, node);
} }
} catch (e) { } catch (e) {
console.error('Regex error:', e); console.error('Regex error:', e);