How to use he

Comprehensive he code examples:

How to use he.escape:

5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
    if (node.tag) {
      renderElement(node, isRoot, context);
    } else if (node.isComment) {
      write(("<!--" + (node.text) + "-->"), next);
    } else {
      write(node.raw ? node.text : he.escape(String(node.text)), next);
    }
  }
}

How to use he.encode:

672
673
674
675
676
677
678
679
680
681
  indentBy: "  ",
  supressEmptyNode: format === 'xccdf',
  tagValueProcessor: a => {
    return a ? he.encode(a.toString(), { useNamedReferences: false}) : a 
  },
  attrValueProcessor: a => he.encode(a, {isAttributeValue: true, useNamedReferences: true})
})
const zip = Archiver('zip', {zlib: {level: 9}})
res.attachment(`${parsedRequest.collection.name}-${format.startsWith('ckl-') ? 'CKL' : 'XCCDF'}.zip`)
zip.pipe(res)

How to use he.decode:

112
113
114
115
116
117
118
119
120
121
return {
    id: (_b = (_a = result.cid) !== null && _a !== void 0 ? _a : result.bvid) !== null && _b !== void 0 ? _b : result.aid,
    aid: result.aid,
    bvid: result.bvid,
    artist: (_c = result.author) !== null && _c !== void 0 ? _c : (_d = result.owner) === null || _d === void 0 ? void 0 : _d.name,
    title: he.decode((_f = (_e = result.title) === null || _e === void 0 ? void 0 : _e.replace(/(\<em(.*?)\>)|(\<\/em\>)/g, "")) !== null && _f !== void 0 ? _f : ""),
    album: (_g = result.bvid) !== null && _g !== void 0 ? _g : result.aid,
    artwork: ((_h = result.pic) === null || _h === void 0 ? void 0 : _h.startsWith("//"))
        ? "http:".concat(result.pic)
        : result.pic,