UNPKG

@modyo/cli

Version:

Modyo CLI Command line to expose local development tools

23 lines (22 loc) 805 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const emoji_regex_1 = tslib_1.__importDefault(require("emoji-regex")); const cheerio_1 = tslib_1.__importDefault(require("cheerio")); function getBody({ $, removeEmojis, }) { const $clone = cheerio_1.default.load($.html(), { // withDomLvl1: true, normalizeWhitespace: false, // xmlMode: true, decodeEntities: true, }); $clone('body script').remove(); $clone('body link[href*="css"]').remove(); const bodyText = $clone('body').html(); if (removeEmojis) { const emojiRegex = (0, emoji_regex_1.default)(); return bodyText ? bodyText.replace(emojiRegex, '') : ''; } return bodyText || ''; } exports.default = getBody;