@scalar/code-highlight 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/css/markdown.css +323 -173
- package/package.json +3 -3
- package/dist/code/highlight.test.js +0 -64
- package/dist/code/highlight.test.js.map +0 -7
- package/dist/markdown/getHeadings.test.js +0 -45
- package/dist/markdown/getHeadings.test.js.map +0 -7
- package/dist/markdown/htmlFromMarkdown.test.js +0 -41
- package/dist/markdown/htmlFromMarkdown.test.js.map +0 -7
- package/dist/markdown/splitContent.test.js +0 -17
- package/dist/markdown/splitContent.test.js.map +0 -7
- package/dist/rehype-alert/rehype-alert.test.js +0 -74
- package/dist/rehype-alert/rehype-alert.test.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scalar/code-highlight
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 00fc827: feat: updates markdown overall style
|
|
8
|
+
- 358eb63: fix(api-reference): fix markdown styles pt2
|
|
9
|
+
|
|
10
|
+
## 0.1.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 785939b: feat: adds id to markdown heading
|
|
15
|
+
- cad6277: feat(themes)!: migrate to tailwind v4
|
|
16
|
+
|
|
3
17
|
## 0.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/css/markdown.css
CHANGED
|
@@ -1,232 +1,165 @@
|
|
|
1
1
|
@import url("./code.css");
|
|
2
2
|
|
|
3
3
|
.scalar-app {
|
|
4
|
+
/* Base container and variables */
|
|
4
5
|
.markdown {
|
|
6
|
+
--scalar-refs-heading-spacing: 24px;
|
|
7
|
+
--markdown-border: var(--scalar-border-width) solid var(--scalar-border-color);
|
|
8
|
+
--markdown-spacing-sm: 12px;
|
|
9
|
+
--markdown-spacing-md: 16px;
|
|
10
|
+
--markdown-line-height: 1.625;
|
|
11
|
+
|
|
5
12
|
font-family: var(--scalar-font);
|
|
6
|
-
color: var(--scalar-color-1);
|
|
7
13
|
word-break: break-word;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.markdown h2,
|
|
13
|
-
.markdown h3,
|
|
14
|
-
.markdown h4,
|
|
15
|
-
.markdown h5,
|
|
16
|
-
.markdown h6,
|
|
17
|
-
.markdown p,
|
|
18
|
-
.markdown div,
|
|
19
|
-
.markdown img,
|
|
20
|
-
.markdown details,
|
|
21
|
-
.markdown summary,
|
|
22
|
-
.markdown ul,
|
|
23
|
-
.markdown ol,
|
|
24
|
-
.markdown table,
|
|
25
|
-
.markdown blockquote,
|
|
26
|
-
.markdown code {
|
|
27
|
-
margin: 12px 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.markdown details {
|
|
31
|
-
margin: 12px 0;
|
|
32
|
-
color: var(--scalar-color-1);
|
|
33
|
-
}
|
|
34
|
-
.markdown summary {
|
|
35
|
-
display: block;
|
|
36
|
-
margin: 1em 0;
|
|
37
|
-
padding-left: 20px;
|
|
38
|
-
position: relative;
|
|
39
|
-
font-weight: var(--scalar-semibold);
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
user-select: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.markdown summary::after {
|
|
45
|
-
display: block;
|
|
46
|
-
content: "";
|
|
47
|
-
|
|
48
|
-
position: absolute;
|
|
49
|
-
top: -1px;
|
|
50
|
-
left: -1px;
|
|
51
|
-
|
|
52
|
-
width: 20px;
|
|
53
|
-
height: 20px;
|
|
54
|
-
|
|
55
|
-
background-color: var(--scalar-color-3);
|
|
56
|
-
mask-image: url('data:image/svg+xml,<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m9 18 6-6-6-6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.markdown summary:hover::after {
|
|
60
|
-
background-color: var(--scalar-color-1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.markdown details[open] summary::after {
|
|
64
|
-
transform: rotate(90deg);
|
|
16
|
+
.markdown > * {
|
|
17
|
+
margin-bottom: var(--markdown-spacing-md);
|
|
65
18
|
}
|
|
66
19
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
border-radius: var(--scalar-radius);
|
|
70
|
-
max-width: 100%;
|
|
71
|
-
}
|
|
72
|
-
/* Don't add margin to the first block */
|
|
73
|
-
.markdown > :first-child {
|
|
74
|
-
margin-top: 0;
|
|
20
|
+
/* margin gets doubled between heading + non heading elements if we don't do this*/
|
|
21
|
+
.markdown > *:not(h1):not(h2):not(h3):not(h4):not(h5):not(h6):last-child {
|
|
75
22
|
margin-bottom: 0;
|
|
76
23
|
}
|
|
77
|
-
|
|
24
|
+
/* Headings (h1-h6) */
|
|
78
25
|
.markdown h1 {
|
|
79
|
-
--font-size: 1.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.markdown h2 {
|
|
83
|
-
--font-size: 1.25em;
|
|
26
|
+
--font-size: 1.5rem;
|
|
27
|
+
--markdown-line-height: 32px;
|
|
84
28
|
}
|
|
85
29
|
|
|
30
|
+
.markdown h2,
|
|
86
31
|
.markdown h3 {
|
|
87
|
-
--font-size: 1.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.markdown h4 {
|
|
91
|
-
--font-size: 1em;
|
|
32
|
+
--font-size: 1.25rem;
|
|
33
|
+
--markdown-line-height: 1.3;
|
|
92
34
|
}
|
|
93
35
|
|
|
36
|
+
.markdown h4,
|
|
37
|
+
.markdown h5,
|
|
94
38
|
.markdown h6 {
|
|
95
|
-
--font-size:
|
|
39
|
+
--font-size: 1rem;
|
|
96
40
|
}
|
|
41
|
+
|
|
97
42
|
.markdown h1,
|
|
98
43
|
.markdown h2,
|
|
99
44
|
.markdown h3,
|
|
100
45
|
.markdown h4,
|
|
101
46
|
.markdown h5,
|
|
102
47
|
.markdown h6 {
|
|
48
|
+
display: block;
|
|
103
49
|
font-size: var(--font-size);
|
|
104
|
-
margin: 18px 0 6px;
|
|
105
50
|
font-weight: var(--scalar-bold);
|
|
106
|
-
|
|
107
|
-
|
|
51
|
+
margin-top: var(--scalar-refs-heading-spacing);
|
|
52
|
+
margin-bottom: var(--markdown-spacing-sm);
|
|
53
|
+
scroll-margin-top: 1rem;
|
|
108
54
|
}
|
|
55
|
+
|
|
56
|
+
/* Text formatting and paragraphs */
|
|
109
57
|
.markdown b,
|
|
110
58
|
.markdown strong {
|
|
111
59
|
font-weight: var(--scalar-bold);
|
|
112
60
|
}
|
|
61
|
+
|
|
113
62
|
.markdown p {
|
|
114
63
|
color: inherit;
|
|
115
|
-
|
|
116
|
-
line-height: 1.5;
|
|
117
|
-
margin-bottom: 0;
|
|
64
|
+
line-height: var(--markdown-line-height);
|
|
118
65
|
display: block;
|
|
119
66
|
}
|
|
120
67
|
|
|
121
|
-
|
|
122
|
-
.markdown
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
display: block;
|
|
68
|
+
/* Images */
|
|
69
|
+
.markdown img {
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
border-radius: var(--scalar-radius);
|
|
72
|
+
max-width: 100%;
|
|
127
73
|
}
|
|
128
74
|
|
|
129
|
-
|
|
130
|
-
|
|
75
|
+
/* Lists */
|
|
76
|
+
.markdown ul:not(.contains-task-list),
|
|
77
|
+
.markdown ol {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
gap: 2px;
|
|
131
81
|
}
|
|
132
82
|
|
|
133
|
-
.markdown
|
|
134
|
-
list-style:
|
|
83
|
+
.markdown ul:not(.contains-task-list) {
|
|
84
|
+
list-style-position: inside;
|
|
135
85
|
}
|
|
136
86
|
|
|
137
|
-
.markdown ul
|
|
138
|
-
list-style:
|
|
139
|
-
padding-left: 0;
|
|
87
|
+
.markdown ul {
|
|
88
|
+
list-style-type: disc;
|
|
140
89
|
}
|
|
141
90
|
|
|
142
91
|
.markdown li {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
.markdown ul:first-of-type li:first-of-type {
|
|
147
|
-
margin-top: 0;
|
|
148
|
-
}
|
|
149
|
-
.markdown a {
|
|
150
|
-
color: var(--scalar-link-color, var(--scalar-color-accent));
|
|
151
|
-
font-weight: var(--scalar-link-font-weight, inherit);
|
|
152
|
-
text-decoration: var(--scalar-text-decoration);
|
|
153
|
-
cursor: pointer;
|
|
154
|
-
}
|
|
155
|
-
.markdown a:hover {
|
|
156
|
-
color: var(--scalar-link-color-hover, var(--scalar-color-accent));
|
|
157
|
-
text-decoration: var(--scalar-text-decoration-hover);
|
|
158
|
-
}
|
|
159
|
-
.markdown em {
|
|
160
|
-
font-style: italic;
|
|
161
|
-
}
|
|
162
|
-
.markdown sup {
|
|
163
|
-
font-size: var(--scalar-micro);
|
|
164
|
-
vertical-align: super;
|
|
165
|
-
font-weight: 450;
|
|
92
|
+
line-height: var(--markdown-line-height);
|
|
93
|
+
position: relative;
|
|
166
94
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
font-weight: 450;
|
|
95
|
+
|
|
96
|
+
.markdown ul li {
|
|
97
|
+
padding-left: var(--markdown-spacing-md);
|
|
171
98
|
}
|
|
172
|
-
|
|
173
|
-
|
|
99
|
+
|
|
100
|
+
.markdown ol {
|
|
101
|
+
counter-reset: item;
|
|
102
|
+
padding-left: 37.5px;
|
|
174
103
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
font
|
|
180
|
-
|
|
181
|
-
|
|
104
|
+
|
|
105
|
+
.markdown ol li::before {
|
|
106
|
+
content: counter(item) "\002E";
|
|
107
|
+
counter-increment: item;
|
|
108
|
+
font: var(--scalar-font);
|
|
109
|
+
font-weight: var(--scalar-semibold);
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: 0;
|
|
112
|
+
left: -24px;
|
|
113
|
+
line-height: var(--markdown-line-height);
|
|
114
|
+
margin-right: var(--markdown-spacing-sm);
|
|
182
115
|
}
|
|
183
116
|
|
|
184
|
-
.markdown
|
|
185
|
-
|
|
117
|
+
.markdown ol li::before,
|
|
118
|
+
.markdown ol ol ol li::before,
|
|
119
|
+
.markdown ol ol ol ol ol ol li::before {
|
|
120
|
+
content: counter(item, decimal) "\002E";
|
|
186
121
|
}
|
|
187
122
|
|
|
188
|
-
.markdown
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
line-height: 1.5;
|
|
193
|
-
margin: 12px 0;
|
|
194
|
-
-webkit-overflow-scrolling: touch;
|
|
195
|
-
overflow-x: auto;
|
|
196
|
-
max-width: 100%;
|
|
197
|
-
min-width: 100px;
|
|
123
|
+
.markdown ol ol li::before,
|
|
124
|
+
.markdown ol ol ol ol li::before,
|
|
125
|
+
.markdown ol ol ol ol ol ol ol li::before {
|
|
126
|
+
content: counter(item, lower-alpha) "\002E";
|
|
198
127
|
}
|
|
199
128
|
|
|
200
|
-
.markdown
|
|
201
|
-
|
|
202
|
-
|
|
129
|
+
.markdown ol ol li::before,
|
|
130
|
+
.markdown ol ol ol ol ol li::before,
|
|
131
|
+
.markdown ol ol ol ol ol ol ol ol li::before {
|
|
132
|
+
content: counter(item, lower-roman) "\002E";
|
|
203
133
|
}
|
|
204
134
|
|
|
205
|
-
.markdown
|
|
206
|
-
|
|
207
|
-
padding-left: 12px;
|
|
208
|
-
margin: 0;
|
|
209
|
-
display: block;
|
|
135
|
+
.markdown ul:first-of-type li:first-of-type {
|
|
136
|
+
margin-top: 0;
|
|
210
137
|
}
|
|
211
138
|
|
|
139
|
+
/* Tables */
|
|
212
140
|
.markdown table {
|
|
213
|
-
display:
|
|
141
|
+
display: table;
|
|
142
|
+
table-layout: fixed;
|
|
214
143
|
overflow-x: auto;
|
|
215
144
|
position: relative;
|
|
216
145
|
border-collapse: collapse;
|
|
217
|
-
width:
|
|
218
|
-
max-width: 100%;
|
|
146
|
+
width: 100%;
|
|
219
147
|
margin: 1em 0;
|
|
220
148
|
box-shadow: 0 0 0 var(--scalar-border-width) var(--scalar-border-color);
|
|
221
|
-
border-radius: var(--scalar-radius
|
|
149
|
+
border-radius: var(--scalar-radius);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.markdown tbody,
|
|
153
|
+
.markdown thead {
|
|
154
|
+
vertical-align: middle;
|
|
222
155
|
}
|
|
156
|
+
|
|
223
157
|
.markdown tbody {
|
|
224
158
|
display: table-row-group;
|
|
225
|
-
vertical-align: middle;
|
|
226
159
|
}
|
|
160
|
+
|
|
227
161
|
.markdown thead {
|
|
228
162
|
display: table-header-group;
|
|
229
|
-
vertical-align: middle;
|
|
230
163
|
}
|
|
231
164
|
|
|
232
165
|
.markdown tr {
|
|
@@ -234,30 +167,31 @@
|
|
|
234
167
|
border-color: inherit;
|
|
235
168
|
vertical-align: inherit;
|
|
236
169
|
}
|
|
170
|
+
|
|
237
171
|
.markdown td,
|
|
238
172
|
.markdown th {
|
|
239
173
|
display: table-cell;
|
|
240
|
-
vertical-align: inherit;
|
|
241
|
-
min-width: 1em;
|
|
242
|
-
padding: 6px 9px;
|
|
243
174
|
vertical-align: top;
|
|
244
|
-
|
|
175
|
+
min-width: 1em;
|
|
176
|
+
padding: 8.5px 16px;
|
|
177
|
+
line-height: var(--markdown-line-height);
|
|
245
178
|
position: relative;
|
|
246
179
|
word-break: initial;
|
|
247
180
|
font-size: var(--scalar-small);
|
|
248
181
|
color: var(--scalar-color-1);
|
|
249
|
-
|
|
250
|
-
border-
|
|
251
|
-
border-bottom: var(--scalar-border-width) solid var(--scalar-border-color);
|
|
182
|
+
border-right: var(--markdown-border);
|
|
183
|
+
border-bottom: var(--markdown-border);
|
|
252
184
|
}
|
|
253
185
|
|
|
254
186
|
.markdown td > *,
|
|
255
187
|
.markdown th > * {
|
|
256
188
|
margin-bottom: 0;
|
|
257
189
|
}
|
|
190
|
+
|
|
258
191
|
.markdown th:empty {
|
|
259
192
|
display: none;
|
|
260
193
|
}
|
|
194
|
+
|
|
261
195
|
.markdown td:first-of-type,
|
|
262
196
|
.markdown th:first-of-type {
|
|
263
197
|
border-left: none;
|
|
@@ -273,32 +207,248 @@
|
|
|
273
207
|
}
|
|
274
208
|
|
|
275
209
|
.markdown th {
|
|
276
|
-
font-weight: var(--scalar-
|
|
210
|
+
font-weight: var(--scalar-bold);
|
|
277
211
|
text-align: left;
|
|
278
212
|
border-left-color: transparent;
|
|
279
213
|
background: var(--scalar-background-2);
|
|
280
214
|
}
|
|
281
215
|
|
|
216
|
+
.markdown th:first-of-type {
|
|
217
|
+
border-top-left-radius: var(--scalar-radius);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.markdown th:last-of-type {
|
|
221
|
+
border-top-right-radius: var(--scalar-radius);
|
|
222
|
+
}
|
|
223
|
+
|
|
282
224
|
.markdown tr > [align="left"] {
|
|
283
225
|
text-align: left;
|
|
284
226
|
}
|
|
227
|
+
|
|
285
228
|
.markdown tr > [align="right"] {
|
|
286
229
|
text-align: right;
|
|
287
230
|
}
|
|
231
|
+
|
|
288
232
|
.markdown tr > [align="center"] {
|
|
289
233
|
text-align: center;
|
|
290
234
|
}
|
|
291
235
|
|
|
236
|
+
/* Details */
|
|
237
|
+
.markdown details {
|
|
238
|
+
border: var(--markdown-border);
|
|
239
|
+
border-radius: var(--scalar-radius);
|
|
240
|
+
color: var(--scalar-color-1);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.markdown details > :not(summary) {
|
|
244
|
+
margin: var(--markdown-spacing-md);
|
|
245
|
+
margin-bottom: 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.markdown details > p:has(> strong):not(:has(:not(strong))) {
|
|
249
|
+
margin-bottom: 8px;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.markdown details > p:has(> strong):not(:has(:not(strong))) + * {
|
|
253
|
+
margin-top: 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.markdown details > table {
|
|
257
|
+
width: calc(100% - calc(var(--markdown-spacing-md) * 2));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.markdown summary {
|
|
261
|
+
background-color: var(--scalar-background-2);
|
|
262
|
+
border-radius: var(--scalar-radius);
|
|
263
|
+
display: flex;
|
|
264
|
+
align-items: top;
|
|
265
|
+
height: 40px;
|
|
266
|
+
padding: 11px 0px 11px 40px;
|
|
267
|
+
position: relative;
|
|
268
|
+
font-weight: var(--scalar-semibold);
|
|
269
|
+
cursor: pointer;
|
|
270
|
+
user-select: none;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.markdown details[open] {
|
|
274
|
+
padding-bottom: var(--markdown-spacing-md);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.markdown details[open] summary {
|
|
278
|
+
border-bottom: var(--markdown-border);
|
|
279
|
+
border-bottom-left-radius: 0;
|
|
280
|
+
border-bottom-right-radius: 0;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.markdown summary::after {
|
|
284
|
+
display: block;
|
|
285
|
+
content: "";
|
|
286
|
+
position: absolute;
|
|
287
|
+
top: calc(var(--markdown-spacing-sm) + 1px);
|
|
288
|
+
left: 14px;
|
|
289
|
+
width: var(--markdown-spacing-md);
|
|
290
|
+
height: var(--markdown-spacing-md);
|
|
291
|
+
background-color: var(--scalar-color-3);
|
|
292
|
+
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 256 256"><path d="M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z"></path></svg>');
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.markdown summary:hover::after {
|
|
296
|
+
background-color: var(--scalar-color-1);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.markdown details[open] summary::after {
|
|
300
|
+
transform: rotate(90deg);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* Links */
|
|
304
|
+
.markdown a {
|
|
305
|
+
--font-color: var(--scalar-link-color, var(--scalar-color-accent));
|
|
306
|
+
--font-visited: var(--scalar-link-color-visited, var(--scalar-color-2));
|
|
307
|
+
text-decoration: var(--scalar-text-decoration);
|
|
308
|
+
|
|
309
|
+
color: var(--font-color);
|
|
310
|
+
font-weight: var(--scalar-link-font-weight, var(--scalar-semibold));
|
|
311
|
+
text-underline-offset: 0.25rem;
|
|
312
|
+
text-decoration-thickness: 1px;
|
|
313
|
+
text-decoration-color: color-mix(in srgb, var(--font-color) 30%, transparent);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.markdown a:hover {
|
|
317
|
+
text-decoration-color: var(currentColor, var(--scalar-color-1));
|
|
318
|
+
color: var(--scalar-link-color-hover, var(--scalar-color-accent));
|
|
319
|
+
-webkit-text-decoration: var(--scalar-text-decoration-hover);
|
|
320
|
+
text-decoration: var(--scalar-text-decoration-hover);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.markdown a:visited {
|
|
324
|
+
color: var(--font-visited);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* Text effects and formatting */
|
|
328
|
+
.markdown em {
|
|
329
|
+
font-style: italic;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.markdown sup,
|
|
333
|
+
.markdown sub {
|
|
334
|
+
font-size: var(--scalar-micro);
|
|
335
|
+
font-weight: 450;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.markdown sup {
|
|
339
|
+
vertical-align: super;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.markdown sub {
|
|
343
|
+
vertical-align: sub;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.markdown del {
|
|
347
|
+
text-decoration: line-through;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/* Code blocks and inline code */
|
|
351
|
+
.markdown code {
|
|
352
|
+
font-family: var(--scalar-font-code);
|
|
353
|
+
background-color: var(--scalar-background-2);
|
|
354
|
+
box-shadow: 0 0 0 var(--scalar-border-width) var(--scalar-border-color);
|
|
355
|
+
font-size: var(--scalar-micro);
|
|
356
|
+
border-radius: 2px;
|
|
357
|
+
padding: 0 3px;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.markdown .hljs {
|
|
361
|
+
font-size: var(--scalar-small);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.markdown pre code {
|
|
365
|
+
display: block;
|
|
366
|
+
white-space: pre;
|
|
367
|
+
padding: var(--markdown-spacing-sm);
|
|
368
|
+
line-height: 1.5;
|
|
369
|
+
margin: var(--markdown-spacing-sm) 0;
|
|
370
|
+
-webkit-overflow-scrolling: touch;
|
|
371
|
+
overflow-x: auto;
|
|
372
|
+
max-width: 100%;
|
|
373
|
+
min-width: 100px;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/* Horizontal rules */
|
|
377
|
+
.markdown hr {
|
|
378
|
+
border: none;
|
|
379
|
+
border-bottom: var(--markdown-border);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* Blockquotes */
|
|
383
|
+
.markdown blockquote {
|
|
384
|
+
border-left: 1px solid var(--scalar-color-1);
|
|
385
|
+
padding-left: var(--markdown-spacing-md);
|
|
386
|
+
margin: 0;
|
|
387
|
+
display: block;
|
|
388
|
+
font-weight: var(--scalar-bold);
|
|
389
|
+
font-size: var(--scalar-heading-2);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/* Markdown Checklist */
|
|
393
|
+
.markdown .contains-task-list {
|
|
394
|
+
display: flex;
|
|
395
|
+
flex-direction: column;
|
|
396
|
+
gap: 2px;
|
|
397
|
+
list-style: none;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.markdown .contains-task-list li {
|
|
401
|
+
align-items: center;
|
|
402
|
+
display: flex;
|
|
403
|
+
gap: 10.5px;
|
|
404
|
+
padding-left: 10.5px;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.markdown .contains-task-list input {
|
|
408
|
+
position: relative;
|
|
409
|
+
appearance: none;
|
|
410
|
+
-webkit-appearance: none;
|
|
411
|
+
display: flex;
|
|
412
|
+
width: var(--markdown-spacing-md);
|
|
413
|
+
height: var(--markdown-spacing-md);
|
|
414
|
+
align-content: center;
|
|
415
|
+
justify-content: center;
|
|
416
|
+
border: 1px solid var(--scalar-color-3);
|
|
417
|
+
border-radius: var(--scalar-radius);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.markdown .contains-task-list input:checked {
|
|
421
|
+
background-color: var(--scalar-color-1);
|
|
422
|
+
border-color: var(--scalar-color-1);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.markdown .contains-task-list input[type="checkbox"]::before {
|
|
426
|
+
content: "";
|
|
427
|
+
position: absolute;
|
|
428
|
+
left: 5px;
|
|
429
|
+
top: 1px;
|
|
430
|
+
width: 5px;
|
|
431
|
+
height: 10px;
|
|
432
|
+
border: solid var(--scalar-background-1);
|
|
433
|
+
border-width: 0 1.5px 1.5px 0;
|
|
434
|
+
transform: rotate(45deg);
|
|
435
|
+
opacity: 0;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.markdown .contains-task-list input[type="checkbox"]:checked::before {
|
|
439
|
+
opacity: 1;
|
|
440
|
+
}
|
|
441
|
+
|
|
292
442
|
/* Markdown Alert */
|
|
293
443
|
.markdown .markdown-alert {
|
|
294
444
|
align-items: stretch;
|
|
295
445
|
border-radius: var(--scalar-radius-lg);
|
|
296
446
|
background-color: color-mix(in srgb, var(--scalar-background-2), transparent);
|
|
297
|
-
border: var(--
|
|
447
|
+
border: var(--markdown-border);
|
|
298
448
|
display: flex;
|
|
299
449
|
font-size: var(--scalar-small);
|
|
300
|
-
gap:
|
|
301
|
-
padding:
|
|
450
|
+
gap: var(--markdown-spacing-sm);
|
|
451
|
+
padding: calc(var(--markdown-spacing-sm) - 0.5px);
|
|
302
452
|
padding-left: 42px;
|
|
303
453
|
position: relative;
|
|
304
454
|
}
|
|
@@ -306,10 +456,10 @@
|
|
|
306
456
|
.markdown .markdown-alert::before {
|
|
307
457
|
content: "";
|
|
308
458
|
position: absolute;
|
|
309
|
-
left:
|
|
310
|
-
top:
|
|
311
|
-
width:
|
|
312
|
-
height:
|
|
459
|
+
left: var(--markdown-spacing-sm);
|
|
460
|
+
top: calc(var(--markdown-spacing-sm) + 0.5px);
|
|
461
|
+
width: 16px;
|
|
462
|
+
height: 16px;
|
|
313
463
|
background-color: currentColor;
|
|
314
464
|
mask-repeat: no-repeat;
|
|
315
465
|
mask-size: contain;
|
|
@@ -354,6 +504,6 @@
|
|
|
354
504
|
|
|
355
505
|
.markdown .markdown-alert .markdown-alert-content {
|
|
356
506
|
margin: 0;
|
|
357
|
-
line-height:
|
|
507
|
+
line-height: 20px;
|
|
358
508
|
}
|
|
359
509
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lowlight",
|
|
17
17
|
"highlightjs"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.1.
|
|
19
|
+
"version": "0.1.2",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=20"
|
|
22
22
|
},
|
|
@@ -97,8 +97,8 @@
|
|
|
97
97
|
"vfile": "^6.0.1",
|
|
98
98
|
"vite": "5.4.19",
|
|
99
99
|
"vue": "^3.5.12",
|
|
100
|
-
"@scalar/build-tooling": "0.2.
|
|
101
|
-
"@scalar/themes": "0.
|
|
100
|
+
"@scalar/build-tooling": "0.2.2",
|
|
101
|
+
"@scalar/themes": "0.13.2"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "scalar-build-esbuild",
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { syntaxHighlight } from "./highlight.js";
|
|
3
|
-
describe("syntaxHighlight", () => {
|
|
4
|
-
const mockLanguages = {
|
|
5
|
-
javascript: () => ({
|
|
6
|
-
name: "javascript",
|
|
7
|
-
aliases: ["js"],
|
|
8
|
-
contains: []
|
|
9
|
-
})
|
|
10
|
-
};
|
|
11
|
-
const defaultOptions = {
|
|
12
|
-
lang: "javascript",
|
|
13
|
-
languages: mockLanguages
|
|
14
|
-
};
|
|
15
|
-
const codeExample = `
|
|
16
|
-
fetch('https://galaxy.scalar.com/planets', {
|
|
17
|
-
method: 'POST',
|
|
18
|
-
headers: {
|
|
19
|
-
'Content-Type': 'application/json'
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
`;
|
|
23
|
-
it("should return highlighted HTML for a given code string", () => {
|
|
24
|
-
const result = syntaxHighlight(codeExample, defaultOptions);
|
|
25
|
-
expect(result).toContain('class="hljs language-javascript"');
|
|
26
|
-
});
|
|
27
|
-
it("should mask credentials in the code string", () => {
|
|
28
|
-
const codeWithCredentials = `
|
|
29
|
-
fetch('https://galaxy.scalar.com/planets', {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
'Authorization': 'Bearer secret'
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
`;
|
|
37
|
-
const options = {
|
|
38
|
-
...defaultOptions,
|
|
39
|
-
maskCredentials: ["secret"]
|
|
40
|
-
};
|
|
41
|
-
const result = syntaxHighlight(codeWithCredentials, options);
|
|
42
|
-
expect(result).toContain('<span class="credential"><span class="credential-value">secret</span></span>');
|
|
43
|
-
});
|
|
44
|
-
it("should handle line numbers if option is enabled", () => {
|
|
45
|
-
const options = {
|
|
46
|
-
...defaultOptions,
|
|
47
|
-
lineNumbers: true
|
|
48
|
-
};
|
|
49
|
-
const result = syntaxHighlight(codeExample, options);
|
|
50
|
-
expect(result).toContain('class="line"');
|
|
51
|
-
});
|
|
52
|
-
it("should correctly work with special characters in credentials", () => {
|
|
53
|
-
const codeExampleWithSpecialChar = `
|
|
54
|
-
const secret = '(secret';
|
|
55
|
-
`;
|
|
56
|
-
const options = {
|
|
57
|
-
...defaultOptions,
|
|
58
|
-
maskCredentials: ["(secret"]
|
|
59
|
-
};
|
|
60
|
-
const result = syntaxHighlight(codeExampleWithSpecialChar, options);
|
|
61
|
-
expect(result).toContain('<span class="credential"><span class="credential-value">(secret</span></span>');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=highlight.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/code/highlight.test.ts"],
|
|
4
|
-
"sourcesContent": ["import type { LanguageFn } from 'highlight.js'\nimport { describe, expect, it } from 'vitest'\n\nimport { syntaxHighlight } from './highlight'\n\ndescribe('syntaxHighlight', () => {\n const mockLanguages: Record<string, LanguageFn> = {\n javascript: () => ({\n name: 'javascript',\n aliases: ['js'],\n contains: [],\n }),\n }\n\n const defaultOptions = {\n lang: 'javascript',\n languages: mockLanguages,\n }\n\n const codeExample = `\n fetch('https://galaxy.scalar.com/planets', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n }\n })\n `\n\n it('should return highlighted HTML for a given code string', () => {\n const result = syntaxHighlight(codeExample, defaultOptions)\n expect(result).toContain('class=\"hljs language-javascript\"')\n })\n\n it('should mask credentials in the code string', () => {\n const codeWithCredentials = `\n fetch('https://galaxy.scalar.com/planets', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': 'Bearer secret'\n }\n })\n `\n const options = {\n ...defaultOptions,\n maskCredentials: ['secret'],\n }\n\n const result = syntaxHighlight(codeWithCredentials, options)\n expect(result).toContain('<span class=\"credential\"><span class=\"credential-value\">secret</span></span>')\n })\n\n it('should handle line numbers if option is enabled', () => {\n const options = {\n ...defaultOptions,\n lineNumbers: true,\n }\n\n const result = syntaxHighlight(codeExample, options)\n expect(result).toContain('class=\"line\"')\n })\n\n it('should correctly work with special characters in credentials', () => {\n const codeExampleWithSpecialChar = `\n const secret = '(secret';\n `\n const options = {\n ...defaultOptions,\n maskCredentials: ['(secret'],\n }\n\n const result = syntaxHighlight(codeExampleWithSpecialChar, options)\n expect(result).toContain('<span class=\"credential\"><span class=\"credential-value\">(secret</span></span>')\n })\n})\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,uBAAuB;AAEhC,SAAS,mBAAmB,MAAM;AAChC,QAAM,gBAA4C;AAAA,IAChD,YAAY,OAAO;AAAA,MACjB,MAAM;AAAA,MACN,SAAS,CAAC,IAAI;AAAA,MACd,UAAU,CAAC;AAAA,IACb;AAAA,EACF;AAEA,QAAM,iBAAiB;AAAA,IACrB,MAAM;AAAA,IACN,WAAW;AAAA,EACb;AAEA,QAAM,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASpB,KAAG,0DAA0D,MAAM;AACjE,UAAM,SAAS,gBAAgB,aAAa,cAAc;AAC1D,WAAO,MAAM,EAAE,UAAU,kCAAkC;AAAA,EAC7D,CAAC;AAED,KAAG,8CAA8C,MAAM;AACrD,UAAM,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS5B,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,iBAAiB,CAAC,QAAQ;AAAA,IAC5B;AAEA,UAAM,SAAS,gBAAgB,qBAAqB,OAAO;AAC3D,WAAO,MAAM,EAAE,UAAU,8EAA8E;AAAA,EACzG,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,aAAa;AAAA,IACf;AAEA,UAAM,SAAS,gBAAgB,aAAa,OAAO;AACnD,WAAO,MAAM,EAAE,UAAU,cAAc;AAAA,EACzC,CAAC;AAED,KAAG,gEAAgE,MAAM;AACvE,UAAM,6BAA6B;AAAA;AAAA;AAGnC,UAAM,UAAU;AAAA,MACd,GAAG;AAAA,MACH,iBAAiB,CAAC,SAAS;AAAA,IAC7B;AAEA,UAAM,SAAS,gBAAgB,4BAA4B,OAAO;AAClE,WAAO,MAAM,EAAE,UAAU,+EAA+E;AAAA,EAC1G,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { getHeadings } from "./markdown.js";
|
|
3
|
-
describe("getHeadings", () => {
|
|
4
|
-
it("gets a heading", () => {
|
|
5
|
-
const markdown = "# Example Heading";
|
|
6
|
-
const headings = getHeadings(markdown);
|
|
7
|
-
expect(headings).toStrictEqual([{ depth: 1, value: "Example Heading" }]);
|
|
8
|
-
});
|
|
9
|
-
it("gets nested headings", () => {
|
|
10
|
-
const markdown = `
|
|
11
|
-
# Example Heading
|
|
12
|
-
|
|
13
|
-
## Nested Heading
|
|
14
|
-
`;
|
|
15
|
-
const headings = getHeadings(markdown);
|
|
16
|
-
expect(headings).toStrictEqual([
|
|
17
|
-
{ depth: 1, value: "Example Heading" },
|
|
18
|
-
{ depth: 2, value: "Nested Heading" }
|
|
19
|
-
]);
|
|
20
|
-
});
|
|
21
|
-
it("ignores Markdown in code blocks", () => {
|
|
22
|
-
const markdown = `
|
|
23
|
-
# Example Heading
|
|
24
|
-
|
|
25
|
-
## Not a heading
|
|
26
|
-
|
|
27
|
-
## Nested Heading
|
|
28
|
-
|
|
29
|
-
\`\`\`
|
|
30
|
-
## Not a heading
|
|
31
|
-
\`\`\`
|
|
32
|
-
`;
|
|
33
|
-
const headings = getHeadings(markdown);
|
|
34
|
-
expect(headings).toStrictEqual([
|
|
35
|
-
{ depth: 1, value: "Example Heading" },
|
|
36
|
-
{ depth: 2, value: "Nested Heading" }
|
|
37
|
-
]);
|
|
38
|
-
});
|
|
39
|
-
it("works with links in headings", () => {
|
|
40
|
-
const markdown = "# [Example Heading](#example-heading)";
|
|
41
|
-
const headings = getHeadings(markdown);
|
|
42
|
-
expect(headings).toStrictEqual([{ depth: 1, value: "Example Heading" }]);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
//# sourceMappingURL=getHeadings.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/markdown/getHeadings.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { getHeadings } from './markdown'\n\ndescribe('getHeadings', () => {\n it('gets a heading', () => {\n const markdown = '# Example Heading'\n\n const headings = getHeadings(markdown)\n\n expect(headings).toStrictEqual([{ depth: 1, value: 'Example Heading' }])\n })\n\n it('gets nested headings', () => {\n const markdown = `\n# Example Heading\n\n## Nested Heading\n`\n\n const headings = getHeadings(markdown)\n\n expect(headings).toStrictEqual([\n { depth: 1, value: 'Example Heading' },\n { depth: 2, value: 'Nested Heading' },\n ])\n })\n\n it('ignores Markdown in code blocks', () => {\n const markdown = `\n# Example Heading\n\n ## Not a heading\n\n## Nested Heading\n\n\\`\\`\\`\n## Not a heading\n\\`\\`\\`\n`\n\n const headings = getHeadings(markdown)\n\n expect(headings).toStrictEqual([\n { depth: 1, value: 'Example Heading' },\n { depth: 2, value: 'Nested Heading' },\n ])\n })\n\n it('works with links in headings', () => {\n const markdown = '# [Example Heading](#example-heading)'\n\n const headings = getHeadings(markdown)\n\n expect(headings).toStrictEqual([{ depth: 1, value: 'Example Heading' }])\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,mBAAmB;AAE5B,SAAS,eAAe,MAAM;AAC5B,KAAG,kBAAkB,MAAM;AACzB,UAAM,WAAW;AAEjB,UAAM,WAAW,YAAY,QAAQ;AAErC,WAAO,QAAQ,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,kBAAkB,CAAC,CAAC;AAAA,EACzE,CAAC;AAED,KAAG,wBAAwB,MAAM;AAC/B,UAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAMjB,UAAM,WAAW,YAAY,QAAQ;AAErC,WAAO,QAAQ,EAAE,cAAc;AAAA,MAC7B,EAAE,OAAO,GAAG,OAAO,kBAAkB;AAAA,MACrC,EAAE,OAAO,GAAG,OAAO,iBAAiB;AAAA,IACtC,CAAC;AAAA,EACH,CAAC;AAED,KAAG,mCAAmC,MAAM;AAC1C,UAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYjB,UAAM,WAAW,YAAY,QAAQ;AAErC,WAAO,QAAQ,EAAE,cAAc;AAAA,MAC7B,EAAE,OAAO,GAAG,OAAO,kBAAkB;AAAA,MACrC,EAAE,OAAO,GAAG,OAAO,iBAAiB;AAAA,IACtC,CAAC;AAAA,EACH,CAAC;AAED,KAAG,gCAAgC,MAAM;AACvC,UAAM,WAAW;AAEjB,UAAM,WAAW,YAAY,QAAQ;AAErC,WAAO,QAAQ,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,kBAAkB,CAAC,CAAC;AAAA,EACzE,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { htmlFromMarkdown } from "./markdown.js";
|
|
3
|
-
describe("htmlFromMarkdown", () => {
|
|
4
|
-
it("returns HTML", () => {
|
|
5
|
-
const html = htmlFromMarkdown("# Example Heading");
|
|
6
|
-
expect(html.trim()).toEqual("<h1>Example Heading</h1>");
|
|
7
|
-
});
|
|
8
|
-
it("removes tags", () => {
|
|
9
|
-
const html = htmlFromMarkdown("# <i>Example</i> <em>Heading</em>", {
|
|
10
|
-
removeTags: ["i"]
|
|
11
|
-
});
|
|
12
|
-
expect(html.trim()).toEqual("<h1>Example <em>Heading</em></h1>");
|
|
13
|
-
});
|
|
14
|
-
it("removes script tags", () => {
|
|
15
|
-
const html = htmlFromMarkdown(`# Example Heading<script>alert('foobar');<\/script>`);
|
|
16
|
-
expect(html.trim()).toEqual("<h1>Example Heading</h1>");
|
|
17
|
-
});
|
|
18
|
-
it("allows given tags", () => {
|
|
19
|
-
const html = htmlFromMarkdown(`# Example Heading<script>alert('foobar');<\/script>`, {
|
|
20
|
-
allowTags: ["script"]
|
|
21
|
-
});
|
|
22
|
-
expect(html.trim()).toEqual(`<h1>Example Heading
|
|
23
|
-
<script>alert('foobar');<\/script>
|
|
24
|
-
</h1>`);
|
|
25
|
-
});
|
|
26
|
-
it("allows to add ids", () => {
|
|
27
|
-
const html = htmlFromMarkdown("# Example Heading", {
|
|
28
|
-
transformType: "heading",
|
|
29
|
-
transform: (node) => {
|
|
30
|
-
node.data = {
|
|
31
|
-
hProperties: {
|
|
32
|
-
id: "example-heading"
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
return node;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
expect(html.trim()).toEqual('<h1 id="example-heading">Example Heading</h1>');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=htmlFromMarkdown.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/markdown/htmlFromMarkdown.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { htmlFromMarkdown } from './markdown'\n\ndescribe('htmlFromMarkdown', () => {\n it('returns HTML', () => {\n const html = htmlFromMarkdown('# Example Heading')\n\n expect(html.trim()).toEqual('<h1>Example Heading</h1>')\n })\n\n it('removes tags', () => {\n const html = htmlFromMarkdown('# <i>Example</i> <em>Heading</em>', {\n removeTags: ['i'],\n })\n\n expect(html.trim()).toEqual('<h1>Example <em>Heading</em></h1>')\n })\n\n it('removes script tags', () => {\n const html = htmlFromMarkdown(`# Example Heading<script>alert('foobar');</script>`)\n\n expect(html.trim()).toEqual('<h1>Example Heading</h1>')\n })\n\n it('allows given tags', () => {\n const html = htmlFromMarkdown(`# Example Heading<script>alert('foobar');</script>`, {\n allowTags: ['script'],\n })\n\n expect(html.trim()).toEqual(`<h1>Example Heading\\n <script>alert('foobar');</script>\\n</h1>`)\n })\n\n it('allows to add ids', () => {\n const html = htmlFromMarkdown('# Example Heading', {\n transformType: 'heading',\n transform: (node) => {\n node.data = {\n hProperties: {\n id: 'example-heading',\n },\n }\n\n return node\n },\n })\n\n expect(html.trim()).toEqual('<h1 id=\"example-heading\">Example Heading</h1>')\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,wBAAwB;AAEjC,SAAS,oBAAoB,MAAM;AACjC,KAAG,gBAAgB,MAAM;AACvB,UAAM,OAAO,iBAAiB,mBAAmB;AAEjD,WAAO,KAAK,KAAK,CAAC,EAAE,QAAQ,0BAA0B;AAAA,EACxD,CAAC;AAED,KAAG,gBAAgB,MAAM;AACvB,UAAM,OAAO,iBAAiB,qCAAqC;AAAA,MACjE,YAAY,CAAC,GAAG;AAAA,IAClB,CAAC;AAED,WAAO,KAAK,KAAK,CAAC,EAAE,QAAQ,mCAAmC;AAAA,EACjE,CAAC;AAED,KAAG,uBAAuB,MAAM;AAC9B,UAAM,OAAO,iBAAiB,qDAAoD;AAElF,WAAO,KAAK,KAAK,CAAC,EAAE,QAAQ,0BAA0B;AAAA,EACxD,CAAC;AAED,KAAG,qBAAqB,MAAM;AAC5B,UAAM,OAAO,iBAAiB,uDAAsD;AAAA,MAClF,WAAW,CAAC,QAAQ;AAAA,IACtB,CAAC;AAED,WAAO,KAAK,KAAK,CAAC,EAAE,QAAQ;AAAA;AAAA,MAAiE;AAAA,EAC/F,CAAC;AAED,KAAG,qBAAqB,MAAM;AAC5B,UAAM,OAAO,iBAAiB,qBAAqB;AAAA,MACjD,eAAe;AAAA,MACf,WAAW,CAAC,SAAS;AACnB,aAAK,OAAO;AAAA,UACV,aAAa;AAAA,YACX,IAAI;AAAA,UACN;AAAA,QACF;AAEA,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,WAAO,KAAK,KAAK,CAAC,EAAE,QAAQ,+CAA+C;AAAA,EAC7E,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { splitContent } from "./markdown.js";
|
|
3
|
-
describe("splitContent", () => {
|
|
4
|
-
it("returns a single document if there\u2019s no heading", () => {
|
|
5
|
-
const sections = splitContent("Foobar");
|
|
6
|
-
expect(sections).toMatchObject(["Foobar"]);
|
|
7
|
-
});
|
|
8
|
-
it("splits the markdown document", () => {
|
|
9
|
-
const sections = splitContent("# Example Heading\n\nFoobar");
|
|
10
|
-
expect(sections).toMatchObject(["# Example Heading", "Foobar"]);
|
|
11
|
-
});
|
|
12
|
-
it("splits multiple headings", () => {
|
|
13
|
-
const sections = splitContent("# Example Heading\n\n## Other Heading\n\nFoobar");
|
|
14
|
-
expect(sections).toMatchObject(["# Example Heading", "## Other Heading", "Foobar"]);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=splitContent.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/markdown/splitContent.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\n\nimport { splitContent } from './markdown'\n\ndescribe('splitContent', () => {\n it('returns a single document if there\u2019s no heading', () => {\n const sections = splitContent('Foobar')\n\n expect(sections).toMatchObject(['Foobar'])\n })\n\n it('splits the markdown document', () => {\n const sections = splitContent('# Example Heading\\n\\nFoobar')\n\n expect(sections).toMatchObject(['# Example Heading', 'Foobar'])\n })\n\n it('splits multiple headings', () => {\n const sections = splitContent('# Example Heading\\n\\n## Other Heading\\n\\nFoobar')\n\n expect(sections).toMatchObject(['# Example Heading', '## Other Heading', 'Foobar'])\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AAErC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,wDAAmD,MAAM;AAC1D,UAAM,WAAW,aAAa,QAAQ;AAEtC,WAAO,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC;AAAA,EAC3C,CAAC;AAED,KAAG,gCAAgC,MAAM;AACvC,UAAM,WAAW,aAAa,6BAA6B;AAE3D,WAAO,QAAQ,EAAE,cAAc,CAAC,qBAAqB,QAAQ,CAAC;AAAA,EAChE,CAAC;AAED,KAAG,4BAA4B,MAAM;AACnC,UAAM,WAAW,aAAa,iDAAiD;AAE/E,WAAO,QAAQ,EAAE,cAAc,CAAC,qBAAqB,oBAAoB,QAAQ,CAAC;AAAA,EACpF,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { unified } from "unified";
|
|
3
|
-
import remarkParse from "remark-parse";
|
|
4
|
-
import remarkRehype from "remark-rehype";
|
|
5
|
-
import rehypeStringify from "rehype-stringify";
|
|
6
|
-
import { rehypeAlert } from "./rehype-alert.js";
|
|
7
|
-
describe("rehype-alert", () => {
|
|
8
|
-
const process = async (markdown) => {
|
|
9
|
-
const file = await unified().use(remarkParse).use(remarkRehype, { allowDangerousHtml: true }).use(rehypeAlert).use(rehypeStringify).process(markdown);
|
|
10
|
-
return String(file);
|
|
11
|
-
};
|
|
12
|
-
it("transforms note alerts correctly", async () => {
|
|
13
|
-
const input = "> [!note]\n> This is a note callout.";
|
|
14
|
-
const output = await process(input);
|
|
15
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-note">');
|
|
16
|
-
expect(output).toContain('<div class="markdown-alert-content">');
|
|
17
|
-
expect(output).toContain("This is a note callout.");
|
|
18
|
-
});
|
|
19
|
-
it("transforms warning alerts correctly", async () => {
|
|
20
|
-
const input = "> [!warning]\n> This is a warning callout.";
|
|
21
|
-
const output = await process(input);
|
|
22
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-warning">');
|
|
23
|
-
expect(output).toContain("This is a warning callout.");
|
|
24
|
-
});
|
|
25
|
-
it("transforms caution alerts correctly", async () => {
|
|
26
|
-
const input = "> [!caution]\n> This is a caution callout.";
|
|
27
|
-
const output = await process(input);
|
|
28
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-caution">');
|
|
29
|
-
expect(output).toContain("This is a caution callout.");
|
|
30
|
-
});
|
|
31
|
-
it("transforms important alerts correctly", async () => {
|
|
32
|
-
const input = "> [!important]\n> This is an important callout.";
|
|
33
|
-
const output = await process(input);
|
|
34
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-important">');
|
|
35
|
-
expect(output).toContain("This is an important callout.");
|
|
36
|
-
});
|
|
37
|
-
it("transforms tip alerts correctly", async () => {
|
|
38
|
-
const input = "> [!tip]\n> This is a tip callout.";
|
|
39
|
-
const output = await process(input);
|
|
40
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-tip">');
|
|
41
|
-
expect(output).toContain("This is a tip callout.");
|
|
42
|
-
});
|
|
43
|
-
it("ignores blockquotes without alert syntax", async () => {
|
|
44
|
-
const input = "> This is a regular blockquote.";
|
|
45
|
-
const output = await process(input);
|
|
46
|
-
expect(output).not.toContain("markdown-alert");
|
|
47
|
-
expect(output).toContain("<blockquote>");
|
|
48
|
-
expect(output).toContain("This is a regular blockquote.");
|
|
49
|
-
});
|
|
50
|
-
it("ignores invalid alert types", async () => {
|
|
51
|
-
const input = "> [!invalid]\n> This is an invalid alert type.";
|
|
52
|
-
const output = await process(input);
|
|
53
|
-
expect(output).not.toContain("markdown-alert");
|
|
54
|
-
expect(output).toContain("<blockquote>");
|
|
55
|
-
expect(output).toContain("[!invalid]");
|
|
56
|
-
expect(output).toContain("This is an invalid alert type.");
|
|
57
|
-
});
|
|
58
|
-
it("handles multiline alert content correctly", async () => {
|
|
59
|
-
const input = "> [!note]\n> First line\n> Second line\n> Third line";
|
|
60
|
-
const output = await process(input);
|
|
61
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-note">');
|
|
62
|
-
expect(output).toContain("First line");
|
|
63
|
-
expect(output).toContain("Second line");
|
|
64
|
-
expect(output).toContain("Third line");
|
|
65
|
-
});
|
|
66
|
-
it("preserves HTML structure in alert content", async () => {
|
|
67
|
-
const input = "> [!note]\n> This is a note with **bold** and *italic* text.";
|
|
68
|
-
const output = await process(input);
|
|
69
|
-
expect(output).toContain('<div class="markdown-alert markdown-alert-note">');
|
|
70
|
-
expect(output).toContain("<strong>bold</strong>");
|
|
71
|
-
expect(output).toContain("<em>italic</em>");
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
//# sourceMappingURL=rehype-alert.test.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/rehype-alert/rehype-alert.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { describe, expect, it } from 'vitest'\nimport { unified } from 'unified'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport rehypeStringify from 'rehype-stringify'\nimport { rehypeAlert } from './rehype-alert'\n\ndescribe('rehype-alert', () => {\n const process = async (markdown: string) => {\n const file = await unified()\n .use(remarkParse)\n .use(remarkRehype, { allowDangerousHtml: true })\n .use(rehypeAlert)\n .use(rehypeStringify)\n .process(markdown)\n\n return String(file)\n }\n\n it('transforms note alerts correctly', async () => {\n const input = '> [!note]\\n> This is a note callout.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-note\">')\n expect(output).toContain('<div class=\"markdown-alert-content\">')\n expect(output).toContain('This is a note callout.')\n })\n\n it('transforms warning alerts correctly', async () => {\n const input = '> [!warning]\\n> This is a warning callout.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-warning\">')\n expect(output).toContain('This is a warning callout.')\n })\n\n it('transforms caution alerts correctly', async () => {\n const input = '> [!caution]\\n> This is a caution callout.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-caution\">')\n expect(output).toContain('This is a caution callout.')\n })\n\n it('transforms important alerts correctly', async () => {\n const input = '> [!important]\\n> This is an important callout.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-important\">')\n expect(output).toContain('This is an important callout.')\n })\n\n it('transforms tip alerts correctly', async () => {\n const input = '> [!tip]\\n> This is a tip callout.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-tip\">')\n expect(output).toContain('This is a tip callout.')\n })\n\n it('ignores blockquotes without alert syntax', async () => {\n const input = '> This is a regular blockquote.'\n const output = await process(input)\n\n expect(output).not.toContain('markdown-alert')\n expect(output).toContain('<blockquote>')\n expect(output).toContain('This is a regular blockquote.')\n })\n\n it('ignores invalid alert types', async () => {\n const input = '> [!invalid]\\n> This is an invalid alert type.'\n const output = await process(input)\n\n expect(output).not.toContain('markdown-alert')\n expect(output).toContain('<blockquote>')\n expect(output).toContain('[!invalid]')\n expect(output).toContain('This is an invalid alert type.')\n })\n\n it('handles multiline alert content correctly', async () => {\n const input = '> [!note]\\n> First line\\n> Second line\\n> Third line'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-note\">')\n expect(output).toContain('First line')\n expect(output).toContain('Second line')\n expect(output).toContain('Third line')\n })\n\n it('preserves HTML structure in alert content', async () => {\n const input = '> [!note]\\n> This is a note with **bold** and *italic* text.'\n const output = await process(input)\n\n expect(output).toContain('<div class=\"markdown-alert markdown-alert-note\">')\n expect(output).toContain('<strong>bold</strong>')\n expect(output).toContain('<em>italic</em>')\n })\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,eAAe;AACxB,OAAO,iBAAiB;AACxB,OAAO,kBAAkB;AACzB,OAAO,qBAAqB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,gBAAgB,MAAM;AAC7B,QAAM,UAAU,OAAO,aAAqB;AAC1C,UAAM,OAAO,MAAM,QAAQ,EACxB,IAAI,WAAW,EACf,IAAI,cAAc,EAAE,oBAAoB,KAAK,CAAC,EAC9C,IAAI,WAAW,EACf,IAAI,eAAe,EACnB,QAAQ,QAAQ;AAEnB,WAAO,OAAO,IAAI;AAAA,EACpB;AAEA,KAAG,oCAAoC,YAAY;AACjD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,kDAAkD;AAC3E,WAAO,MAAM,EAAE,UAAU,sCAAsC;AAC/D,WAAO,MAAM,EAAE,UAAU,yBAAyB;AAAA,EACpD,CAAC;AAED,KAAG,uCAAuC,YAAY;AACpD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,qDAAqD;AAC9E,WAAO,MAAM,EAAE,UAAU,4BAA4B;AAAA,EACvD,CAAC;AAED,KAAG,uCAAuC,YAAY;AACpD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,qDAAqD;AAC9E,WAAO,MAAM,EAAE,UAAU,4BAA4B;AAAA,EACvD,CAAC;AAED,KAAG,yCAAyC,YAAY;AACtD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,uDAAuD;AAChF,WAAO,MAAM,EAAE,UAAU,+BAA+B;AAAA,EAC1D,CAAC;AAED,KAAG,mCAAmC,YAAY;AAChD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,iDAAiD;AAC1E,WAAO,MAAM,EAAE,UAAU,wBAAwB;AAAA,EACnD,CAAC;AAED,KAAG,4CAA4C,YAAY;AACzD,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,IAAI,UAAU,gBAAgB;AAC7C,WAAO,MAAM,EAAE,UAAU,cAAc;AACvC,WAAO,MAAM,EAAE,UAAU,+BAA+B;AAAA,EAC1D,CAAC;AAED,KAAG,+BAA+B,YAAY;AAC5C,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,IAAI,UAAU,gBAAgB;AAC7C,WAAO,MAAM,EAAE,UAAU,cAAc;AACvC,WAAO,MAAM,EAAE,UAAU,YAAY;AACrC,WAAO,MAAM,EAAE,UAAU,gCAAgC;AAAA,EAC3D,CAAC;AAED,KAAG,6CAA6C,YAAY;AAC1D,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,kDAAkD;AAC3E,WAAO,MAAM,EAAE,UAAU,YAAY;AACrC,WAAO,MAAM,EAAE,UAAU,aAAa;AACtC,WAAO,MAAM,EAAE,UAAU,YAAY;AAAA,EACvC,CAAC;AAED,KAAG,6CAA6C,YAAY;AAC1D,UAAM,QAAQ;AACd,UAAM,SAAS,MAAM,QAAQ,KAAK;AAElC,WAAO,MAAM,EAAE,UAAU,kDAAkD;AAC3E,WAAO,MAAM,EAAE,UAAU,uBAAuB;AAChD,WAAO,MAAM,EAAE,UAAU,iBAAiB;AAAA,EAC5C,CAAC;AACH,CAAC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|