From a01e7330845867e57203332cf81d90710b032fa6 Mon Sep 17 00:00:00 2001 From: Aaron Axvig Date: Mon, 16 Mar 2026 21:12:50 -0500 Subject: [PATCH] Added first test --- package-lock.json | 531 +++++++++++++++++++++ package.json | 2 + test/fixtures/PAA-25.6.2-known/expected.md | 13 + test/fixtures/PAA-25.6.2-known/input.html | 32 ++ test/process-parser.test.mjs | 56 +++ web/js/process.js | 123 ++++- 6 files changed, 742 insertions(+), 15 deletions(-) create mode 100644 test/fixtures/PAA-25.6.2-known/expected.md create mode 100644 test/fixtures/PAA-25.6.2-known/input.html create mode 100644 test/process-parser.test.mjs diff --git a/package-lock.json b/package-lock.json index 778c60b..73bc3ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,9 +6,323 @@ "": { "name": "firewallissues", "devDependencies": { + "jsdom": "^26.1.0", "marked": "^16.3.0" } }, + "node_modules/@asamuzakjp/css-color": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-3.2.0.tgz", + "integrity": "sha512-K1A6z8tS3XsmCMM86xoWdn7Fkdn9m6RSVtocUrJYIwZnFVkng/PvkEoWtOWmP+Scc6saYWHWZYbndEEXxl24jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^2.1.3", + "@csstools/css-color-parser": "^3.0.9", + "@csstools/css-parser-algorithms": "^3.0.4", + "@csstools/css-tokenizer": "^3.0.3", + "lru-cache": "^10.4.3" + } + }, + "node_modules/@csstools/color-helpers": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-5.1.0.tgz", + "integrity": "sha512-S11EXWJyy0Mz5SYvRmY8nJYTFFd1LCNV+7cXyAgQtOOuzb4EsgfqDufL+9esx72/eLhsRdGZwaldu/h+E4t4BA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@csstools/css-calc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-2.1.4.tgz", + "integrity": "sha512-3N8oaj+0juUw/1H3YwmDDJXCgTB1gKU6Hc/bB502u9zR0q2vd786XJH9QfrKIEgFlZmhZiq6epXl4rHqhzsIgQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-3.1.0.tgz", + "integrity": "sha512-nbtKwh3a6xNVIp/VRuXV64yTKnb1IjTAEEh3irzS+HkKjAOYLTGNb9pmVNntZ8iVBHcWDA2Dof0QtPgFI1BaTA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^5.1.0", + "@csstools/css-calc": "^2.1.4" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^3.0.5", + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-3.0.5.tgz", + "integrity": "sha512-DaDeUkXZKjdGhgYaHNJTV9pV7Y9B3b644jCLs9Upc3VeNGg6LWARAT6O+Q+/COo+2gg/bM5rhpMAtf70WqfBdQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^3.0.4" + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-3.0.4.tgz", + "integrity": "sha512-Vd/9EVDiu6PPJt9yAh6roZP6El1xHrdvIVGjyBsHR0RYwNHgL7FJPyIIW4fANJNG6FtyZfvlRPpFI4ZM/lubvw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/agent-base": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", + "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, + "node_modules/cssstyle": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-4.6.0.tgz", + "integrity": "sha512-2z+rWdzbbSZv6/rhtvzvqeZQHrBaqgogqt85sqFNbabZOuFbCVFb8kPeEtZjiKkbrm395irpNKiYeFeLiQnFPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^3.2.0", + "rrweb-cssom": "^0.8.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/data-urls": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-5.0.0.tgz", + "integrity": "sha512-ZYP5VBHshaDAiVZxjbRVcFJpc+4xGgT0bK3vzy1HLN8jTO975HEbuYzZJcHoQEY5K1a0z8YayJkyVETa08eNTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, + "node_modules/entities": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/html-encoding-sniffer": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", + "integrity": "sha512-Y22oTqIU4uuPgEemfz7NDJz6OeKf12Lsu+QC+s3BVpda64lTiMYCyGwg5ki4vFxkMwQdeZDl2adZoqUgdFuTgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-encoding": "^3.1.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsdom": { + "version": "26.1.0", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-26.1.0.tgz", + "integrity": "sha512-Cvc9WUhxSMEo4McES3P7oK3QaXldCfNWp7pl2NNeiIFlCoLr3kfq9kb1fxftiwk1FLV7CvpvDfonxtzUDeSOPg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssstyle": "^4.2.1", + "data-urls": "^5.0.0", + "decimal.js": "^10.5.0", + "html-encoding-sniffer": "^4.0.0", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.6", + "is-potential-custom-element-name": "^1.0.1", + "nwsapi": "^2.2.16", + "parse5": "^7.2.1", + "rrweb-cssom": "^0.8.0", + "saxes": "^6.0.0", + "symbol-tree": "^3.2.4", + "tough-cookie": "^5.1.1", + "w3c-xmlserializer": "^5.0.0", + "webidl-conversions": "^7.0.0", + "whatwg-encoding": "^3.1.1", + "whatwg-mimetype": "^4.0.0", + "whatwg-url": "^14.1.1", + "ws": "^8.18.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "canvas": "^3.0.0" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, "node_modules/marked": { "version": "16.4.2", "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.2.tgz", @@ -21,6 +335,223 @@ "engines": { "node": ">= 20" } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nwsapi": { + "version": "2.2.23", + "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.23.tgz", + "integrity": "sha512-7wfH4sLbt4M0gCDzGE6vzQBo0bfTKjU7Sfpqy/7gs1qBfYz2vEJH6vXcBKpO3+6Yu1telwd0t9HpyOoLEQQbIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/parse5": { + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.3.0.tgz", + "integrity": "sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^6.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/rrweb-cssom": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.8.0.tgz", + "integrity": "sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true, + "license": "MIT" + }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, + "node_modules/symbol-tree": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", + "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", + "dev": true, + "license": "MIT" + }, + "node_modules/tldts": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.86.tgz", + "integrity": "sha512-WMi/OQ2axVTf/ykqCQgXiIct+mSQDFdH2fkwhPwgEwvJ1kSzZRiinb0zF2Xb8u4+OqPChmyI6MEu4EezNJz+FQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^6.1.86" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "6.1.86", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.86.tgz", + "integrity": "sha512-Je6p7pkk+KMzMv2XXKmAE3McmolOQFdxkKw0R8EYNr7sELW46JqnNeTX8ybPiQgvg1ymCoF8LXs5fzFaZvJPTA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tough-cookie": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-5.1.2.tgz", + "integrity": "sha512-FVDYdxtnj0G6Qm/DhNPSb8Ju59ULcup3tuJxkFb5K8Bv2pUXILbf0xZWU8PX8Ov19OXljbUyveOFwRMwkXzO+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^6.1.32" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.1.1.tgz", + "integrity": "sha512-hdF5ZgjTqgAntKkklYw0R03MG2x/bSzTtkxmIRw/sTNV8YXsCJ1tfLAX23lhxhHJlEf3CRCOCGGWw3vI3GaSPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/w3c-xmlserializer": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz", + "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-encoding": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-3.1.1.tgz", + "integrity": "sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==", + "deprecated": "Use @exodus/bytes instead for a more spec-conformant and faster implementation", + "dev": true, + "license": "MIT", + "dependencies": { + "iconv-lite": "0.6.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-mimetype": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-4.0.0.tgz", + "integrity": "sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/whatwg-url": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.2.0.tgz", + "integrity": "sha512-De72GdQZzNTUBBChsXueQUnPKDkg/5A5zp7pFDuQAj5UFoENpiACU0wlCvzpAGnTkj++ihpKwKyYewn/XNUbKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tr46": "^5.1.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/ws": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", + "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" } } } diff --git a/package.json b/package.json index 3324ff7..afb8208 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,11 @@ "name": "firewallissues", "private": true, "scripts": { + "test": "node --test --experimental-default-type=module", "vendor:marked": "mkdir -p web/vendor && cp node_modules/marked/lib/marked.esm.js web/vendor/marked.esm.js" }, "devDependencies": { + "jsdom": "^26.1.0", "marked": "^16.3.0" } } diff --git a/test/fixtures/PAA-25.6.2-known/expected.md b/test/fixtures/PAA-25.6.2-known/expected.md new file mode 100644 index 0000000..5564498 --- /dev/null +++ b/test/fixtures/PAA-25.6.2-known/expected.md @@ -0,0 +1,13 @@ +--- +type: Known +product: Prisma Access Agent +version: 25.6.2 +--- + +## PANG-9739 + +An issue exists where Prisma Access Agent portal (LDAP) authentication on Strata Cloud Manager requires the use of certificates from the **Global** configuration scope exclusively for cookie encryption and decryption operations. + +When configuring portal authentication for Prisma Access Agent, you must select certificates from the **Global** scope (**NGFW and Prisma Access** > **Configuration Scope** > **Global** > **Objects** > **Certificate Management**) for this purpose and must avoid using certificates that share the same name across different scopes. + +Specifically, if a certificate is selected from the **Global** scope for portal authentication, you must verify that no certificate with an identical name exists under the **Prisma Access** or **Access Agent** scopes, as any naming conflict can cause authentication issues. This scope restriction is necessary to prevent certificate conflicts and ensure proper cookie handling during the LDAP authentication process for Prisma Access Agent users. diff --git a/test/fixtures/PAA-25.6.2-known/input.html b/test/fixtures/PAA-25.6.2-known/input.html new file mode 100644 index 0000000..45d793c --- /dev/null +++ b/test/fixtures/PAA-25.6.2-known/input.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + +
Issue IDDescription
PANG-9739 +
An issue exists where Prisma Access Agent portal (LDAP) + authentication on Strata Cloud Manager requires the use of + certificates from the Global configuration + scope exclusively for cookie encryption and decryption operations.
+
When configuring portal authentication for Prisma Access Agent, you + must select certificates from the Global + scope (NGFW and Prisma AccessConfiguration ScopeGlobalObjectsCertificate Management) for this purpose and must avoid using certificates + that share the same name across different scopes.
+
Specifically, if a certificate is selected from the + Global scope for portal authentication, + you must verify that no certificate with an identical name exists + under the Prisma Access or Access Agent scopes, as any naming conflict can cause + authentication issues. This scope restriction is necessary to + prevent certificate conflicts and ensure proper cookie handling + during the LDAP authentication process for Prisma Access Agent + users.
+
diff --git a/test/process-parser.test.mjs b/test/process-parser.test.mjs new file mode 100644 index 0000000..9ce37e9 --- /dev/null +++ b/test/process-parser.test.mjs @@ -0,0 +1,56 @@ +import assert from 'node:assert/strict'; +import test from 'node:test'; +import { readFileSync, readdirSync } from 'node:fs'; +import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { JSDOM } from 'jsdom'; + +const { window } = new JSDOM(''); +globalThis.DOMParser = window.DOMParser; + +const { parseIssuesFromHtmlTable } = await import('../web/js/process.js'); +const { buildIssueMarkdownDocument } = await import('../web/js/markdown.js'); + +const __dirname = fileURLToPath(new URL('.', import.meta.url)); +const fixturesDir = join(__dirname, 'fixtures'); + +// Discover all test fixtures +const fixtures = readdirSync(fixturesDir).filter(file => { + const stat = readdirSync(join(fixturesDir, file), { withFileTypes: true }).map(d => d.name); + return stat.includes('input.html') && stat.includes('expected.md'); +}); + +fixtures.forEach(fixtureId => { + const fixturePath = join(fixturesDir, fixtureId); + const inputPath = join(fixturePath, 'input.html'); + const expectedPath = join(fixturePath, 'expected.md'); + + test(`parses ${fixtureId} correctly`, () => { + const inputHtml = readFileSync(inputPath, 'utf-8'); + const expectedMarkdown = readFileSync(expectedPath, 'utf-8'); + + // Extract metadata from expected markdown frontmatter + const frontmatterMatch = expectedMarkdown.match(/^---\n([\s\S]*?)\n---/); + if (!frontmatterMatch) { + throw new Error(`No frontmatter found in ${expectedPath}`); + } + + const frontmatterLines = frontmatterMatch[1].split('\n'); + const metadata = {}; + frontmatterLines.forEach(line => { + const [key, ...valueParts] = line.split(':'); + metadata[key.trim()] = valueParts.join(':').trim(); + }); + + const parsedIssues = parseIssuesFromHtmlTable(inputHtml); + + const markdown = buildIssueMarkdownDocument({ + type: metadata.type, + product: metadata.product, + version: metadata.version, + issues: parsedIssues + }); + + assert.equal(markdown.trim(), expectedMarkdown.trim()); + }); +}); diff --git a/web/js/process.js b/web/js/process.js index 7dcc102..80fa2be 100644 --- a/web/js/process.js +++ b/web/js/process.js @@ -1,16 +1,24 @@ import { buildIssueMarkdownDocument } from './markdown.js'; -document.addEventListener('DOMContentLoaded', () => { - loadProducts(); - setupEventListeners(); - restoreFormState(); -}); +if (typeof document !== 'undefined') { + document.addEventListener('DOMContentLoaded', () => { + if (!document.getElementById('issuesInput')) { + return; + } + + loadProducts(); + setupEventListeners(); + restoreFormState(); + }); +} let activeDownloadUrl = null; const PROCESS_FORM_STATE_KEY = 'bugmedley.process.formState.v1'; const ISSUE_ID_PATTERN = /\b((?:[A-Z]{2,6}|WF500)-\d{4,8})\b/i; const BLOCK_CONTAINER_TAGS = new Set(['ARTICLE', 'ASIDE', 'BLOCKQUOTE', 'DIV', 'P', 'PRE', 'SECTION']); const RESOLVED_LINE_PATTERN = /^resolved\s+in\b/i; +const TEXT_NODE = 3; +const ELEMENT_NODE = 1; function loadProducts() { fetch('data/products.json') @@ -89,7 +97,7 @@ function generateJSON() { setParseStatus(`Parsed ${issues.length} issues from input.`); } -function parseIssuesFromHtmlTable(htmlText) { +export function parseIssuesFromHtmlTable(htmlText) { const parser = new DOMParser(); const doc = parser.parseFromString(htmlText, 'text/html'); const table = doc.querySelector('table'); @@ -193,22 +201,17 @@ function collectMarkdownBlocks(root, nestedListDepth = 0) { }; Array.from(root.childNodes).forEach(node => { - if (node.nodeType === Node.TEXT_NODE) { - paragraphBuffer += node.textContent || ''; + if (node.nodeType === TEXT_NODE) { + paragraphBuffer = appendInlineText(paragraphBuffer, node.textContent || ''); return; } - if (node.nodeType !== Node.ELEMENT_NODE) { + if (node.nodeType !== ELEMENT_NODE) { return; } const tagName = node.tagName.toUpperCase(); - if (tagName === 'BR') { - paragraphBuffer += '\n'; - return; - } - if (tagName === 'TABLE') { flushParagraph(); const tableMarkdown = convertHtmlTableToMarkdown(node); @@ -233,13 +236,82 @@ function collectMarkdownBlocks(root, nestedListDepth = 0) { return; } - paragraphBuffer += node.textContent || ''; + paragraphBuffer = appendInlineText(paragraphBuffer, convertInlineNodeToMarkdown(node)); }); flushParagraph(); return blocks; } +function convertInlineNodeToMarkdown(node) { + if (!node || node.nodeType !== ELEMENT_NODE) { + return ''; + } + + const className = String(node.getAttribute('class') || ''); + + if (/\bmenucascade\b/i.test(className)) { + const parts = extractMenuCascadeParts(node); + if (parts.length > 0) { + return parts.map(part => `**${part}**`).join(' > '); + } + } + + if (/\buicontrol\b/i.test(className)) { + const content = normalizeInlineMarkdown(renderInlineChildren(node)); + return content ? `**${content}**` : ''; + } + + const tagName = (node.tagName || '').toUpperCase(); + + if (tagName === 'BR') { + return '\u0000'; + } + + if (tagName === 'STRONG' || tagName === 'B') { + const content = normalizeInlineMarkdown(renderInlineChildren(node)); + return content ? `**${content}**` : ''; + } + + if (tagName === 'EM' || tagName === 'I') { + const content = normalizeInlineMarkdown(renderInlineChildren(node)); + return content ? `*${content}*` : ''; + } + + return renderInlineChildren(node); +} + +function renderInlineChildren(node) { + let output = ''; + + Array.from(node.childNodes).forEach(child => { + if (child.nodeType === TEXT_NODE) { + output = appendInlineText(output, child.textContent || ''); + return; + } + + if (child.nodeType !== ELEMENT_NODE) { + return; + } + + output = appendInlineText(output, convertInlineNodeToMarkdown(child)); + }); + + return output; +} + +function extractMenuCascadeParts(node) { + const controls = Array.from(node.querySelectorAll('.uicontrol')); + if (controls.length === 0) { + const fallback = normalizeInlineMarkdown(renderInlineChildren(node)); + return fallback ? [fallback] : []; + } + + return controls + .map(control => normalizeInlineMarkdown(renderInlineChildren(control))) + .filter(Boolean); +} + function convertHtmlListToMarkdown(list, depth = 0) { const items = Array.from(list.children).filter(child => child.tagName && child.tagName.toUpperCase() === 'LI'); if (items.length === 0) { @@ -296,10 +368,31 @@ function normalizeInlineMarkdown(value) { return String(value || '') .replace(/\u00a0/g, ' ') .replace(/[\t\f\v\r ]+/g, ' ') + .replace(/\s*\n+\s*/g, ' ') + .replace(/\u0000/g, '\n') .replace(/ *\n+ */g, '\n') .trim(); } +function appendInlineText(existing, fragment) { + const current = String(existing || ''); + const next = String(fragment || ''); + + if (!next) { + return current; + } + + if (!current) { + return next; + } + + if (/[A-Za-z0-9)\]]$/.test(current) && /^[A-Za-z0-9([\]]/.test(next)) { + return `${current} ${next}`; + } + + return `${current}${next}`; +} + function convertHtmlTableToMarkdown(table) { const rows = Array.from(table.querySelectorAll('tr')) .map(row => Array.from(row.querySelectorAll('th, td')))