~sircmpwn/cgi-scripts

1e881968712cf59918d6be54399567d2fb2a41f1 — Drew DeVault 3 years ago f3d1c1b
web2gmi: collapse whitespace properly
3 files changed, 8 insertions(+), 1 deletions(-)

M package-lock.json
M package.json
M web2gmi.js
M package-lock.json => package-lock.json +5 -0
@@ 90,6 90,11 @@
      "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
      "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
    },
    "collapse-white-space": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.6.tgz",
      "integrity": "sha512-jEovNnrhMuqyCcjfEJA56v0Xq8SkIoPKDyaHahwo3POf4qcSXqMYuwNcOTzp74vTsR9Tn08z4MxWqAhcekogkQ=="
    },
    "colorette": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz",

M package.json => package.json +1 -0
@@ 18,6 18,7 @@
  "homepage": "https://gitlab.com/git.sr.ht/~sircmpwn/webart2gem#readme",
  "dependencies": {
    "@mozilla/readability": "^0.3.0",
    "collapse-white-space": "^1.0.6",
    "jsdom": "^16.4.0",
    "node-fetch": "^2.6.1",
    "sanitize-html": "^2.1.2"

M web2gmi.js => web2gmi.js +2 -1
@@ 3,12 3,13 @@ const jsdom = require('jsdom');
const JSDOM = jsdom.JSDOM;
const fetch = require('node-fetch');
const sanitizer = require('sanitize-html');
const collapse = require('collapse-white-space');

jsdom.defaultDocumentFeatures = {
  QuerySelector: true
};

const sanitize = html => sanitizer(html.replace(/\n/g, ""), {
const sanitize = html => sanitizer(collapse(html), {
  allowedTags: [],
  allowedAttributes: {},
}).trim();