Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-html

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-html - npm Package Compare versions

Comparing version 1.5.8 to 1.6.0

26

.eslintrc.js
// @ts-nocheck
const restrictedGlobals = require( 'confusing-browser-globals')
const restrictedGlobals = require('confusing-browser-globals');

@@ -8,3 +8,3 @@ module.exports = {

ecmaVersion: 2020,
sourceType: 'module'
sourceType: 'module',
},

@@ -17,2 +17,4 @@ extends: [

// 'plugin:react/recommended',
'plugin:ava/recommended',
'plugin:promise/recommended',

@@ -42,22 +44,20 @@ 'standard-jsdoc',

'security',
'simple-import-sort'
'simple-import-sort',
],
env: {
browser: true,
es6: true
es6: true,
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
SharedArrayBuffer: 'readonly',
},
rules: {
'unicorn/filename-case': 2,
'unicorn/import-index': 0,
'import/extensions': 0,
'prefer-object-spread/prefer-object-spread': 2,
'no-restricted-globals': ['error'].concat(restrictedGlobals),
'sort-imports': 'off',
'import/order': 'off',
'simple-import-sort/sort': 'error'
}
'no-restricted-globals': [2].concat(restrictedGlobals),
'mocha/handle-done-callback': 0,
'mocha/no-global-tests': 0,
'mocha/valid-test-description': 0,
},
};

@@ -6,3 +6,2 @@ const parse5 = require('parse5');

const htmlToCli = (rawHTML) => {

@@ -13,3 +12,2 @@ // @type Object

// console.dir(

@@ -23,3 +21,2 @@ // filterAst(document.childNodes[0].childNodes[1]),

module.exports = htmlToCli;

@@ -12,3 +12,3 @@ /* eslint-disable unicorn/consistent-function-scoping */

const blockTag = (wrapper, localContext) => (tag, context) => {
const wrapFn = wrapper || ((argument) => (argument));
const wrapFn = wrapper || ((argument) => argument);

@@ -20,51 +20,52 @@ if (!tag || !tag.childNodes) {

let liItemNumber = parseInt(getAttribute(tag, 'start', '1'), 10);
const value = tag.childNodes.reduce((accumulator, node) => {
if (!tags[node.nodeName]) {
return accumulator;
}
const value = tag.childNodes.reduce(
(accumulator, node) => {
if (!tags[node.nodeName]) {
return accumulator;
}
const nodeTag = tags[node.nodeName](node, { ...context, liItemNumber });
const nodeTag = tags[node.nodeName](node, { ...context, liItemNumber });
if (nodeTag == null) {
return accumulator;
}
if (nodeTag == null) {
return accumulator;
}
if (nodeTag.nodeName === 'li') {
liItemNumber += 1;
}
if (nodeTag.nodeName === 'li') {
liItemNumber += 1;
}
if (nodeTag.type === 'inline') {
return {
block: accumulator.block,
inline: concatTwoInlineTags(accumulator.inline, nodeTag),
};
}
if (nodeTag.type === 'inline') {
return {
block: accumulator.block,
inline: concatTwoInlineTags(accumulator.inline, nodeTag),
};
}
if (accumulator.inline && accumulator.inline.value != null) {
if (!context.pre) {
accumulator.inline.value = wrapLineWidth(
accumulator.inline.value, context.lineWidth, context.pre,
);
if (accumulator.inline && accumulator.inline.value != null) {
if (!context.pre) {
accumulator.inline.value = wrapLineWidth(accumulator.inline.value, context);
}
}
}
accumulator.block = concatTwoBlockTags(accumulator.block, inlineToBlockTag(accumulator.inline));
accumulator.block = concatTwoBlockTags(
accumulator.block,
inlineToBlockTag(accumulator.inline),
);
accumulator.block = concatTwoBlockTags(accumulator.block, nodeTag);
accumulator.block = concatTwoBlockTags(accumulator.block, nodeTag);
return {
block: accumulator.block,
return {
block: accumulator.block,
inline: null,
};
},
{
block: null,
inline: null,
};
}, {
block: null,
inline: null,
});
},
);
if (value.inline != null && value.inline.value != null) {
if (!context.pre) {
value.inline.value = wrapLineWidth(
value.inline.value, context.lineWidth, context.pre,
);
value.inline.value = wrapLineWidth(value.inline.value, context);
}

@@ -81,24 +82,16 @@ }

topBlock = (!context || !context.pre)
? topBlock + 1
: topBlock;
topBlock = !context || !context.pre ? topBlock + 1 : topBlock;
let bottomBlock = (localContext && localContext.marginBottom) || 0;
bottomBlock = (!context || !context.pre)
? bottomBlock + 1
: bottomBlock;
bottomBlock = !context || !context.pre ? bottomBlock + 1 : bottomBlock;
return {
marginTop: (value.block.marginTop
&& value.block.marginTop > topBlock
)
? value.block.marginTop
: topBlock,
marginTop:
value.block.marginTop && value.block.marginTop > topBlock ? value.block.marginTop : topBlock,
value: wrapFn(value.block.value, tag),
marginBottom: (value.block.marginBottom
&& value.block.marginBottom > bottomBlock
)
? value.block.marginBottom
: bottomBlock,
marginBottom:
value.block.marginBottom && value.block.marginBottom > bottomBlock
? value.block.marginBottom
: bottomBlock,
type: 'block',

@@ -105,0 +98,0 @@ nodeName: tag.nodeName,

@@ -7,3 +7,3 @@ /* eslint-disable unicorn/consistent-function-scoping */

const inlineTag = (wrapper) => (tag, context) => {
const wrapFn = wrapper || ((argument) => (argument));
const wrapFn = wrapper || ((argument) => argument);

@@ -25,3 +25,2 @@ if (!tag || !tag.childNodes) {

return {

@@ -40,11 +39,5 @@ ...concatTwoInlineTags(accumulator, nodeTag),

return {
pre: value.pre
? wrapFn(value.pre, tag)
: null,
value: value.value
? wrapFn(value.value, tag)
: null,
post: value.post
? wrapFn(value.post, tag)
: null,
pre: value.pre ? wrapFn(value.pre, tag) : null,
value: value.value ? wrapFn(value.value, tag) : null,
post: value.post ? wrapFn(value.post, tag) : null,
type: 'inline',

@@ -51,0 +44,0 @@ nodeName: tag.nodeName,

const normalizeWhitespace = require('normalize-html-whitespace');
const he = require('he');
const textNode = (tag, context) => {

@@ -17,3 +16,5 @@ if (context.pre) {

? tag.value.split('')
: normalizeWhitespace(tag.value).replace(/\n/g, ' ').split('');
: normalizeWhitespace(tag.value)
.replace(/\n/g, ' ')
.split('');

@@ -25,5 +26,3 @@ const pre = [' ', '\n'].includes(normalized[0]) ? normalized.shift() : null;

pre,
value: normalized.length > 0
? `${he.decode(normalized.join(''))}`
: null,
value: normalized.length > 0 ? `${he.decode(normalized.join(''))}` : null,
post,

@@ -30,0 +29,0 @@ type: 'inline',

@@ -1,21 +0,16 @@

/* eslint-disable no-param-reassign */
/* eslint-disable security/detect-object-injection */
/* eslint-disable security/detect-non-literal-fs-filename */
/* eslint-disable global-require */
/* eslint-disable security/detect-non-literal-require */
/* eslint-disable global-require */
/* eslint-disable import/no-dynamic-require */
const fs = require('fs');
const textNode = require('./tag-helpers/textNode');
const inlineTag = require('./tag-helpers/inlineTag');
const blockTag = require('./tag-helpers/blockTag');
fs
.readdirSync(`${__dirname}/tags`)
.forEach((moduleUrl) => {
Object.entries(require(`${__dirname}/tags/${moduleUrl}`)).forEach(([key, value]) => {
// @ts-ignore
module.exports[key] = value;
});
const textNode = require(`${__dirname}/tag-helpers/textNode`);
fs.readdirSync(`${__dirname}/tags`).forEach((moduleUrl) => {
Object.entries(require(`${__dirname}/tags/${moduleUrl}`)).forEach(([key, value]) => {
module.exports[key] = value;
});
});
module.exports['#text'] = textNode;
const ansiStyles = require('ansi-colors');
const inlineTag = require('../tag-helpers/inlineTag');
const {
getAttribute,
} = require('../utils');
const { getAttribute } = require('../utils');
const abbr = inlineTag(
(value, tag) => {
const title = getAttribute(tag, 'title', null);
const abbr = inlineTag((value, tag) => {
const title = getAttribute(tag, 'title', null);
let abbrValue = ansiStyles.underline(value);
let abbrValue = ansiStyles.underline(value);
abbrValue = title
? `${abbrValue} ${
ansiStyles.grey('(')
}${
ansiStyles.cyan(title)
}${
ansiStyles.grey(')')
}`
: abbrValue;
abbrValue = title
? `${abbrValue} ${ansiStyles.grey('(')}${ansiStyles.cyan(title)}${ansiStyles.grey(')')}`
: abbrValue;
return abbrValue;
});
return abbrValue;
},
);
const dfn = inlineTag((value, tag) => {
const title = getAttribute(tag, 'title', null);
const dfn = inlineTag(
(value, tag) => {
const title = getAttribute(tag, 'title', null);
let abbrValue = ansiStyles.italic.underline(value);
let abbrValue = ansiStyles.italic.underline(value);
abbrValue = title
? `${abbrValue} ${ansiStyles.grey('(')}${ansiStyles.cyan(title)}${ansiStyles.grey(')')}`
: abbrValue;
abbrValue = title
? `${abbrValue} ${
ansiStyles.grey('(')
}${
ansiStyles.cyan(title)
}${
ansiStyles.grey(')')
}`
: abbrValue;
return abbrValue;
});
return abbrValue;
},
);
module.exports.abbr = abbr;
module.exports.acronym = abbr;
module.exports.dfn = dfn;

@@ -0,5 +1,5 @@

const boxen = require('boxen');
const ansiStyles = require('ansi-colors');
const blockTag = require('../tag-helpers/blockTag');
const inlineTag = require('../tag-helpers/inlineTag');
const boxen = require('boxen');
const ansiStyles = require('ansi-colors');

@@ -10,19 +10,14 @@ const block = blockTag();

const blockWithNewlines = blockTag(
(value) => value,
{ marginTop: 1, marginBottom: 1 },
);
const blockWithNewlines = blockTag((value) => value, { marginTop: 1, marginBottom: 1 });
const title = blockTag(
(value) => boxen(ansiStyles.blue.bold(value), {
padding: {
top: 0,
bottom: 0,
left: 4,
right: 4,
},
borderColor: 'gray',
borderStyle: 'bold',
}),
);
const title = blockTag((value) => boxen(ansiStyles.blue.bold(value), {
padding: {
top: 0,
bottom: 0,
left: 4,
right: 4,
},
borderColor: 'gray',
borderStyle: 'bold',
}));

@@ -29,0 +24,0 @@ module.exports.title = title;

@@ -10,5 +10,6 @@ const ansiStyles = require('ansi-colors');

(value) => ansiStyles.dim.italic(value),
), { marginTop: 1, marginBottom: 1 },
),
{ marginTop: 1, marginBottom: 1 },
)(tag, { ...context, lineWidth: context.lineWidth - 2 });
module.exports.blockquote = blockquote;

@@ -11,5 +11,3 @@ /* eslint-disable unicorn/no-nested-ternary */

const {
getAttribute,
} = require('../utils');
const { getAttribute } = require('../utils');

@@ -23,37 +21,31 @@ const getLangName = (lang) => {

const code = (tag, context) => inlineTag(
(value, tag) => {
const classAttribute = getAttribute(tag, 'class', null);
const code = (tag, context) => inlineTag((value, tag) => {
const classAttribute = getAttribute(tag, 'class', null);
let langName = null;
let langName = null;
if (classAttribute) {
if (classAttribute.startsWith('language-')) {
langName = classAttribute.slice(9);
} if (classAttribute.startsWith('lang-')) {
langName = classAttribute.slice(5);
}
if (classAttribute) {
if (classAttribute.startsWith('language-')) {
langName = classAttribute.slice(9);
}
if (classAttribute.startsWith('lang-')) {
langName = classAttribute.slice(5);
}
}
const codeValue = langName
? highlight(value, {
language: langName,
theme: {
comment: ansiStyles.grey,
},
})
: ansiStyles.yellow(value);
const codeValue = langName
? highlight(value, {
language: langName,
theme: {
comment: ansiStyles.grey,
},
})
: ansiStyles.yellow(value);
return codeValue;
})(tag, context);
return codeValue;
},
)(tag, context);
const pre = (tag, context) => blockTag(
(value, tag) => {
const classAttribute = (tag.childNodes && tag.childNodes[0])
? getAttribute(tag.childNodes[0], 'class', null)
: null;
const classAttribute = tag.childNodes && tag.childNodes[0] ? getAttribute(tag.childNodes[0], 'class', null) : null;

@@ -87,4 +79,4 @@ let langName = null;

return codeValueInBox;
}, { marginTop: 2, marginBottom: 2 },
},
{ marginTop: 2, marginBottom: 2 },
)(tag, { ...context, pre: true, lineWidth: context.lineWidth - 6 });

@@ -91,0 +83,0 @@

@@ -7,12 +7,10 @@ const ansiStyles = require('ansi-colors');

const dt = (tag, context) => blockTag(
compose(
indentify(' '),
(value) => ansiStyles.bold.blue(value),
), { marginTop: 1, marginBottom: 1 },
compose(indentify(' '), (value) => ansiStyles.bold.blue(value)),
{ marginTop: 1, marginBottom: 1 },
)(tag, { ...context, lineWidth: context.lineWidth - 1 });
const dd = (tag, context) => blockTag(
indentify(' '),
{ marginTop: 1, marginBottom: 1 },
)(tag, { ...context, lineWidth: context.lineWidth - 3 });
const dd = (tag, context) => blockTag(indentify(' '), { marginTop: 1, marginBottom: 1 })(tag, {
...context,
lineWidth: context.lineWidth - 3,
});

@@ -19,0 +17,0 @@ const dl = blockTag();

@@ -0,20 +1,14 @@

const boxen = require('boxen');
const { filterAst } = require('../utils');
const boxen = require('boxen');
const blockTag = require('../tag-helpers/blockTag');
const inlineTag = require('../tag-helpers/inlineTag');
const details = (tag, context) => {
const summaryTag = tag.childNodes.find((tag) => tag.tagName === 'summary');
const summary = inlineTag()(
summaryTag || null, context,
);
const summary = inlineTag()(summaryTag || null, context);
return blockTag(
(value) => `${boxen(value || '', {
title: (summary && summary.value)
? `> ${summary.value.replace(/\n/g, ' ')}`
: '> Summary',
title: summary && summary.value ? `> ${summary.value.replace(/\n/g, ' ')}` : '> Summary',
dimTitle: false,

@@ -30,3 +24,2 @@ titleColor: 'red',

module.exports.details = details;

@@ -5,14 +5,9 @@ const boxen = require('boxen');

const fieldset = (tag, context) => {
const summaryTag = tag.childNodes.find((tag) => tag.tagName === 'legend');
const summary = inlineTag()(
summaryTag || null, context,
);
const summary = inlineTag()(summaryTag || null, context);
return blockTag(
(value) => `${boxen(value, {
title: (summary && summary.value)
? summary.value.replace(/\n/g, ' ')
: null,
title: summary && summary.value ? summary.value.replace(/\n/g, ' ') : null,
dimTitle: false,

@@ -28,3 +23,2 @@ titleColor: 'yellow',

module.exports.fieldset = fieldset;

@@ -21,7 +21,6 @@ const boxen = require('boxen');

return valueInBox;
}, { marginTop: 1, marginBottom: 1 },
},
{ marginTop: 1, marginBottom: 1 },
)(tag, { ...context, lineWidth: context.lineWidth - 6 });
module.exports.figure = figure;

@@ -5,26 +5,23 @@ const ansiStyles = require('ansi-colors');

const h1 = blockTag(
(value) => ansiStyles.red.underline.bold(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h2 = blockTag(
(value) => ansiStyles.yellow.underline.bold(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h3 = blockTag(
(value) => ansiStyles.yellow.underline(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h4 = blockTag(
(value) => ansiStyles.green.underline(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h5 = blockTag(
(value) => ansiStyles.green(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h6 = blockTag(
(value) => ansiStyles.green.dim(`§ ${value}`),
{ marginTop: 1, marginBottom: 1 },
);
const h1 = blockTag((value) => ansiStyles.red.underline.bold(`§ ${value}`), {
marginTop: 1,
marginBottom: 1,
});
const h2 = blockTag((value) => ansiStyles.yellow.underline.bold(`§ ${value}`), {
marginTop: 1,
marginBottom: 1,
});
const h3 = blockTag((value) => ansiStyles.yellow.underline(`§ ${value}`), {
marginTop: 1,
marginBottom: 1,
});
const h4 = blockTag((value) => ansiStyles.green.underline(`§ ${value}`), {
marginTop: 1,
marginBottom: 1,
});
const h5 = blockTag((value) => ansiStyles.green(`§ ${value}`), { marginTop: 1, marginBottom: 1 });
const h6 = blockTag((value) => ansiStyles.green.dim(`§ ${value}`), {
marginTop: 1,
marginBottom: 1,
});

@@ -31,0 +28,0 @@ module.exports.h1 = h1;

@@ -5,6 +5,5 @@ const ansiStyles = require('ansi-colors');

const lengthHr = length || process.stdout.columns;
return (new Array(lengthHr)).join(inputHrString);
return new Array(lengthHr).join(inputHrString);
};
const hr = (tag, context) => ({

@@ -11,0 +10,0 @@ marginTop: 1,

const ansiStyles = require('ansi-colors');
const {
getAttribute,
} = require('../utils');
const { getAttribute } = require('../utils');
const img = (tag, context) => {
const text = getAttribute(tag, 'alt', null)
|| getAttribute(tag, 'title', null)
|| 'Image';
const img = (tag) => {
const text = getAttribute(tag, 'alt', null) || getAttribute(tag, 'title', null) || 'Image';
return {
pre: null,
value: ansiStyles.cyan('!')
+ ansiStyles.grey('[')
+ ansiStyles.cyan(text)
+ ansiStyles.grey(']'),
value:
ansiStyles.cyan('!') + ansiStyles.grey('[') + ansiStyles.cyan(text) + ansiStyles.grey(']'),
post: null,

@@ -19,0 +13,0 @@ type: 'inline',

const ansiStyles = require('ansi-colors');
const inlineTag = require('../tag-helpers/inlineTag');
const button = inlineTag(
(value) => `${ansiStyles.bgBlack.grey('[ ')}${ansiStyles.bgBlack.bold(value)}${ansiStyles.bgBlack.grey(
' ]',
)}`,
);
const button = inlineTag((value) => `${
ansiStyles.bgBlack.grey('[ ')
}${
ansiStyles.bgBlack.bold(value)
}${
ansiStyles.bgBlack.grey(' ]')
}`);
const output = inlineTag();

@@ -14,0 +11,0 @@

@@ -7,37 +7,29 @@ const supportsHyperlinks = require('supports-hyperlinks');

const {
getAttribute,
} = require('../utils');
const { getAttribute } = require('../utils');
const link = inlineTag(
(value, tag) => {
const rawHref = getAttribute(tag, 'href', null);
const link = inlineTag((value, tag) => {
const rawHref = getAttribute(tag, 'href', null);
const href = (
rawHref
// eslint-disable-next-line no-script-url
&& !rawHref.startsWith('javascript:')
)
? rawHref
: null;
const href = rawHref
// eslint-disable-next-line no-script-url
&& !rawHref.startsWith('javascript:')
? rawHref
: null;
const title = getAttribute(tag, 'title', null);
const title = getAttribute(tag, 'title', null);
let linkText = ansiStyles.blue(value);
let linkText = ansiStyles.blue(value);
linkText = title
? `${linkText} - ${title}`
: linkText;
linkText = title ? `${linkText} - ${title}` : linkText;
linkText = ansiStyles.underline.blue(linkText);
linkText = ansiStyles.underline.blue(linkText);
const linkValue = (supportsHyperlinks.stdout && href)
// eslint-disable-next-line security/detect-non-literal-fs-filename
? ansiEscapes.link(linkText, href)
: linkText;
const linkValue = supportsHyperlinks.stdout && href
// eslint-disable-next-line security/detect-non-literal-fs-filename
? ansiEscapes.link(linkText, href)
: linkText;
return linkValue;
},
);
return linkValue;
});
module.exports.a = link;
const ansiStyles = require('ansi-colors');
const compose = require('compose-function');
const blockTag = require('../tag-helpers/blockTag');
const {
indentify,
getAttribute,
} = require('../utils');
const {
getListSymbol,
getListType,
getListItemNumber,
} = require('../utils/list');
const { indentify, getAttribute } = require('../utils');
const { getListSymbol, getListType, getListItemNumber } = require('../utils/list');
const ol = (tag, context) => {

@@ -24,11 +16,6 @@ const newContext = {

return blockTag(
compose(
(value) => indentify(' ')(value),
), {
marginTop: context.compact ? 0 : 1,
marginBottom: context.compact ? 0 : 1,
},
)(tag, newContext);
return blockTag((value) => indentify(context.compact ? '' : ' ')(value), {
marginTop: context.compact ? 0 : 1,
marginBottom: context.compact ? 0 : 1,
})(tag, newContext);
};

@@ -45,11 +32,6 @@

return blockTag(
compose(
(value) => indentify(' ')(value),
), {
marginTop: context.compact ? 0 : 1,
marginBottom: context.compact ? 0 : 1,
},
)(tag, newContext);
return blockTag((value) => indentify(context.compact ? '' : ' ')(value), {
marginTop: context.compact ? 0 : 1,
marginBottom: context.compact ? 0 : 1,
})(tag, newContext);
};

@@ -59,20 +41,11 @@

if (context.orderedList) {
return blockTag(
compose(
(value) => `${
ansiStyles.blue(`${getListItemNumber(context.liItemNumber, context.listType)}.`)
} ${
indentify(' ')(value)
}`.replace(/ {3}/, ''),
),
)(tag, { ...context, lineWidth: context.lineWidth - 3 });
return blockTag((value) => `${ansiStyles.blue(
`${getListItemNumber(context.liItemNumber, context.listType)}.`,
)} ${indentify(' ')(value)}`.replace(/ {3}/, ''))(tag, { ...context, lineWidth: context.lineWidth - 3 });
}
return blockTag(
compose(
(value) => `${
indentify(' ')(value)
}`.replace(/ {2}/, `${ansiStyles.red(getListSymbol(context.listType))} `),
),
)(tag, { ...context, lineWidth: context.lineWidth - 2 });
return blockTag((value) => `${indentify(' ')(value)}`.replace(
/ {2}/,
`${ansiStyles.red(getListSymbol(context.listType))} `,
))(tag, { ...context, lineWidth: context.lineWidth - 2 });
};

@@ -79,0 +52,0 @@

@@ -1,6 +0,3 @@

const Table = require('cli-table3');
const compose = require('compose-function');
const blockTag = require('../tag-helpers/blockTag');
const inlineTag = require('../tag-helpers/inlineTag');
const boxen = require('boxen');

@@ -10,12 +7,8 @@ const ansiStyles = require('ansi-colors');

const longestLine = require('longest-line');
const inlineTag = require('../tag-helpers/inlineTag');
const blockTag = require('../tag-helpers/blockTag');
const { concatTwoBlockTags } = require('../utils/concatBlockTags');
const {
indentify,
getAttribute,
filterAst,
} = require('../utils');
const { indentify, getAttribute, filterAst } = require('../utils');
// // table is an Array, so you can `push`, `unshift`, `splice` and friends

@@ -32,15 +25,6 @@ // table.push(

const captions = (tag, context) => blockTag((value) => ansiStyles.bold.blue(value))(tag, context);
const captions = (tag, context) => {
void 0;
return blockTag(
compose(
(value) => ansiStyles.bold.blue(value),
(value) => indentify((''))(value),
),
)(tag, context);
};
const trVals = (tr) => {
const theadTds = (!tr || !tr.childNodes)
const theadTds = !tr || !tr.childNodes
? null

@@ -51,25 +35,17 @@ : tr.childNodes.filter((tag) => ['td', 'th'].includes(tag.nodeName));

? null
: theadTds.map(
(tag, context) => {
const det = tag.nodeName === 'td'
? td(tag, context)
: th(tag, context);
: theadTds.map((tag, context) => {
const det = tag.nodeName === 'td' ? td(tag, context) : th(tag, context);
const hAlign = getAttribute(tag, 'align', 'right');
const vAlign = getAttribute(tag, 'valign', 'top');
const hAlign = getAttribute(tag, 'align', 'right');
const vAlign = getAttribute(tag, 'valign', 'top');
const colSpan = parseInt(getAttribute(tag, 'colspan', '1'), 10);
const colSpan = parseInt(getAttribute(tag, 'colspan', '1'), 10);
return {
content: (det && det.value)
? det.value
: '',
hAlign,
vAlign,
colSpan,
};
},
);
return {
content: det && det.value ? det.value : '',
hAlign,
vAlign,
colSpan,
};
});
return theadTdsValue;

@@ -79,5 +55,3 @@ };

const tbodyVals = (tbody) => {
const theadTrs = !tbody
? null
: tbody.childNodes.filter((tag) => ['tr'].includes(tag.nodeName));
const theadTrs = !tbody ? null : tbody.childNodes.filter((tag) => ['tr'].includes(tag.nodeName));

@@ -98,3 +72,2 @@ const theadTrsVals = theadTrs.map(trVals);

const captionsValue = captions(captionTag, context);

@@ -104,12 +77,7 @@

const thead = tag.childNodes.find((child) => child.nodeName === 'thead');
const theadTr = (!thead || !thead.childNodes)
? null
: thead.childNodes.find((child) => child.nodeName === 'tr');
const theadTr = !thead || !thead.childNodes ? null : thead.childNodes.find((child) => child.nodeName === 'tr');
const theadsValue = !theadTr
? null
: trVals(theadTr);
const theadsValue = !theadTr ? null : trVals(theadTr);

@@ -120,3 +88,2 @@ if (theadsValue && theadsValue[0]) {

const trs = tag.childNodes.filter((child) => ['tbody'].includes(child.nodeName));

@@ -126,12 +93,7 @@

const tfoot = tag.childNodes.find((child) => child.nodeName === 'tfoot');
const tfootTr = (!tfoot || !tfoot.childNodes)
? null
: tfoot.childNodes.find((child) => child.nodeName === 'tr');
const tfootTr = !tfoot || !tfoot.childNodes ? null : tfoot.childNodes.find((child) => child.nodeName === 'tr');
const tfootdsValue = !tfootTr
? null
: trVals(tfootTr);
const tfootdsValue = !tfootTr ? null : trVals(tfootTr);

@@ -142,6 +104,4 @@ if (tfootdsValue && tfootdsValue[0]) {

const table = new Table({
});
const table = new Table({});
// console.log('--))==', tableArray);
table.push(...tableArray);

@@ -154,7 +114,3 @@

if (captionsValue && captionsValue.value) {
captionsValue.value = `${
captionsValue.value
}\n${
' '.repeat(longestLineInTable)
}`;
captionsValue.value = `${captionsValue.value}\n${' '.repeat(longestLineInTable)}`;

@@ -161,0 +117,0 @@ captionsValue.value = ansiAlign(captionsValue.value);

const ansiStyles = require('ansi-colors');
const inlineTag = require('../tag-helpers/inlineTag');
const q = inlineTag((value) => `"${value}"`);
const noStyle = inlineTag();
const q = inlineTag((value) => `"${value}"`);

@@ -20,3 +19,2 @@ const del = inlineTag((value) => ansiStyles.bgRed.black(value));

module.exports.b = bold;

@@ -49,3 +47,2 @@

module.exports.small = noStyle;

@@ -52,0 +49,0 @@ module.exports.big = noStyle;

const filterAst = (ast) => {
const removeTheseKeys = [
'mode',
'namespaceURI',
'parentNode',
'tagName',
];
const removeTheseKeys = ['mode', 'namespaceURI', 'parentNode', 'tagName'];

@@ -20,3 +15,2 @@ return Object.entries(ast).reduce((accumulator, [key, value]) => {

module.exports.filterAst = filterAst;

@@ -36,3 +30,2 @@

const getAttribute = (tag, attributeName, defaultValue) => {

@@ -39,0 +32,0 @@ if (!tag || !tag.attrs || !tag.attrs[0]) {

@@ -17,3 +17,2 @@ /* eslint-disable unicorn/no-nested-ternary */

if (second.value == null) {

@@ -23,10 +22,3 @@ return {

value: first.value,
marginBottom: first.marginBottom > 0
? +first.marginBottom
: (second.marginTop > 0
? +second.marginTop : (
second.marginBottom > 0
? +second.marginBottom
: 0
)),
marginBottom: Math.max(+first.marginBottom, +second.marginTop, +second.marginBottom),
};

@@ -37,10 +29,3 @@ }

return {
marginTop: first.marginTop > 0
? +first.marginTop
: (first.marginBottom > 0
? first.marginBottom : (
second.marginTop > 0
? second.marginTop
: 0
)),
marginTop: Math.max(+first.marginTop, +first.marginBottom, +second.marginTop),
value: second.value,

@@ -55,4 +40,4 @@ marginBottom: second.marginBottom,

first.marginBottom > second.marginTop
? ('\n').repeat(first.marginBottom || 0)
: ('\n').repeat(second.marginTop || 0)
? '\n'.repeat(first.marginBottom || 0)
: '\n'.repeat(second.marginTop || 0)
}${second.value}`,

@@ -59,0 +44,0 @@ marginBottom: second.marginBottom,

@@ -21,9 +21,10 @@ /* eslint-disable unicorn/no-nested-ternary */

value: first.value,
post: first.post != null
? first.post
: (second.pre != null ? second.pre : (
second.post != null
? second.post
: ''
)),
post:
first.post != null
? first.post
: second.pre != null
? second.pre
: second.post != null
? second.post
: '',
};

@@ -34,9 +35,10 @@ }

return {
pre: first.pre != null
? first.pre
: (first.post != null ? first.post : (
second.pre != null
? second.pre
: ''
)),
pre:
first.pre != null
? first.pre
: first.post != null
? first.post
: second.pre != null
? second.pre
: '',
value: second.value,

@@ -43,0 +45,0 @@ post: second.post,

@@ -15,3 +15,2 @@ const inlineToBlockTag = (value) => {

module.exports.inlineToBlockTag = inlineToBlockTag;

@@ -5,7 +5,3 @@ const { NumberToAlphabet } = require('number-to-alphabet');

const getListType = (tagType, contextType) => {
const types = [
'disc',
'square',
'circle',
];
const types = ['disc', 'square', 'circle'];

@@ -57,5 +53,4 @@ if (tagType) {

module.exports.getListType = getListType;
module.exports.getListSymbol = getListSymbol;
module.exports.getListItemNumber = getListItemNumber;
const wrapAnsi = require('wrap-ansi');
const wrapLineWidth = (text, lineWidth, pre) => {
if (pre) {
const wrapLineWidth = (text, tag) => {
if (tag.pre) {
return text;
}
return wrapAnsi(text, lineWidth, { trim: true });
return wrapAnsi(text, tag.lineWidth, { trim: true });
};
module.exports = wrapLineWidth;
{
"name": "cli-html",
"version": "1.5.8",
"version": "1.6.0",
"description": "There will be cli module who render HTML to Terminal",
"main": "index.js",
"type": "commonjs",
"scripts": {
"fix": "eslint --fix index.js lib/*.js lib/*/*.js",
"test": "echo \"Error: no test specified\" && exit 0",
"run-test": "babel-node src/index.ts",
"tsc": "tsc"
"fix": "eslint --fix index.js lib/*.js lib/*/*.js test/*.js",
"test": "ava"
},

@@ -49,3 +48,2 @@ "bin": {

"parse5": "^5.1.1",
"parse5-htmlparser2-tree-adapter": "^5.1.1",
"romanize": "^1.1.1",

@@ -56,11 +54,13 @@ "supports-hyperlinks": "^2.0.0",

"devDependencies": {
"ava": "^2.4.0",
"confusing-browser-globals": "^1.0.9",
"eslint": "^6.6.0",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-es": "^3.17.1",
"eslint-config-es": "^3.19.4",
"eslint-config-standard-jsdoc": "^9.2.2",
"eslint-plugin-async-await": "0.0.0",
"eslint-plugin-ava": "^9.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jquery": "^1.5.1",
"eslint-plugin-jsdoc": "^18.1.4",
"eslint-plugin-jsdoc": "^18.4.1",
"eslint-plugin-json": "^2.0.1",

@@ -72,6 +72,5 @@ "eslint-plugin-no-loops": "^0.3.0",

"eslint-plugin-security": "^1.4.0",
"eslint-plugin-simple-import-sort": "^4.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.8.0",
"mocha": "^6.2.2"
"eslint-plugin-simple-import-sort": "^5.0.0",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.8.0"
}
}

@@ -0,9 +1,25 @@

/* eslint-disable node/no-unsupported-features/es-syntax */
/* eslint-disable node/no-unpublished-import */
import test from 'ava';
const { getListSymbol, getListType } = require('../lib/utils/list');
test("should be 'disc' for ['disc', 'square']", (t) => {
t.is(getListType('disc', 'square'), 'disc');
});
console.log(getListType('disc', 'square'));
console.log(getListType(null, 'square'));
console.log(getListType(null, 'void'));
console.log(getListType(null, null));
test("should be 'circle' for [null, 'square']", (t) => {
t.is(getListType(null, 'square'), 'circle');
});
console.log(getListSymbol('disc'));
test("should be 'disc' for [null, 'void']", (t) => {
t.is(getListType(null, 'void'), 'disc');
});
test("should be 'disc' for [null, null]", (t) => {
t.is(getListType(null, null), 'disc');
});
test("should be '•' for 'disc'", (t) => {
t.is(getListSymbol('disc'), '•');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc