Skip to content

Commit 64a4fbb

Browse files
Update style
1 parent 9059d48 commit 64a4fbb

File tree

15 files changed

+76
-78
lines changed

15 files changed

+76
-78
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ html examples/demo.html
2323

2424
This will produce the following:
2525

26-
![Screenshot of cli-html](./images/1.png)
26+
![Screenshot of cli-html](./images/terminal.png)
2727

2828
## Usage as module
2929

examples/headers.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h1>h1, h1, h1, h1, h1</h1>
2+
<h2>h2, h2, h2, h2, h2</h2>
3+
<h3>h3, h3, h3, h3, h3</h3>
4+
<h4>h4, h4, h4, h4, h4</h4>
5+
<h5>h5, h5, h5, h5, h5</h5>
6+
<h6>h6, h6, h6, h6, h6</h6>

images/1.png

-194 KB
Binary file not shown.

images/terminal.png

163 KB
Loading

lib/tag-helpers/text-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export const textNode = (tag, context) => {
1212
};
1313
}
1414

15-
const normalized = [...normalizeWhitespace(tag.value).replace(/\n/g, ' ')];
15+
const normalized = [...normalizeWhitespace(tag.value).replaceAll('\n', ' ')];
1616

1717
const pre = [' ', '\n'].includes(normalized[0]) ? normalized.shift() : null;
18-
const post = [' ', '\n'].includes(normalized[normalized.length - 1]) ? normalized.pop() : null;
18+
const post = [' ', '\n'].includes(normalized.at(-1)) ? normalized.pop() : null;
1919

2020
return {
2121
pre,

lib/tags/base-tags.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export const form = block;
2727
export const picture = block;
2828
export const hgroup = block;
2929

30-
export const figcaption = blockTag((value) => chalk.bgGreen.bold(` § ${value} `), {
31-
marginTop: 1,
32-
marginBottom: 1,
33-
});
30+
export const figcaption = blockTag(
31+
(value) => chalk.bgGreen.bold(` ${value} `),
32+
{
33+
marginTop: 1,
34+
marginBottom: 1,
35+
},
36+
);

lib/tags/code.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getAttribute, indentify } from '../utils.js';
99
export const code = (tag, context) => inlineTag((value, tag) => {
1010
const classAttributes = getAttribute(tag, 'class', '').split(' ');
1111

12-
const content = value[value.length - 1] === '\n' ? value.slice(0, -1) : value;
12+
const content = value.at(-1) === '\n' ? value.slice(0, -1) : value;
1313

1414
let langName = null;
1515

@@ -24,13 +24,13 @@ export const code = (tag, context) => inlineTag((value, tag) => {
2424
});
2525

2626
const codeValue = langName
27-
? (highlight(content, {
27+
? highlight(content, {
2828
language: langName,
2929
theme: {
3030
comment: chalk.blackBright,
3131
},
32-
}))
33-
: chalk.yellow(content);
32+
})
33+
: chalk.red(content);
3434

3535
if (tag.parentNode.nodeName !== 'pre') {
3636
return chalk.bgBlack(codeValue);
@@ -42,7 +42,9 @@ export const code = (tag, context) => inlineTag((value, tag) => {
4242
const pad = `${Array.from({ length: codeLinesLength }).join(' ')} `;
4343

4444
const codeContent = codeValueLines.map(
45-
(codeLine, index) => `${chalk.black.bold(`${index + 1}`.padStart(codeLinesLength, ' '))} ${indentify(
45+
(codeLine, index) => `${chalk.blackBright.dim(
46+
`${index + 1}`.padStart(codeLinesLength, ' '),
47+
)} ${indentify(
4648
pad,
4749
true,
4850
)(

lib/tags/details.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const details = (tag, context) => {
99

1010
return blockTag(
1111
(value) => `${boxen(value || '', {
12-
title: summary && summary.value ? `> ${summary.value.replace(/\n/g, ' ')}` : '> Summary',
12+
title: summary && summary.value ? `> ${summary.value.replaceAll('\n', ' ')}` : '> Summary',
1313
dimTitle: false,
1414
titleColor: 'red',
1515
padding: {

lib/tags/fieldset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const fieldset = (tag, context) => {
99

1010
return blockTag(
1111
(value) => `${boxen_(value, {
12-
title: summary && summary.value ? summary.value.replace(/\n/g, ' ') : null,
12+
title: summary && summary.value ? summary.value.replaceAll('\n', ' ') : null,
1313
dimTitle: false,
1414
titleColor: 'yellow',
1515
padding: {

lib/tags/headers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@ import chalk from 'chalk';
22

33
import { blockTag } from '../tag-helpers/block-tag.js';
44

5-
export const h1 = blockTag((value) => chalk.bgBlue.bold(` § ${value} `), {
5+
export const h1 = blockTag((value) => chalk.blue.bold(` # ${value} `), {
66
marginTop: 2,
77
marginBottom: 1,
88
});
9-
export const h2 = blockTag((value) => chalk.bgBlueBright.bold(` § ${value} `), {
9+
export const h2 = blockTag((value) => chalk.blue.bold(` ## ${value} `), {
1010
marginTop: 1,
1111
marginBottom: 1,
1212
});
13-
export const h3 = blockTag((value) => chalk.bgCyan.bold(` § ${value} `), {
13+
export const h3 = blockTag((value) => chalk.blue.bold(` ### ${value} `), {
1414
marginTop: 1,
1515
marginBottom: 1,
1616
});
17-
export const h4 = blockTag((value) => ` ${chalk.blue.bold(`§ ${value}`)}`, {
17+
export const h4 = blockTag((value) => chalk.cyan.bold(` #### ${value}`), {
1818
marginTop: 1,
1919
marginBottom: 1,
2020
});
21-
export const h5 = blockTag((value) => ` ${chalk.blueBright(${value}`)}`, {
21+
export const h5 = blockTag((value) => chalk.cyan(` ##### ${value}`), {
2222
marginTop: 1,
2323
marginBottom: 1,
2424
});
25-
export const h6 = blockTag((value) => ` ${chalk.cyan(`§ ${value}`)}`, {
25+
export const h6 = blockTag((value) => chalk.cyan(` ###### ${value}`), {
2626
marginTop: 1,
2727
marginBottom: 1,
2828
});

0 commit comments

Comments
 (0)