Skip to content

Commit 1b3abd1

Browse files
Add tags
1 parent 3fb7bc5 commit 1b3abd1

File tree

19 files changed

+58
-69
lines changed

19 files changed

+58
-69
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ module.exports = {
5454
'unicorn/no-array-callback-reference': 0,
5555
'max-len': 0,
5656
'import/no-unresolved': 0,
57+
'jsdoc/require-returns-description': 0,
58+
'jsdoc/require-param-description': 0,
5759

5860
'simple-import-sort/imports': 'error',
5961
'simple-import-sort/exports': 'error',

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parse } from 'parse5';
22

3-
import { filterAst, indentify } from './lib/utils.js';
3+
import { indentify } from './lib/utils.js';
44
import { getGlobalConfig } from './lib/utils/get-clobal-config.js';
55
import { renderTag } from './lib/utils/render-tag.js';
66

@@ -14,7 +14,7 @@ const htmlToCli = (rawHTML, theme = {}) => {
1414

1515
const clobalConfig = getGlobalConfig(document, theme);
1616

17-
return `\n${indentify(' ')(
17+
return `\n${indentify(' ', false)(
1818
(renderTag(document, clobalConfig) || { value: '' }).value,
1919
)}\n\n`;
2020
};

lib/tag-helpers/block-tag.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { renderTag } from '../utils/render-tag.js';
66
import wrapLineWidth from '../wrap-line-width.js';
77

88
/**
9-
* @param wrapper - {Function}.
10-
* @param localContext - {object}.
9+
* @param {Function} [wrapper]
10+
* @param {object} [localContext]
1111
* @returns {Function}
1212
*/
1313
export function blockTag(wrapper, localContext) {
@@ -38,7 +38,7 @@ export function blockTag(wrapper, localContext) {
3838
};
3939
}
4040

41-
if (accumulator.inline && accumulator.inline.value != undefined) {
41+
if (accumulator.inline && accumulator.inline.value != null) {
4242
accumulator.inline.value = wrapLineWidth(
4343
accumulator.inline.value,
4444
context,
@@ -63,7 +63,7 @@ export function blockTag(wrapper, localContext) {
6363
},
6464
);
6565

66-
if (value.inline != undefined && value.inline.value != undefined) {
66+
if (value.inline != null && value.inline.value != null) {
6767
value.inline.value = wrapLineWidth(value.inline.value, context);
6868
}
6969

lib/tags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
article,
88
aside,
99
blink,
10+
dialog,
1011
div,
1112
figcaption,
1213
footer,
@@ -206,4 +207,5 @@ export default {
206207
video,
207208
wbr,
208209
basefont,
210+
dialog,
209211
};

lib/tags/a.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ansiEscapes from 'ansi-escapes';
2-
import chalk from 'chalk';
32
import { stdout } from 'supports-hyperlinks';
43

54
import inlineTag from '../tag-helpers/inline-tag.js';

lib/tags/base-tags.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import chalk from 'chalk';
2-
31
import { blockTag } from '../tag-helpers/block-tag.js';
42
import inlineTag from '../tag-helpers/inline-tag.js';
53

@@ -34,3 +32,5 @@ export const figcaption = blockTag(
3432
marginBottom: 1,
3533
},
3634
);
35+
36+
export const dialog = blockTag();

lib/tags/blockquote.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import chalk from 'chalk';
21
import compose from 'compose-function';
32

43
import { blockTag } from '../tag-helpers/block-tag.js';
54
import { indentify } from '../utils.js';
65

76
export const blockquote = (tag, context) => blockTag(
87
compose(
9-
indentify(context.theme.blockquote('│ ')),
8+
indentify(context.theme.blockquote('│ '), false),
109
),
1110
{ marginTop: 1, marginBottom: 1 },
1211
)(tag, { ...context, lineWidth: context.lineWidth - 2 });

lib/tags/code.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { blockTag } from '../tag-helpers/block-tag.js';
66
import inlineTag from '../tag-helpers/inline-tag.js';
77
import { getAttribute, indentify } from '../utils.js';
88

9-
export const code = (tag, context) => inlineTag((value, tag, globalContext) => {
9+
export const code = (tag, context) => inlineTag((value, tag) => {
1010
const classAttributes = getAttribute(tag, 'class', '').split(' ');
1111

1212
const content = value.at(-1) === '\n' ? value.slice(0, -1) : value;
@@ -46,18 +46,18 @@ export const code = (tag, context) => inlineTag((value, tag, globalContext) => {
4646
`${index + 1}`.padStart(codeLinesLength, ' '),
4747
)} ${indentify(
4848
pad,
49-
true,
49+
false,
5050
)(
5151
wrapAnsi(codeLine, context.lineWidth - pad.length - 1, {
5252
trim: false,
5353
}),
5454
)}`,
5555
);
5656

57-
return indentify(' ')(codeContent.join('\n'));
57+
return indentify(' ', false)(codeContent.join('\n'));
5858
})(tag, context);
5959

60-
export const pre = (tag, context) => blockTag((value, tag) => value, { marginTop: 2, marginBottom: 2 })(
60+
export const pre = (tag, context) => blockTag((value) => value, { marginTop: 2, marginBottom: 2 })(
6161
tag,
6262
{ ...context, pre: true, lineWidth: context.lineWidth - 10 },
6363
);

lib/tags/definitions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ export const dt = (tag, context) => blockTag(
1010

1111
export const dd = (tag, context) => blockTag(compose(
1212
context.theme.dd,
13-
indentify(' '),
13+
indentify(' ', false),
1414
), { marginTop: 1, marginBottom: 1 })(tag, {
1515
...context,
1616
lineWidth: context.lineWidth - 3,
1717
});
1818

19-
export const dl = blockTag();
19+
export const dl = (tag, context) => blockTag(
20+
context.theme.dl,
21+
{ marginTop: 1, marginBottom: 1 },
22+
)(tag, { ...context, lineWidth: context.lineWidth - 1 });

lib/tags/details.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export const details = (tag, context) => {
1010
return blockTag(
1111
(value) => `${boxen(value || '', {
1212
title: summary && summary.value ? `> ${summary.value.replaceAll('\n', ' ')}` : '> Summary',
13-
dimTitle: false,
14-
titleColor: 'red',
1513
padding: {
1614
bottom: 0, top: 0, left: 1, right: 1,
1715
},

0 commit comments

Comments
 (0)