From 6e45e6e5d69e46124de35599660ae91d927f3f2f Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 11:24:04 +0300 Subject: [PATCH 1/7] Upgrade outdated. --- package-lock.json | 142 +++++++++++++++++++++++++--------------------- 1 file changed, 76 insertions(+), 66 deletions(-) diff --git a/package-lock.json b/package-lock.json index d323e46b..fe211aad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2180,6 +2180,16 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/core": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.6.0.tgz", + "integrity": "sha512-8I2Q8ykA4J0x0o7cg67FPVnehcqWTBehu/lmY+bolPFHGjh49YzGBMXTvpqVgEbBdvNCSxj6iFgiIyHzf03lzg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/eslintrc": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", @@ -2218,9 +2228,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.10.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.10.0.tgz", - "integrity": "sha512-fuXtbiP5GWIn8Fz+LWoOMVf/Jxm+aajZYkhi6CuEm4SxymFM+eUWzbO9qXT+L0iCkL5+KGYMCSGxo686H19S1g==", + "version": "9.11.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.11.1.tgz", + "integrity": "sha512-/qu+TWz8WwPWc7/HcIJKi+c+MOm46GdVaSlTTQcaqaL53+GsoA6MxWp5PtTx48qbSP7ylM1Kn7nhvkugfJvRSA==", "dev": true, "license": "MIT", "engines": { @@ -2238,9 +2248,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.1.0.tgz", - "integrity": "sha512-autAXT203ixhqei9xt+qkYOvY8l6LAFIdT2UXc/RPNeUVfqRF1BV94GTJyVPFKT8nFM6MyVJhjLj9E8JWvf5zQ==", + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.0.tgz", + "integrity": "sha512-vH9PiIMMwvhCx31Af3HiGzsVNULDbyVkHXwlemn/B0TFj/00ho3y55efXrUZTfQipxoHC5u4xq6zblww1zm1Ig==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -3413,13 +3423,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.47.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.47.1.tgz", - "integrity": "sha512-dbWpcNQZ5nj16m+A5UNScYx7HX5trIy7g4phrcitn+Nk83S32EBX/CLU4hiF4RGKX/yRc93AAqtfaXB7JWBd4Q==", + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.47.2.tgz", + "integrity": "sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.47.1" + "playwright": "1.47.2" }, "bin": { "playwright": "cli.js" @@ -3991,9 +4001,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "version": "22.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.6.1.tgz", + "integrity": "sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==", "license": "MIT", "dependencies": { "undici-types": "~6.19.2" @@ -4069,14 +4079,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.6.0.tgz", - "integrity": "sha512-ZuoutoS5y9UOxKvpc/GkvF4cuEmpokda4wRg64JEia27wX+PysIE9q+lzDtlHHgblwUWwo5/Qn+/WyTUvDwBHw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.7.0.tgz", + "integrity": "sha512-87rC0k3ZlDOuz82zzXRtQ7Akv3GKhHs0ti4YcbAJtaomllXoSO8hi7Ix3ccEvCd824dy9aIX+j3d2UMAfCtVpg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.6.0", - "@typescript-eslint/visitor-keys": "8.6.0" + "@typescript-eslint/types": "8.7.0", + "@typescript-eslint/visitor-keys": "8.7.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -4087,9 +4097,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.6.0.tgz", - "integrity": "sha512-rojqFZGd4MQxw33SrOy09qIDS8WEldM8JWtKQLAjf/X5mGSeEFh5ixQlxssMNyPslVIk9yzWqXCsV2eFhYrYUw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.7.0.tgz", + "integrity": "sha512-LLt4BLHFwSfASHSF2K29SZ+ZCsbQOM+LuarPjRUuHm+Qd09hSe3GCeaQbcCr+Mik+0QFRmep/FyZBO6fJ64U3w==", "dev": true, "license": "MIT", "engines": { @@ -4101,14 +4111,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.6.0.tgz", - "integrity": "sha512-MOVAzsKJIPIlLK239l5s06YXjNqpKTVhBVDnqUumQJja5+Y94V3+4VUFRA0G60y2jNnTVwRCkhyGQpavfsbq/g==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.7.0.tgz", + "integrity": "sha512-MC8nmcGHsmfAKxwnluTQpNqceniT8SteVwd2voYlmiSWGOtjvGXdPl17dYu2797GVscK30Z04WRM28CrKS9WOg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "8.6.0", - "@typescript-eslint/visitor-keys": "8.6.0", + "@typescript-eslint/types": "8.7.0", + "@typescript-eslint/visitor-keys": "8.7.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -4169,16 +4179,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.6.0.tgz", - "integrity": "sha512-eNp9cWnYf36NaOVjkEUznf6fEgVy1TWpE0o52e4wtojjBx7D1UV2WAWGzR+8Y5lVFtpMLPwNbC67T83DWSph4A==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.7.0.tgz", + "integrity": "sha512-ZbdUdwsl2X/s3CiyAu3gOlfQzpbuG3nTWKPoIvAu1pu5r8viiJvv2NPN2AqArL35NCYtw/lrPPfM4gxrMLNLPw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.6.0", - "@typescript-eslint/types": "8.6.0", - "@typescript-eslint/typescript-estree": "8.6.0" + "@typescript-eslint/scope-manager": "8.7.0", + "@typescript-eslint/types": "8.7.0", + "@typescript-eslint/typescript-estree": "8.7.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -4192,13 +4202,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.6.0.tgz", - "integrity": "sha512-wapVFfZg9H0qOYh4grNVQiMklJGluQrOUiOhYRrQWhx7BY/+I1IYb8BczWNbbUpO+pqy0rDciv3lQH5E1bCLrg==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.7.0.tgz", + "integrity": "sha512-b1tx0orFCCh/THWPQa2ZwWzvOeyzzp36vkJYOpVg0u8UVOIsfVrnuC9FqAw9gRKn+rG2VmWQ/zDJZzkxUnj/XQ==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.6.0", + "@typescript-eslint/types": "8.7.0", "eslint-visitor-keys": "^3.4.3" }, "engines": { @@ -6431,9 +6441,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001662", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001662.tgz", - "integrity": "sha512-sgMUVwLmGseH8ZIrm1d51UbrhqMCH3jvS7gF/M6byuHOnKyLOBL7W8yz5V02OHwgLGA36o/AFhWzzh4uc5aqTA==", + "version": "1.0.30001663", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001663.tgz", + "integrity": "sha512-o9C3X27GLKbLeTYZ6HBOLU1tsAcBZsLis28wrVzddShCS16RujjHp9GDHKZqrB3meE0YjhawvMFsGb/igqiPzA==", "dev": true, "funding": [ { @@ -8552,9 +8562,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.26", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.26.tgz", - "integrity": "sha512-Z+OMe9M/V6Ep9n/52+b7lkvYEps26z4Yz3vjWL1V61W0q+VLF1pOHhMY17sa4roz4AWmULSI8E6SAojZA5L0YQ==", + "version": "1.5.28", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.28.tgz", + "integrity": "sha512-VufdJl+rzaKZoYVUijN13QcXVF5dWPZANeFTLNy+OSpHdDL5ynXTF35+60RSBbaQYB1ae723lQXHCrf4pyLsMw==", "dev": true, "license": "ISC" }, @@ -8799,21 +8809,24 @@ } }, "node_modules/eslint": { - "version": "9.10.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.10.0.tgz", - "integrity": "sha512-Y4D0IgtBZfOcOUAIQTSXBKoNGfY0REGqHJG6+Q81vNippW5YlKjHFj4soMxamKK1NXHUWuBZTLdU3Km+L/pcHw==", + "version": "9.11.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.11.1.tgz", + "integrity": "sha512-MobhYKIoAO1s1e4VUrgx1l1Sk2JBR/Gqjjgw8+mfgoLE2xwsHur4gdfTxyTgShrhvdVFTaJSgMiQBl1jv/AWxg==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.11.0", "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.6.0", "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.10.0", - "@eslint/plugin-kit": "^0.1.0", + "@eslint/js": "9.11.1", + "@eslint/plugin-kit": "^0.2.0", "@humanwhocodes/module-importer": "^1.0.1", "@humanwhocodes/retry": "^0.3.0", "@nodelib/fs.walk": "^1.2.8", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -9758,9 +9771,9 @@ } }, "node_modules/firebase-tools": { - "version": "13.18.0", - "resolved": "https://registry.npmjs.org/firebase-tools/-/firebase-tools-13.18.0.tgz", - "integrity": "sha512-HackYCHIDqGddGCua79jEOL0ZtMr9LOsk99KIzymX8UET7BeFDwFs7zNgJSFxFErqBKWw2Y1zAj7OuE8+EOkIw==", + "version": "13.19.0", + "resolved": "https://registry.npmjs.org/firebase-tools/-/firebase-tools-13.19.0.tgz", + "integrity": "sha512-NgzXJFhHz8EPDyoEKA8QXzUEcD05z+NJ3sSNmgCsPlmLa93jNzdFqpboS6fqXcnNYKFqwxnqGWE6d02wushPXg==", "dev": true, "license": "MIT", "dependencies": { @@ -11993,9 +12006,9 @@ } }, "node_modules/jackspeak": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", - "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -12006,9 +12019,6 @@ }, "funding": { "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/jed": { @@ -15178,13 +15188,13 @@ } }, "node_modules/playwright": { - "version": "1.47.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.47.1.tgz", - "integrity": "sha512-SUEKi6947IqYbKxRiqnbUobVZY4bF1uu+ZnZNJX9DfU1tlf2UhWfvVjLf01pQx9URsOr18bFVUKXmanYWhbfkw==", + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.47.2.tgz", + "integrity": "sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.47.1" + "playwright-core": "1.47.2" }, "bin": { "playwright": "cli.js" @@ -15197,9 +15207,9 @@ } }, "node_modules/playwright-core": { - "version": "1.47.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.47.1.tgz", - "integrity": "sha512-i1iyJdLftqtt51mEk6AhYFaAJCDx0xQ/O5NU8EKaWFgMjItPVma542Nh/Aq8aLCjIJSzjaiEQGW/nyqLkGF1OQ==", + "version": "1.47.2", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.47.2.tgz", + "integrity": "sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -17558,9 +17568,9 @@ } }, "node_modules/solid-js": { - "version": "1.8.22", - "resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.8.22.tgz", - "integrity": "sha512-VBzN5j+9Y4rqIKEnK301aBk+S7fvFSTs9ljg+YEdFxjNjH0hkjXPiQRcws9tE5fUzMznSS6KToL5hwMfHDgpLA==", + "version": "1.8.23", + "resolved": "https://registry.npmjs.org/solid-js/-/solid-js-1.8.23.tgz", + "integrity": "sha512-0jKzMgxmU/b3k4iJmIZJW2BIArrHN+Mug0n7m7MeHvGHWiS57ZdyTmnqNMSbGRvE73QBnTiGFJc90cPPieawaA==", "license": "MIT", "dependencies": { "csstype": "^3.1.0", From ffba84f6a2685eecd59cef1526f9ce10cfca353d Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 12:09:02 +0300 Subject: [PATCH 2/7] Convert no-break space to normal space. --- src/content/utils/html-to-text.js | 4 ++++ src/content/utils/html-to-text.spec.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/content/utils/html-to-text.js b/src/content/utils/html-to-text.js index 39ba00c6..8de8085f 100644 --- a/src/content/utils/html-to-text.js +++ b/src/content/utils/html-to-text.js @@ -5,6 +5,10 @@ import {compile} from 'html-to-text' const parserOptions = { wordwrap: false, + // in addition to the default whitespace characters, + // also convert u00A0 (no-break space), + // used by tinymce for consecutive spaces. + whitespaceCharacters: '\t\r\n\f\u200b\u00a0', selectors: [ { selector: 'a', diff --git a/src/content/utils/html-to-text.spec.js b/src/content/utils/html-to-text.spec.js index 53d488dd..bb142f86 100644 --- a/src/content/utils/html-to-text.spec.js +++ b/src/content/utils/html-to-text.spec.js @@ -56,4 +56,10 @@ describe('htmlToText', () => { it('should add newlines for br tags', () => { expect(htmlToText('first

second

third')).equal('first\n\nsecond\n\nthird'); }); + + it('should convert unicode no-break space to normal space', () => { + const a = encodeURI(htmlToText('
Hello,  first  second
')) + const b = encodeURI('Hello, first second') + expect(htmlToText(a)).equal(b) + }) }); From 5d4ba936ca4383ca07289c62d41262cc6bd08cba Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 12:10:35 +0300 Subject: [PATCH 3/7] Bump version. --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe211aad..d0cc69ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "briskine", - "version": "7.13.8", + "version": "7.13.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "briskine", - "version": "7.13.8", + "version": "7.13.9", "license": "GPL-3.0-or-later", "dependencies": { "@webcomponents/custom-elements": "^1.4.3", diff --git a/package.json b/package.json index da9edd5e..d7b2e113 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "briskine", - "version": "7.13.8", + "version": "7.13.9", "description": "Write everything faster.", "private": true, "type": "module", From d79be807ebe4754a1fd23f847a3a16903deed7a9 Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 15:50:29 +0300 Subject: [PATCH 4/7] Handle   instead of the no-break whitespace unicode char. --- src/content/utils/html-to-text.js | 13 ++++++++----- src/content/utils/html-to-text.spec.js | 12 +++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/content/utils/html-to-text.js b/src/content/utils/html-to-text.js index 8de8085f..810ec3cc 100644 --- a/src/content/utils/html-to-text.js +++ b/src/content/utils/html-to-text.js @@ -5,10 +5,6 @@ import {compile} from 'html-to-text' const parserOptions = { wordwrap: false, - // in addition to the default whitespace characters, - // also convert u00A0 (no-break space), - // used by tinymce for consecutive spaces. - whitespaceCharacters: '\t\r\n\f\u200b\u00a0', selectors: [ { selector: 'a', @@ -21,12 +17,19 @@ const parserOptions = { const htmlToTextConverter = compile(parserOptions) -function isHtml (html) { +function isHtml (html = '') { // always true in service worker if (typeof document === 'undefined') { return true } + // if it contains the   entity, + // used for consecutive spaces, + // we need to convert it to whitespace. + if (html.includes(' ')) { + return true + } + const template = document.createElement('template') template.innerHTML = html return Boolean(template.content.children.length) diff --git a/src/content/utils/html-to-text.spec.js b/src/content/utils/html-to-text.spec.js index bb142f86..a0ac7b36 100644 --- a/src/content/utils/html-to-text.spec.js +++ b/src/content/utils/html-to-text.spec.js @@ -45,7 +45,7 @@ describe('htmlToText', () => { expect(htmlToText('briskine')).equal('briskine [https://briskine.com/]'); }); - it('should decorate links only with different urls', () => { + it('should only decorate links with different urls', () => { expect(htmlToText('https://briskine.com/')).equal('https://briskine.com/'); }); @@ -57,9 +57,11 @@ describe('htmlToText', () => { expect(htmlToText('first

second

third')).equal('first\n\nsecond\n\nthird'); }); - it('should convert unicode no-break space to normal space', () => { - const a = encodeURI(htmlToText('
Hello,  first  second
')) - const b = encodeURI('Hello, first second') - expect(htmlToText(a)).equal(b) + it('should convert   to whitespace in div', () => { + expect(htmlToText('
Hello  ,
')).equal('Hello \u00a0,') + }) + + it('should convert   to whitespace in plain text', () => { + expect(htmlToText('Hello  ,')).equal('Hello \u00a0,') }) }); From 959e167e4ec6522ccdeda209aec3907f1c542a57 Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 15:52:20 +0300 Subject: [PATCH 5/7] Format htmlToText unit tests. --- src/content/utils/html-to-text.spec.js | 126 ++++++++++++------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/content/utils/html-to-text.spec.js b/src/content/utils/html-to-text.spec.js index a0ac7b36..49edef40 100644 --- a/src/content/utils/html-to-text.spec.js +++ b/src/content/utils/html-to-text.spec.js @@ -1,67 +1,67 @@ /* globals describe, it */ -import {expect} from 'chai'; +import {expect} from 'chai' -import htmlToText from './html-to-text.js'; +import htmlToText from './html-to-text.js' describe('htmlToText', () => { - it('should convert html to text', () => { - expect(htmlToText('
first-line
second-line
third-line
')).equal('first-line\nsecond-line\nthird-line'); - }); - - it('should add end newlines to block nodes', () => { - expect(htmlToText('
first
second
')).equal('first\nsecond'); - }); - - it('should add correct newlines to successive block nodes', () => { - expect(htmlToText('
first
second
')).equal('first\nsecond'); - }); - - it('should add newlines for br and divs', () => { - expect(htmlToText('
first

second

third')).equal('first\n\n\nsecond\n\nthird'); - }); - - it('should add newlines for br inside inline nodes', () => { - expect(htmlToText('first
second')).equal('first\nsecond'); - }); - - it('should remove extra newlines from html', () => { - expect(htmlToText('
first
\n\n
second
')).equal('first\nsecond'); - }); - - it('should keep plain text links intact', () => { - expect(htmlToText('https://www.briskine.com/')).equal('https://www.briskine.com/'); - }); - - it('should keep plain text the same', () => { - const content = 'line-one\n* bullet\nlink(https://briskine.com'; - expect(htmlToText(content)).equal(content); - }); - - it('should decorate lists', () => { - expect(htmlToText('
  • one
  • two')).equal(' * one\n * two'); - }); - - it('should decorate links', () => { - expect(htmlToText('briskine')).equal('briskine [https://briskine.com/]'); - }); - - it('should only decorate links with different urls', () => { - expect(htmlToText('https://briskine.com/')).equal('https://briskine.com/'); - }); - - it('should decorate images', () => { - expect(htmlToText('image alt')).equal('image alt [https://briskine.com/image.jpg]'); - }); - - it('should add newlines for br tags', () => { - expect(htmlToText('first

    second

    third')).equal('first\n\nsecond\n\nthird'); - }); - - it('should convert   to whitespace in div', () => { - expect(htmlToText('
    Hello  ,
    ')).equal('Hello \u00a0,') - }) - - it('should convert   to whitespace in plain text', () => { - expect(htmlToText('Hello  ,')).equal('Hello \u00a0,') - }) -}); + it('should convert html to text', () => { + expect(htmlToText('
    first-line
    second-line
    third-line
    ')).equal('first-line\nsecond-line\nthird-line') + }) + + it('should add end newlines to block nodes', () => { + expect(htmlToText('
    first
    second
    ')).equal('first\nsecond') + }) + + it('should add correct newlines to successive block nodes', () => { + expect(htmlToText('
    first
    second
    ')).equal('first\nsecond') + }) + + it('should add newlines for br and divs', () => { + expect(htmlToText('
    first

    second

    third')).equal('first\n\n\nsecond\n\nthird') + }) + + it('should add newlines for br inside inline nodes', () => { + expect(htmlToText('first
    second')).equal('first\nsecond') + }) + + it('should remove extra newlines from html', () => { + expect(htmlToText('
    first
    \n\n
    second
    ')).equal('first\nsecond') + }) + + it('should keep plain text links intact', () => { + expect(htmlToText('https://www.briskine.com/')).equal('https://www.briskine.com/') + }) + + it('should keep plain text the same', () => { + const content = 'line-one\n* bullet\nlink(https://briskine.com' + expect(htmlToText(content)).equal(content) + }) + + it('should decorate lists', () => { + expect(htmlToText('
    • one
    • two')).equal(' * one\n * two') + }) + + it('should decorate links', () => { + expect(htmlToText('briskine')).equal('briskine [https://briskine.com/]') + }) + + it('should only decorate links with different urls', () => { + expect(htmlToText('https://briskine.com/')).equal('https://briskine.com/') + }) + + it('should decorate images', () => { + expect(htmlToText('image alt')).equal('image alt [https://briskine.com/image.jpg]') + }) + + it('should add newlines for br tags', () => { + expect(htmlToText('first

      second

      third')).equal('first\n\nsecond\n\nthird') + }) + + it('should convert   to whitespace in div', () => { + expect(htmlToText('
      Hello  ,
      ')).equal('Hello \u00a0,') + }) + + it('should convert   to whitespace in plain text', () => { + expect(htmlToText('Hello  ,')).equal('Hello \u00a0,') + }) +}) From 8f721d152ca97a215f15afbf69ef4a5f30b27d3d Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 15:53:37 +0300 Subject: [PATCH 6/7] Bump version. --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d0cc69ac..451d4052 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "briskine", - "version": "7.13.9", + "version": "7.13.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "briskine", - "version": "7.13.9", + "version": "7.13.10", "license": "GPL-3.0-or-later", "dependencies": { "@webcomponents/custom-elements": "^1.4.3", diff --git a/package.json b/package.json index d7b2e113..2cea213b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "briskine", - "version": "7.13.9", + "version": "7.13.10", "description": "Write everything faster.", "private": true, "type": "module", From 58d8506dde48f5676f4c5af59e23b8f799e34ae2 Mon Sep 17 00:00:00 2001 From: Ionut Colceriu Date: Tue, 24 Sep 2024 16:37:12 +0300 Subject: [PATCH 7/7] Tweak puppeteer script. --- test/test-server.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/test/test-server.js b/test/test-server.js index 0066a6f3..fa910f75 100755 --- a/test/test-server.js +++ b/test/test-server.js @@ -160,22 +160,24 @@ function run () { puppeteer .launch(options) - .then(browser => browser.pages() - .then(pages => pages.pop()) - .then(page => { - page.on('console', handleConsole) - page.on('dialog', dialog => dialog.dismiss()) - page.on('pageerror', err => console.error(err)) - - return page.evaluateOnNewDocument(initMocha) - .then(() => page.goto(url)) - .then(() => page.waitForFunction(() => window.__mochaResult__, { timeout })) - .then(() => page.evaluate(() => window.__mochaResult__)) - .then(obj => { - browser.close() - return obj + .then(browser => { + return browser.pages() + .then(pages => pages.pop()) + .then(page => { + page.on('console', handleConsole) + page.on('dialog', dialog => dialog.dismiss()) + page.on('pageerror', err => console.error(err)) + + return page.evaluateOnNewDocument(initMocha) + .then(() => page.goto(url)) + .then(() => page.waitForFunction(() => window.__mochaResult__, { timeout })) + .then(() => page.evaluate(() => window.__mochaResult__)) + .then(obj => { + browser.close() + return obj + }) }) - })) + }) } run()