~sircmpwn/cgi-scripts

bd2ed880d0410eec255499f23d6cb5acf13f9bae — Drew DeVault 3 years ago 1e88196
web2gmi: decode HTML entities
3 files changed, 12 insertions(+), 4 deletions(-)

M package-lock.json
M package.json
M web2gmi.js
M package-lock.json => package-lock.json +5 -0
@@ 335,6 335,11 @@
        "whatwg-encoding": "^1.0.5"
      }
    },
    "html-entities": {
      "version": "1.3.1",
      "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.3.1.tgz",
      "integrity": "sha512-rhE/4Z3hIhzHAUKbW8jVcCyuT5oJCXXqhN/6mXXVCpzTmvJnoH2HL/bt3EZ6p55jbFJBeAe1ZNpL5BugLujxNA=="
    },
    "htmlparser2": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz",

M package.json => package.json +1 -0
@@ 19,6 19,7 @@
  "dependencies": {
    "@mozilla/readability": "^0.3.0",
    "collapse-white-space": "^1.0.6",
    "html-entities": "^1.3.1",
    "jsdom": "^16.4.0",
    "node-fetch": "^2.6.1",
    "sanitize-html": "^2.1.2"

M web2gmi.js => web2gmi.js +6 -4
@@ 4,19 4,21 @@ const JSDOM = jsdom.JSDOM;
const fetch = require('node-fetch');
const sanitizer = require('sanitize-html');
const collapse = require('collapse-white-space');
const Entities = require('html-entities').AllHtmlEntities;
const entities = new Entities();

jsdom.defaultDocumentFeatures = {
  QuerySelector: true
};

const sanitize = html => sanitizer(collapse(html), {
const sanitize = html => entities.decode(sanitizer(collapse(html), {
  allowedTags: [],
  allowedAttributes: {},
}).trim();
const sanitizePre = html => sanitizer(html, {
})).trim();
const sanitizePre = html => entities.decode(sanitizer(html, {
  allowedTags: [],
  allowedAttributes: {},
}).trim();
})).trim();

const convert = (dom, title) => {
  let output = "";