diff --git a/modules/translators b/modules/translators index 2901ba9..1b96abf 160000 --- a/modules/translators +++ b/modules/translators @@ -1 +1 @@ -Subproject commit 2901ba9fa5b4158cf87697a979a55ee7ad867fef +Subproject commit 1b96abf803535872be41ede811fc13be85b3dbe3 diff --git a/package-lock.json b/package-lock.json index f2f849e..14e2729 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "translation-server", - "version": "2.0.1", + "version": "2.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 1ecc793..747801a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "translation-server", - "version": "2.0.1", + "version": "2.0.3", "description": "Zotero translation server", "license": "AGPL-3.0-only", "main": "index.js", diff --git a/src/translation/translate.js b/src/translation/translate.js index f306886..e5bbbb3 100644 --- a/src/translation/translate.js +++ b/src/translation/translate.js @@ -63,7 +63,13 @@ Object.defineProperty(Attr.interface.prototype, 'innerText', { }); var Node = require('jsdom/lib/jsdom/living/generated/Node'); Object.defineProperty(Node.interface.prototype, 'innerText', { - get: function() { return this.textContent }, + get: function() { + // innerText in the browser is more sophisticated, but this removes most unwanted content + // https://github.com/jsdom/jsdom/issues/1245#issuecomment-584677454 + var el = this.cloneNode(true); + el.querySelectorAll('script,style').forEach(s => s.remove()) + return el.textContent + }, set: function(value) { this.textContent = value }, configurable: true, });