Skip to content

Commit 3de0e55

Browse files
Change tagss
1 parent 36dda62 commit 3de0e55

File tree

9 files changed

+129
-88
lines changed

9 files changed

+129
-88
lines changed

examples/blockquote.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<blockquote cite="http://www.worldwildlife.org/who/index.html">
2+
For 50 years, WWF has been protecting the future of nature. The world's
3+
leading conservation organization, WWF works in 100 countries and is supported
4+
by 1.2 million members in the United States and close to 5 million globally.
5+
</blockquote>

examples/code.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@
99
const languages = require('languages-aliases');
1010
const { highlight } = require('cli-highlight');
1111
const boxen = require('boxen');</code></pre>
12-

examples/links.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a>Hello</a>
2+
<a href="#hello"/>Hello</a>
3+
<a href="http://google.com"/>Hello</a>

lib/tags.js

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -82,125 +82,125 @@ import {
8282
map,
8383
meta,
8484
noscript,
85+
optgroup,
86+
option,
8587
param as parameter,
8688
script,
89+
select,
8790
source,
8891
style,
8992
summary,
93+
template,
9094
track,
95+
video,
9196
} from './tags/void.js';
9297

9398
const __text = textNode;
9499

95100
//
96-
97101
export default {
102+
'#text': __text,
103+
a,
98104
abbr,
99-
dfn,
100105
acronym,
101106
address,
102-
title,
103-
span,
104-
label,
105-
p,
106-
div,
107-
head,
108-
header,
107+
applet,
108+
area,
109109
article,
110-
footer,
111-
section,
112-
main,
113-
nav,
114110
aside,
115-
form,
116-
picture,
117-
figcaption,
118-
hgroup,
111+
audio,
112+
b,
113+
base,
114+
bgsound,
115+
big,
119116
blockquote,
117+
blockTag,
118+
body,
119+
bold,
120120
br,
121+
button,
122+
caption,
121123
center,
124+
cite,
122125
code,
123-
pre,
124-
dt,
126+
data,
125127
dd,
126-
dl,
128+
del,
127129
details,
128-
html,
129-
body,
130+
dfn,
131+
div,
132+
dl,
133+
dt,
134+
em,
135+
embed,
130136
fieldset,
137+
figcaption,
131138
figure,
139+
font,
140+
footer,
141+
form,
132142
h1,
133143
h2,
134144
h3,
135145
h4,
136146
h5,
137147
h6,
148+
head,
149+
header,
150+
hgroup,
138151
hr,
152+
html,
153+
i: index,
139154
img,
140-
button,
141155
input,
142-
output,
143-
a,
144-
ol,
145-
ul,
146-
li,
147-
table,
148-
caption,
149-
q,
150-
del,
151156
ins,
152157
italic,
153-
strikethrough,
154-
underline,
155-
bold,
156-
samp,
157158
kbd,
158-
var: variableTag,
159+
keygen,
160+
label,
161+
li,
162+
link,
163+
main,
164+
map,
159165
mark,
160-
b,
166+
meta,
167+
nav,
168+
noscript,
169+
ol,
170+
optgroup,
171+
option,
172+
output,
173+
p,
174+
param: parameter,
175+
picture,
176+
pre,
177+
progress,
178+
q,
161179
s,
180+
samp,
181+
script,
182+
section,
183+
small,
184+
select,
185+
source,
186+
span,
162187
strike,
163-
em,
164-
i: index,
165-
cite,
188+
strikethrough,
166189
strong,
167-
u,
168-
small,
169-
big,
190+
style,
170191
sub,
192+
summary,
171193
sup,
194+
table,
195+
template,
172196
time,
197+
title,
198+
track,
173199
tt,
174-
font,
175-
data,
200+
u,
201+
ul,
202+
underline,
203+
var: variableTag,
204+
video,
176205
wbr,
177-
178-
//
179-
blockTag,
180-
181-
//
182-
183-
script,
184-
style,
185-
meta,
186-
audio,
187-
applet,
188-
area,
189-
map,
190-
base,
191-
track,
192-
embed,
193-
keygen,
194-
link,
195-
param: parameter,
196-
source,
197-
summary,
198-
199-
noscript,
200-
bgsound,
201-
202-
progress,
203-
204-
//
205-
'#text': __text,
206206
};

lib/tags/a.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,35 @@ export const a = inlineTag((value, tag) => {
1111

1212
const inHeader = findParrentTag(tag, ['h1', 'h2', 'h3']);
1313

14-
const href = rawHref
14+
const cleeanUrls = [
1515
// eslint-disable-next-line no-script-url
16-
&& !rawHref.startsWith('javascript:')
17-
? rawHref
18-
: null;
16+
'javascript:',
17+
'vbscript:',
18+
'vbscript:',
19+
'data:',
20+
'mailto:',
21+
'tel:',
22+
'sms:',
23+
'callto:',
24+
'cid:',
25+
'xmpp:',
26+
'skype:',
27+
'sip:',
28+
'sips:',
29+
'mms:',
30+
'rtmp:',
31+
'rtmpt:',
32+
'rtmps:',
33+
'rtmpts:',
34+
'magnet:',
35+
36+
'#',
37+
];
38+
39+
const href = !rawHref
40+
|| (cleeanUrls.some((url) => rawHref.startsWith(url)))
41+
? null
42+
: rawHref;
1943

2044
const title = getAttribute(tag, 'title', null);
2145

lib/tags/base-tags.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,9 @@ export const nav = block;
3737
export const aside = block;
3838
export const form = block;
3939
export const picture = block;
40-
export const figcaption = block;
4140
export const hgroup = block;
41+
42+
export const figcaption = blockTag((value) => chalk.bgGreen.bold(` § ${value} `), {
43+
marginTop: 1,
44+
marginBottom: 1,
45+
});

lib/tags/code.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ 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: {
30-
comment: chalk.blackBright.italic,
30+
comment: chalk.blackBright,
3131
},
32-
})
32+
}))
3333
: chalk.yellow(content);
3434

35-
const codeValueLines = codeValue.split('\n');
36-
3735
if (tag.parentNode.nodeName !== 'pre') {
38-
return codeValue;
36+
return chalk.bgBlack(codeValue);
3937
}
4038

39+
const codeValueLines = codeValue.split('\n');
40+
4141
const codeLinesLength = `${codeValueLines.length}`.length;
4242
const pad = `${Array.from({ length: codeLinesLength }).join(' ')} `;
4343

lib/tags/figure.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import ansiAlign from 'ansi-align';
12
import boxen from 'boxen';
23

34
import { blockTag } from '../tag-helpers/block-tag.js';
45

56
export const figure = (tag, context) => blockTag(
67
(value, tag) => {
7-
const valueInBox = boxen(value, {
8+
const valueInBox = boxen(ansiAlign(value, { align: 'center' }), {
89
padding: {
910
top: 0,
1011
bottom: 0,

lib/tags/void.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ export {
1010
voidTag as map,
1111
voidTag as meta,
1212
voidTag as noscript,
13+
voidTag as optgroup,
14+
voidTag as option,
1315
voidTag as param,
1416
voidTag as script,
17+
voidTag as select,
1518
voidTag as source,
1619
voidTag as style,
1720
voidTag as summary,
21+
voidTag as template,
1822
voidTag as track,
23+
voidTag as video,
1924
} from '../tag-helpers/void-tag.js';

0 commit comments

Comments
 (0)