@jianwen-lang/parser 0.1.1
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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/cli/render.d.ts +1 -0
- package/dist/cli/render.js +300 -0
- package/dist/core/ast.d.ts +286 -0
- package/dist/core/ast.js +2 -0
- package/dist/core/block/rules/heading.d.ts +9 -0
- package/dist/core/block/rules/heading.js +75 -0
- package/dist/core/block/rules/horizontal-rule.d.ts +9 -0
- package/dist/core/block/rules/horizontal-rule.js +87 -0
- package/dist/core/block/rules/include.d.ts +9 -0
- package/dist/core/block/rules/include.js +64 -0
- package/dist/core/block/rules/index.d.ts +2 -0
- package/dist/core/block/rules/index.js +16 -0
- package/dist/core/block/rules/types.d.ts +21 -0
- package/dist/core/block/rules/types.js +2 -0
- package/dist/core/block/types.d.ts +10 -0
- package/dist/core/block/types.js +2 -0
- package/dist/core/block-parser.d.ts +3 -0
- package/dist/core/block-parser.js +1385 -0
- package/dist/core/clone.d.ts +9 -0
- package/dist/core/clone.js +32 -0
- package/dist/core/diagnostics.d.ts +12 -0
- package/dist/core/diagnostics.js +24 -0
- package/dist/core/errors.d.ts +12 -0
- package/dist/core/errors.js +2 -0
- package/dist/core/inline/rules/backtick.d.ts +4 -0
- package/dist/core/inline/rules/backtick.js +90 -0
- package/dist/core/inline/rules/bracket.d.ts +4 -0
- package/dist/core/inline/rules/bracket.js +721 -0
- package/dist/core/inline/rules/disabled.d.ts +2 -0
- package/dist/core/inline/rules/disabled.js +34 -0
- package/dist/core/inline/rules/escape.d.ts +2 -0
- package/dist/core/inline/rules/escape.js +11 -0
- package/dist/core/inline/rules/index.d.ts +2 -0
- package/dist/core/inline/rules/index.js +25 -0
- package/dist/core/inline/rules/marker-highlight.d.ts +4 -0
- package/dist/core/inline/rules/marker-highlight.js +56 -0
- package/dist/core/inline/rules/style.d.ts +4 -0
- package/dist/core/inline/rules/style.js +120 -0
- package/dist/core/inline/rules/types.d.ts +22 -0
- package/dist/core/inline/rules/types.js +2 -0
- package/dist/core/inline/types.d.ts +1 -0
- package/dist/core/inline/types.js +2 -0
- package/dist/core/inline-parser.d.ts +3 -0
- package/dist/core/inline-parser.js +52 -0
- package/dist/core/location.d.ts +9 -0
- package/dist/core/location.js +30 -0
- package/dist/core/parser.d.ts +9 -0
- package/dist/core/parser.js +423 -0
- package/dist/core/traverse.d.ts +7 -0
- package/dist/core/traverse.js +71 -0
- package/dist/html/convert.d.ts +29 -0
- package/dist/html/convert.js +61 -0
- package/dist/html/format.d.ts +1 -0
- package/dist/html/format.js +17 -0
- package/dist/html/render/blocks.d.ts +4 -0
- package/dist/html/render/blocks.js +433 -0
- package/dist/html/render/html.d.ts +8 -0
- package/dist/html/render/html.js +89 -0
- package/dist/html/render/inlines.d.ts +4 -0
- package/dist/html/render/inlines.js +110 -0
- package/dist/html/render/meta.d.ts +3 -0
- package/dist/html/render/meta.js +51 -0
- package/dist/html/render/utils.d.ts +31 -0
- package/dist/html/render/utils.js +213 -0
- package/dist/html/theme/base/css.d.ts +2 -0
- package/dist/html/theme/base/css.js +383 -0
- package/dist/html/theme/dark/css.d.ts +2 -0
- package/dist/html/theme/dark/css.js +108 -0
- package/dist/html/theme/default/colors.d.ts +13 -0
- package/dist/html/theme/default/colors.js +2 -0
- package/dist/html/theme/default/css.d.ts +2 -0
- package/dist/html/theme/default/css.js +6 -0
- package/dist/html/theme/default/runtime.d.ts +0 -0
- package/dist/html/theme/default/runtime.js +31 -0
- package/dist/html/theme/light/css.d.ts +2 -0
- package/dist/html/theme/light/css.js +55 -0
- package/dist/html/theme/preset/colors.d.ts +10 -0
- package/dist/html/theme/preset/colors.js +14 -0
- package/dist/html/theme/runtime.d.ts +0 -0
- package/dist/html/theme/runtime.js +31 -0
- package/dist/html/theme/theme.d.ts +9 -0
- package/dist/html/theme/theme.js +21 -0
- package/dist/lexer/lexer.d.ts +17 -0
- package/dist/lexer/lexer.js +47 -0
- package/dist/parser.d.ts +6 -0
- package/dist/parser.js +22 -0
- package/package.json +50 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const BASE_CSS = `
|
|
3
|
+
html,
|
|
4
|
+
body {
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
.jw-root {
|
|
9
|
+
background-color: var(--jw-bg-color, transparent);
|
|
10
|
+
color: var(--jw-text-color, inherit);
|
|
11
|
+
display: flow-root;
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
}
|
|
14
|
+
.jw-root > .jw-block + .jw-block { margin-top: var(--jw-block-spacing); }
|
|
15
|
+
.jw-root > .jw-block { margin: 0; }
|
|
16
|
+
.jw-table { border-collapse: collapse; }
|
|
17
|
+
.jw-table-cell { border: 1px solid var(--jw-border-color); padding: 0.5em; }
|
|
18
|
+
.jw-link { text-decoration: none; color: var(--jw-link-color, currentColor); }
|
|
19
|
+
.jw-link:visited { color: var(--jw-link-color, currentColor); }
|
|
20
|
+
.jw-link:hover { text-decoration: underline; }
|
|
21
|
+
.jw-underline { text-decoration: underline; }
|
|
22
|
+
.jw-strike { text-decoration: line-through; }
|
|
23
|
+
.jw-wave { text-decoration: underline; text-decoration-style: wavy; }
|
|
24
|
+
.jw-heading { font-weight: bold; margin: 0; }
|
|
25
|
+
.jw-heading.level-1 { font-size: 2.5em; }
|
|
26
|
+
.jw-heading.level-2 { font-size: 2em; }
|
|
27
|
+
.jw-heading.level-3 { font-size: 1.75em; }
|
|
28
|
+
.jw-heading.level-4 { font-size: 1.5em; }
|
|
29
|
+
.jw-heading.level-5 { font-size: 1.25em; }
|
|
30
|
+
.jw-foldable-section { margin: 1em 0; }
|
|
31
|
+
.jw-foldable-section > summary {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
user-select: none;
|
|
34
|
+
list-style: none;
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
.jw-foldable-section > summary::-webkit-details-marker {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
.jw-foldable-section > summary::before {
|
|
42
|
+
content: '';
|
|
43
|
+
display: block;
|
|
44
|
+
width: 0.5em;
|
|
45
|
+
height: 0.5em;
|
|
46
|
+
margin-right: 0.4em;
|
|
47
|
+
flex: 0 0 auto;
|
|
48
|
+
background: currentColor;
|
|
49
|
+
clip-path: polygon(0 0, 100% 50%, 0 100%);
|
|
50
|
+
transform: rotate(0deg);
|
|
51
|
+
opacity: 0.74;
|
|
52
|
+
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
53
|
+
}
|
|
54
|
+
.jw-foldable-section[open] > summary::before {
|
|
55
|
+
transform: rotate(90deg);
|
|
56
|
+
opacity: 0.85;
|
|
57
|
+
}
|
|
58
|
+
.jw-foldable-section > summary .jw-heading {
|
|
59
|
+
display: inline;
|
|
60
|
+
margin: 0;
|
|
61
|
+
min-width: 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.jw-content-title {
|
|
65
|
+
margin-top: 0.1em;
|
|
66
|
+
margin-bottom: 0;
|
|
67
|
+
font-size: 0.85em;
|
|
68
|
+
color: var(--jw-text-muted);
|
|
69
|
+
}
|
|
70
|
+
.jw-content-title-gap {
|
|
71
|
+
display: block;
|
|
72
|
+
height: 0.8em;
|
|
73
|
+
min-height: 8px;
|
|
74
|
+
}
|
|
75
|
+
.jw-quote {
|
|
76
|
+
margin: 0;
|
|
77
|
+
border-left: 4px solid var(--jw-quote-border-color);
|
|
78
|
+
padding: 0 1em;
|
|
79
|
+
background: var(--jw-quote-background);
|
|
80
|
+
color: var(--jw-quote-text);
|
|
81
|
+
}
|
|
82
|
+
.jw-quote > .jw-paragraph { margin: var(--jw-quote-gap) 0; }
|
|
83
|
+
.jw-quote > .jw-quote { margin: var(--jw-quote-gap) 0; }
|
|
84
|
+
[data-jw-level="2"].jw-quote { border-left-color: var(--jw-quote-border-color-2); }
|
|
85
|
+
[data-jw-level="3"].jw-quote { border-left-color: var(--jw-quote-border-color-3); }
|
|
86
|
+
.jw-paragraph { white-space: pre-wrap; line-height: var(--jw-line-height-base); }
|
|
87
|
+
.jw-paragraph-block { white-space: normal; }
|
|
88
|
+
.jw-list { padding-left: 1.25em; }
|
|
89
|
+
.jw-list[data-jw-list-kind="bullet"] { list-style-type: disc; }
|
|
90
|
+
.jw-hr { border: none; border-top: 1px solid currentColor; color: var(--jw-border-color); height: 0; background: none; padding: 0; margin: 0; }
|
|
91
|
+
.jw-hr[data-jw-position="L"] { width: 100%; }
|
|
92
|
+
.jw-hr[data-jw-position="C"] { width: 66.67%; }
|
|
93
|
+
.jw-hr[data-jw-position="R"] { width: 33.34%; }
|
|
94
|
+
.jw-hr[data-jw-hr-style="dashed"] { border-top-style: dashed; }
|
|
95
|
+
.jw-hr[data-jw-hr-style="bold"] { border-top-width: 4px; }
|
|
96
|
+
.jw-hr[data-jw-hr-style="wavy"] {
|
|
97
|
+
border: none;
|
|
98
|
+
height: 8px;
|
|
99
|
+
color: var(--jw-border-color);
|
|
100
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4 Q 8 0 16 4 T 32 4' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
|
|
101
|
+
background-size: 32px 8px;
|
|
102
|
+
background-repeat: repeat-x;
|
|
103
|
+
background-position: center bottom;
|
|
104
|
+
background-color: transparent;
|
|
105
|
+
}
|
|
106
|
+
.jw-highlight-marker { background-color: var(--jw-highlight-marker); padding: 0; }
|
|
107
|
+
.jw-highlight-frame { border: 1px solid var(--jw-border-color); padding: 0; border-radius: 3px; }
|
|
108
|
+
.jw-highlight-block {
|
|
109
|
+
display: block;
|
|
110
|
+
padding: 0.75em 1em;
|
|
111
|
+
white-space: normal;
|
|
112
|
+
}
|
|
113
|
+
.jw-list[data-jw-list-kind="task"] { list-style: none; padding-left: 0; }
|
|
114
|
+
.jw-list-item[data-jw-list-kind="task"] { list-style: none; }
|
|
115
|
+
.jw-list-item[data-jw-list-kind="task"][data-jw-task-status] {
|
|
116
|
+
position: relative;
|
|
117
|
+
padding-left: 0;
|
|
118
|
+
margin: 0.25em 0;
|
|
119
|
+
}
|
|
120
|
+
.jw-list-item {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-flow: row wrap;
|
|
123
|
+
align-items: flex-start;
|
|
124
|
+
}
|
|
125
|
+
.jw-list-item[data-jw-list-kind="bullet"] {
|
|
126
|
+
display: list-item;
|
|
127
|
+
}
|
|
128
|
+
.jw-list-ordinal {
|
|
129
|
+
margin-right: 0.5em;
|
|
130
|
+
line-height: var(--jw-line-height-base);
|
|
131
|
+
flex-shrink: 0;
|
|
132
|
+
color: var(--jw-text-strong);
|
|
133
|
+
font-variant-numeric: tabular-nums;
|
|
134
|
+
}
|
|
135
|
+
.jw-list-task-marker {
|
|
136
|
+
display: inline-flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
width: 1.25em;
|
|
140
|
+
height: 1.25em;
|
|
141
|
+
border: 1px solid var(--jw-border-color-strong);
|
|
142
|
+
background: var(--jw-surface-task);
|
|
143
|
+
border-radius: 2px;
|
|
144
|
+
font-size: 0.85em;
|
|
145
|
+
color: transparent;
|
|
146
|
+
transition: all 0.2s ease;
|
|
147
|
+
box-sizing: border-box;
|
|
148
|
+
margin-right: 0.5em;
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
margin-top: 0.375em;
|
|
151
|
+
position: relative;
|
|
152
|
+
line-height: 1;
|
|
153
|
+
}
|
|
154
|
+
.jw-list-task-marker::before,
|
|
155
|
+
.jw-list-task-marker::after {
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 50%;
|
|
158
|
+
left: 50%;
|
|
159
|
+
transform: translate(-50%, -50%);
|
|
160
|
+
content: '';
|
|
161
|
+
}
|
|
162
|
+
.jw-list-task-marker[data-jw-task-status="done"] {
|
|
163
|
+
content: '✔';
|
|
164
|
+
}
|
|
165
|
+
.jw-list-task-marker[data-jw-task-status="done"]::before {
|
|
166
|
+
content: '✔';
|
|
167
|
+
color: var(--jw-task-done-text);
|
|
168
|
+
}
|
|
169
|
+
.jw-list-task-marker[data-jw-task-status="done"] {
|
|
170
|
+
background: var(--jw-task-done-bg);
|
|
171
|
+
border-color: var(--jw-task-done-bg);
|
|
172
|
+
}
|
|
173
|
+
.jw-list-task-marker[data-jw-task-status="not_done"]::before,
|
|
174
|
+
.jw-list-task-marker[data-jw-task-status="not_done"]::after {
|
|
175
|
+
width: 0.85em;
|
|
176
|
+
height: 0.12em;
|
|
177
|
+
background: var(--jw-task-not-done-cross);
|
|
178
|
+
border-radius: 999px;
|
|
179
|
+
}
|
|
180
|
+
.jw-list-task-marker[data-jw-task-status="not_done"]::before {
|
|
181
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
182
|
+
}
|
|
183
|
+
.jw-list-task-marker[data-jw-task-status="not_done"]::after {
|
|
184
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
185
|
+
}
|
|
186
|
+
.jw-list-task-marker[data-jw-task-status="not_done"] {
|
|
187
|
+
background: var(--jw-border-color-strong);
|
|
188
|
+
border-color: var(--jw-border-color-strong);
|
|
189
|
+
}
|
|
190
|
+
.jw-list-task-marker[data-jw-task-status="in_progress"]::before {
|
|
191
|
+
width: 0.7em;
|
|
192
|
+
height: 0.7em;
|
|
193
|
+
border: 0.12em solid var(--jw-task-in-progress);
|
|
194
|
+
border-radius: 50%;
|
|
195
|
+
}
|
|
196
|
+
.jw-list-task-marker[data-jw-task-status="unknown"] {
|
|
197
|
+
/* Empty box */
|
|
198
|
+
}
|
|
199
|
+
.jw-list-item > .jw-paragraph {
|
|
200
|
+
flex: 1 1 auto;
|
|
201
|
+
margin: 0;
|
|
202
|
+
min-width: 0;
|
|
203
|
+
line-height: var(--jw-line-height-base);
|
|
204
|
+
}
|
|
205
|
+
.jw-list-item > .jw-list {
|
|
206
|
+
flex-basis: 100%;
|
|
207
|
+
width: 100%;
|
|
208
|
+
padding-left: 2em;
|
|
209
|
+
margin: var(--jw-nested-list-gap) 0 0 0;
|
|
210
|
+
}
|
|
211
|
+
.jw-list-item + .jw-list-item {
|
|
212
|
+
margin-top: var(--jw-nested-list-gap);
|
|
213
|
+
}
|
|
214
|
+
.jw-list-item > .jw-code-block {
|
|
215
|
+
flex-basis: 100%;
|
|
216
|
+
width: 100%;
|
|
217
|
+
margin-top: var(--jw-nested-list-gap);
|
|
218
|
+
}
|
|
219
|
+
.jw-list-item[data-jw-task-status="done"] > .jw-paragraph {
|
|
220
|
+
text-decoration: line-through;
|
|
221
|
+
color: var(--jw-text-faint);
|
|
222
|
+
}
|
|
223
|
+
.jw-list-item[data-jw-list-kind="ordered"] {
|
|
224
|
+
list-style: none;
|
|
225
|
+
}
|
|
226
|
+
.jw-list-item[data-jw-list-kind="ordered"]::marker {
|
|
227
|
+
content: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.jw-list-item[data-jw-list-kind="foldable"] { list-style: none; }
|
|
231
|
+
.jw-foldable-list-item {
|
|
232
|
+
display: block;
|
|
233
|
+
}
|
|
234
|
+
.jw-foldable-list-item > summary {
|
|
235
|
+
cursor: pointer;
|
|
236
|
+
user-select: none;
|
|
237
|
+
list-style: none;
|
|
238
|
+
position: relative;
|
|
239
|
+
padding-left: 1.2em;
|
|
240
|
+
}
|
|
241
|
+
.jw-foldable-list-item > summary::-webkit-details-marker {
|
|
242
|
+
display: none;
|
|
243
|
+
}
|
|
244
|
+
.jw-foldable-list-item > summary::before {
|
|
245
|
+
content: '';
|
|
246
|
+
position: absolute;
|
|
247
|
+
left: 0;
|
|
248
|
+
top: 50%;
|
|
249
|
+
width: 0.45em;
|
|
250
|
+
height: 0.45em;
|
|
251
|
+
background: currentColor;
|
|
252
|
+
clip-path: polygon(0 0, 100% 50%, 0 100%);
|
|
253
|
+
transform: translateY(-50%) rotate(0deg);
|
|
254
|
+
opacity: 0.68;
|
|
255
|
+
transition: transform 0.2s ease, opacity 0.2s ease;
|
|
256
|
+
}
|
|
257
|
+
.jw-foldable-list-item[open] > summary::before {
|
|
258
|
+
transform: translateY(-50%) rotate(90deg);
|
|
259
|
+
opacity: 0.85;
|
|
260
|
+
}
|
|
261
|
+
.jw-foldable-list-item > summary .jw-paragraph {
|
|
262
|
+
display: inline;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.jw-image-figure { }
|
|
266
|
+
.jw-image { max-width: 100%; max-height: 600px; width: auto; height: auto; object-fit: contain; }
|
|
267
|
+
.jw-image-caption { margin-top: 0.5em; font-size: 0.9em; color: var(--jw-text-subtle); }
|
|
268
|
+
.jw-image-figure[data-jw-shape="rounded"] .jw-image { border-radius: 8px; }
|
|
269
|
+
.jw-code-block {
|
|
270
|
+
position: relative;
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-direction: column;
|
|
273
|
+
padding: 0;
|
|
274
|
+
background: var(--jw-surface-code);
|
|
275
|
+
border: 1px solid var(--jw-border-color-subtle);
|
|
276
|
+
border-radius: 4px;
|
|
277
|
+
font-family: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
|
|
278
|
+
font-size: 0.9em;
|
|
279
|
+
line-height: 1.5;
|
|
280
|
+
margin: 0;
|
|
281
|
+
}
|
|
282
|
+
.jw-code-header {
|
|
283
|
+
display: flex;
|
|
284
|
+
justify-content: space-between;
|
|
285
|
+
align-items: center;
|
|
286
|
+
padding: 0.5em 0.75em;
|
|
287
|
+
border-bottom: 1px solid var(--jw-border-color-subtle);
|
|
288
|
+
background: var(--jw-surface-overlay-1);
|
|
289
|
+
}
|
|
290
|
+
.jw-code-lang {
|
|
291
|
+
padding: 0.1em 0.4em;
|
|
292
|
+
background: var(--jw-surface-overlay-2);
|
|
293
|
+
color: var(--jw-text-subtle);
|
|
294
|
+
font-size: 0.75em;
|
|
295
|
+
border-radius: 3px;
|
|
296
|
+
font-weight: 500;
|
|
297
|
+
text-transform: uppercase;
|
|
298
|
+
letter-spacing: 0.05em;
|
|
299
|
+
}
|
|
300
|
+
.jw-code-copy {
|
|
301
|
+
padding: 0.25em 0.5em;
|
|
302
|
+
background: transparent;
|
|
303
|
+
border: 1px solid var(--jw-border-color);
|
|
304
|
+
border-radius: 3px;
|
|
305
|
+
cursor: pointer;
|
|
306
|
+
font-size: 0.75em;
|
|
307
|
+
color: var(--jw-text-subtle);
|
|
308
|
+
transition: background 0.2s, border-color 0.2s;
|
|
309
|
+
}
|
|
310
|
+
.jw-code-copy:hover {
|
|
311
|
+
background: var(--jw-surface-overlay-2);
|
|
312
|
+
border-color: var(--jw-border-color-strong);
|
|
313
|
+
}
|
|
314
|
+
.jw-code-copy:active {
|
|
315
|
+
background: var(--jw-surface-overlay-3);
|
|
316
|
+
}
|
|
317
|
+
.jw-code-content {
|
|
318
|
+
display: flex;
|
|
319
|
+
padding: 1em 1em 1em 0;
|
|
320
|
+
}
|
|
321
|
+
.jw-line-numbers {
|
|
322
|
+
flex-shrink: 0;
|
|
323
|
+
display: flex;
|
|
324
|
+
flex-direction: column;
|
|
325
|
+
padding: 0 0.75em;
|
|
326
|
+
border-right: 1px solid var(--jw-border-color-subtle);
|
|
327
|
+
text-align: right;
|
|
328
|
+
user-select: none;
|
|
329
|
+
color: var(--jw-text-faint);
|
|
330
|
+
font-variant-numeric: tabular-nums;
|
|
331
|
+
}
|
|
332
|
+
.jw-line-number {
|
|
333
|
+
display: block;
|
|
334
|
+
min-height: 1.5em;
|
|
335
|
+
}
|
|
336
|
+
.jw-code {
|
|
337
|
+
flex: 1;
|
|
338
|
+
display: block;
|
|
339
|
+
overflow-x: auto;
|
|
340
|
+
padding: 0 1em;
|
|
341
|
+
background: transparent;
|
|
342
|
+
font-family: inherit;
|
|
343
|
+
white-space: pre;
|
|
344
|
+
}
|
|
345
|
+
.jw-code-line {
|
|
346
|
+
display: block;
|
|
347
|
+
white-space: pre;
|
|
348
|
+
min-height: 1.5em;
|
|
349
|
+
}
|
|
350
|
+
.jw-disabled-block { font-family: inherit; white-space: pre-wrap; line-height: var(--jw-line-height-base); margin: 0; }
|
|
351
|
+
[data-jw-position="C"] { margin-left: 33.33%; }
|
|
352
|
+
[data-jw-position="R"] { margin-left: 66.66%; }
|
|
353
|
+
[data-jw-truncate-left="true"] { margin-left: 0; }
|
|
354
|
+
[data-jw-truncate-right="true"] { max-width: 33.33%; word-wrap: break-word; overflow-wrap: break-word; }
|
|
355
|
+
[data-jw-position="C"][data-jw-truncate-right="true"] { max-width: 33.33%; }
|
|
356
|
+
[data-jw-position="R"][data-jw-truncate-right="true"] { max-width: 33.33%; }
|
|
357
|
+
.jw-hr[data-jw-truncate-right="true"] { width: 33.33%; max-width: none; }
|
|
358
|
+
[data-jw-align="center"] { text-align: center; }
|
|
359
|
+
[data-jw-align="right"] { text-align: right; }
|
|
360
|
+
.jw-same-line-row { display: flex; flex-wrap: nowrap; gap: 0; align-items: flex-start; max-width: 100%; overflow: hidden; }
|
|
361
|
+
.jw-same-line-row > * { flex-shrink: 1; word-wrap: break-word; overflow-wrap: break-word; min-width: 0; }
|
|
362
|
+
.jw-same-line-row > [data-jw-position="L"]:not(:last-child),
|
|
363
|
+
.jw-same-line-row > [data-jw-position="C"]:not(:last-child),
|
|
364
|
+
.jw-same-line-row > [data-jw-position="R"]:not(:last-child) { flex-basis: 33.33%; max-width: 33.33%; }
|
|
365
|
+
.jw-same-line-row > [data-jw-position="L"]:last-child,
|
|
366
|
+
.jw-same-line-row > [data-jw-position="C"]:last-child,
|
|
367
|
+
.jw-same-line-row > [data-jw-position="R"]:last-child { flex-grow: 1; flex-basis: 0; }
|
|
368
|
+
.jw-same-line-row > [data-jw-position] { margin-left: 0; }
|
|
369
|
+
.jw-same-line-row > [data-jw-position="C"]:first-child { margin-left: 33.33%; }
|
|
370
|
+
.jw-same-line-row > [data-jw-position="R"]:first-child { margin-left: 66.66%; }
|
|
371
|
+
.jw-meta { margin: 0 0 var(--jw-block-spacing); }
|
|
372
|
+
.jw-meta-time,
|
|
373
|
+
.jw-meta-add-info,
|
|
374
|
+
.jw-meta-tags,
|
|
375
|
+
.jw-meta-author {
|
|
376
|
+
color: var(--jw-quote-text);
|
|
377
|
+
}
|
|
378
|
+
.jw-meta-author-link { text-decoration: none; color: inherit; }
|
|
379
|
+
.jw-meta-author-link:hover { text-decoration: underline; }
|
|
380
|
+
.jw-comment-inline { display: none; }
|
|
381
|
+
.jw-comment-block { display: none; }
|
|
382
|
+
`;
|
|
383
|
+
module.exports = BASE_CSS;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const PRESET_COLORS = require('../preset/colors');
|
|
3
|
+
const DARK_CSS = `
|
|
4
|
+
:where(.jw-root)[data-jw-theme="dark"] {
|
|
5
|
+
color-scheme: dark;
|
|
6
|
+
--jw-line-height-base: 1.7;
|
|
7
|
+
--jw-block-spacing: 1em;
|
|
8
|
+
--jw-nested-list-gap: 0.35em;
|
|
9
|
+
--jw-quote-gap: 0.6em;
|
|
10
|
+
|
|
11
|
+
--jw-bg-color: #15171c;
|
|
12
|
+
--jw-text-color: #e8e9ed;
|
|
13
|
+
--jw-link-color: #8ab4f8;
|
|
14
|
+
|
|
15
|
+
--jw-quote-border-color: #343843;
|
|
16
|
+
--jw-quote-border-color-2: #2c313a;
|
|
17
|
+
--jw-quote-border-color-3: #252a33;
|
|
18
|
+
--jw-quote-background: #1d2028;
|
|
19
|
+
--jw-quote-text: #c9ccd5;
|
|
20
|
+
|
|
21
|
+
--jw-border-color: #333844;
|
|
22
|
+
--jw-border-color-subtle: #282d38;
|
|
23
|
+
--jw-border-color-strong: #434958;
|
|
24
|
+
|
|
25
|
+
--jw-text-muted: #b3b7c2;
|
|
26
|
+
--jw-text-subtle: #9aa0ad;
|
|
27
|
+
--jw-text-strong: #d7d9e2;
|
|
28
|
+
--jw-text-faint: #7c8494;
|
|
29
|
+
|
|
30
|
+
--jw-surface-code: #1c1f26;
|
|
31
|
+
--jw-surface-task: #262b36;
|
|
32
|
+
--jw-surface-overlay-1: rgba(255, 255, 255, 0.03);
|
|
33
|
+
--jw-surface-overlay-2: rgba(255, 255, 255, 0.06);
|
|
34
|
+
--jw-surface-overlay-3: rgba(255, 255, 255, 0.1);
|
|
35
|
+
|
|
36
|
+
--jw-highlight-marker: #d2b21f;
|
|
37
|
+
|
|
38
|
+
--jw-task-done-bg: #cfd3dd;
|
|
39
|
+
--jw-task-done-text: #1c1f26;
|
|
40
|
+
--jw-task-not-done-cross: #eef1f7;
|
|
41
|
+
--jw-task-in-progress: #b7bdca;
|
|
42
|
+
|
|
43
|
+
--jw-color-red: ${PRESET_COLORS.red};
|
|
44
|
+
--jw-color-orange: ${PRESET_COLORS.orange};
|
|
45
|
+
--jw-color-yellow: ${PRESET_COLORS.yellow};
|
|
46
|
+
--jw-color-green: ${PRESET_COLORS.green};
|
|
47
|
+
--jw-color-cyan: ${PRESET_COLORS.cyan};
|
|
48
|
+
--jw-color-blue: ${PRESET_COLORS.blue};
|
|
49
|
+
--jw-color-purple: ${PRESET_COLORS.purple};
|
|
50
|
+
--jw-color-black: ${PRESET_COLORS.black};
|
|
51
|
+
--jw-color-darkgray: ${PRESET_COLORS.darkgray};
|
|
52
|
+
--jw-color-gray: ${PRESET_COLORS.gray};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@media (prefers-color-scheme: dark) {
|
|
56
|
+
:where(.jw-root)[data-jw-theme="auto"] {
|
|
57
|
+
color-scheme: dark;
|
|
58
|
+
--jw-line-height-base: 1.7;
|
|
59
|
+
--jw-block-spacing: 1em;
|
|
60
|
+
--jw-nested-list-gap: 0.35em;
|
|
61
|
+
--jw-quote-gap: 0.6em;
|
|
62
|
+
|
|
63
|
+
--jw-bg-color: #15171c;
|
|
64
|
+
--jw-text-color: #e8e9ed;
|
|
65
|
+
--jw-link-color: #8ab4f8;
|
|
66
|
+
|
|
67
|
+
--jw-quote-border-color: #343843;
|
|
68
|
+
--jw-quote-border-color-2: #2c313a;
|
|
69
|
+
--jw-quote-border-color-3: #252a33;
|
|
70
|
+
--jw-quote-background: #1d2028;
|
|
71
|
+
--jw-quote-text: #c9ccd5;
|
|
72
|
+
|
|
73
|
+
--jw-border-color: #333844;
|
|
74
|
+
--jw-border-color-subtle: #282d38;
|
|
75
|
+
--jw-border-color-strong: #434958;
|
|
76
|
+
|
|
77
|
+
--jw-text-muted: #b3b7c2;
|
|
78
|
+
--jw-text-subtle: #9aa0ad;
|
|
79
|
+
--jw-text-strong: #d7d9e2;
|
|
80
|
+
--jw-text-faint: #7c8494;
|
|
81
|
+
|
|
82
|
+
--jw-surface-code: #1c1f26;
|
|
83
|
+
--jw-surface-task: #262b36;
|
|
84
|
+
--jw-surface-overlay-1: rgba(255, 255, 255, 0.03);
|
|
85
|
+
--jw-surface-overlay-2: rgba(255, 255, 255, 0.06);
|
|
86
|
+
--jw-surface-overlay-3: rgba(255, 255, 255, 0.1);
|
|
87
|
+
|
|
88
|
+
--jw-highlight-marker: #d2b21f;
|
|
89
|
+
|
|
90
|
+
--jw-task-done-bg: #cfd3dd;
|
|
91
|
+
--jw-task-done-text: #1c1f26;
|
|
92
|
+
--jw-task-not-done-cross: #eef1f7;
|
|
93
|
+
--jw-task-in-progress: #b7bdca;
|
|
94
|
+
|
|
95
|
+
--jw-color-red: ${PRESET_COLORS.red};
|
|
96
|
+
--jw-color-orange: ${PRESET_COLORS.orange};
|
|
97
|
+
--jw-color-yellow: ${PRESET_COLORS.yellow};
|
|
98
|
+
--jw-color-green: ${PRESET_COLORS.green};
|
|
99
|
+
--jw-color-cyan: ${PRESET_COLORS.cyan};
|
|
100
|
+
--jw-color-blue: ${PRESET_COLORS.blue};
|
|
101
|
+
--jw-color-purple: ${PRESET_COLORS.purple};
|
|
102
|
+
--jw-color-black: ${PRESET_COLORS.black};
|
|
103
|
+
--jw-color-darkgray: ${PRESET_COLORS.darkgray};
|
|
104
|
+
--jw-color-gray: ${PRESET_COLORS.gray};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
module.exports = DARK_CSS;
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const ROOT_SELECTOR = '.jw-root';
|
|
7
|
+
const THEME_ATTR = 'data-jw-theme';
|
|
8
|
+
const VALID_THEMES = new Set(['light', 'dark', 'auto']);
|
|
9
|
+
function getRoots() {
|
|
10
|
+
return Array.from(document.querySelectorAll(ROOT_SELECTOR));
|
|
11
|
+
}
|
|
12
|
+
function setTheme(theme) {
|
|
13
|
+
if (!VALID_THEMES.has(theme)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const root of getRoots()) {
|
|
17
|
+
root.setAttribute(THEME_ATTR, theme);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toggleTheme() {
|
|
21
|
+
for (const root of getRoots()) {
|
|
22
|
+
const current = root.getAttribute(THEME_ATTR);
|
|
23
|
+
const next = current === 'dark' ? 'light' : 'dark';
|
|
24
|
+
root.setAttribute(THEME_ATTR, next);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
window.JianwenTheme = Object.assign(window.JianwenTheme || {}, {
|
|
28
|
+
setTheme,
|
|
29
|
+
toggleTheme,
|
|
30
|
+
});
|
|
31
|
+
})();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const PRESET_COLORS = require('../preset/colors');
|
|
3
|
+
const LIGHT_CSS = `
|
|
4
|
+
:where(.jw-root) {
|
|
5
|
+
color-scheme: light;
|
|
6
|
+
--jw-line-height-base: 1.7;
|
|
7
|
+
--jw-block-spacing: 1em;
|
|
8
|
+
--jw-nested-list-gap: 0.35em;
|
|
9
|
+
--jw-quote-gap: 0.6em;
|
|
10
|
+
|
|
11
|
+
--jw-bg-color: #ffffff;
|
|
12
|
+
--jw-text-color: #222222;
|
|
13
|
+
--jw-link-color: #1d4ed8;
|
|
14
|
+
|
|
15
|
+
--jw-quote-border-color: #d0d0d0;
|
|
16
|
+
--jw-quote-border-color-2: #c5c5c5;
|
|
17
|
+
--jw-quote-border-color-3: #b8b8b8;
|
|
18
|
+
--jw-quote-background: #f8f8f8;
|
|
19
|
+
--jw-quote-text: #595959;
|
|
20
|
+
|
|
21
|
+
--jw-border-color: #cccccc;
|
|
22
|
+
--jw-border-color-subtle: #dddddd;
|
|
23
|
+
--jw-border-color-strong: #999999;
|
|
24
|
+
|
|
25
|
+
--jw-text-muted: #777777;
|
|
26
|
+
--jw-text-subtle: #666666;
|
|
27
|
+
--jw-text-strong: #555555;
|
|
28
|
+
--jw-text-faint: #999999;
|
|
29
|
+
|
|
30
|
+
--jw-surface-code: #f5f5f5;
|
|
31
|
+
--jw-surface-task: #eeeeee;
|
|
32
|
+
--jw-surface-overlay-1: rgba(0, 0, 0, 0.02);
|
|
33
|
+
--jw-surface-overlay-2: rgba(0, 0, 0, 0.05);
|
|
34
|
+
--jw-surface-overlay-3: rgba(0, 0, 0, 0.1);
|
|
35
|
+
|
|
36
|
+
--jw-highlight-marker: #FFEB3B;
|
|
37
|
+
|
|
38
|
+
--jw-task-done-bg: #333333;
|
|
39
|
+
--jw-task-done-text: #ffffff;
|
|
40
|
+
--jw-task-not-done-cross: #ffffff;
|
|
41
|
+
--jw-task-in-progress: #555555;
|
|
42
|
+
|
|
43
|
+
--jw-color-red: ${PRESET_COLORS.red};
|
|
44
|
+
--jw-color-orange: ${PRESET_COLORS.orange};
|
|
45
|
+
--jw-color-yellow: ${PRESET_COLORS.yellow};
|
|
46
|
+
--jw-color-green: ${PRESET_COLORS.green};
|
|
47
|
+
--jw-color-cyan: ${PRESET_COLORS.cyan};
|
|
48
|
+
--jw-color-blue: ${PRESET_COLORS.blue};
|
|
49
|
+
--jw-color-purple: ${PRESET_COLORS.purple};
|
|
50
|
+
--jw-color-black: ${PRESET_COLORS.black};
|
|
51
|
+
--jw-color-darkgray: ${PRESET_COLORS.darkgray};
|
|
52
|
+
--jw-color-gray: ${PRESET_COLORS.gray};
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
module.exports = LIGHT_CSS;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export let red: string;
|
|
2
|
+
export let orange: string;
|
|
3
|
+
export let yellow: string;
|
|
4
|
+
export let green: string;
|
|
5
|
+
export let cyan: string;
|
|
6
|
+
export let blue: string;
|
|
7
|
+
export let purple: string;
|
|
8
|
+
export let black: string;
|
|
9
|
+
export let darkgray: string;
|
|
10
|
+
export let gray: string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const PRESET_COLORS = {
|
|
3
|
+
red: '#B10000',
|
|
4
|
+
orange: '#FA8800',
|
|
5
|
+
yellow: '#7B5A00',
|
|
6
|
+
green: '#006200',
|
|
7
|
+
cyan: '#009FDF',
|
|
8
|
+
blue: '#003366',
|
|
9
|
+
purple: '#4B0082',
|
|
10
|
+
black: '#000000',
|
|
11
|
+
darkgray: '#333333',
|
|
12
|
+
gray: '#595959',
|
|
13
|
+
};
|
|
14
|
+
module.exports = PRESET_COLORS;
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
(() => {
|
|
3
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const ROOT_SELECTOR = '.jw-root';
|
|
7
|
+
const THEME_ATTR = 'data-jw-theme';
|
|
8
|
+
const VALID_THEMES = new Set(['light', 'dark', 'auto']);
|
|
9
|
+
function getRoots() {
|
|
10
|
+
return Array.from(document.querySelectorAll(ROOT_SELECTOR));
|
|
11
|
+
}
|
|
12
|
+
function setTheme(theme) {
|
|
13
|
+
if (!VALID_THEMES.has(theme)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const root of getRoots()) {
|
|
17
|
+
root.setAttribute(THEME_ATTR, theme);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function toggleTheme() {
|
|
21
|
+
for (const root of getRoots()) {
|
|
22
|
+
const current = root.getAttribute(THEME_ATTR);
|
|
23
|
+
const next = current === 'dark' ? 'light' : 'dark';
|
|
24
|
+
root.setAttribute(THEME_ATTR, next);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
window.JianwenTheme = Object.assign(window.JianwenTheme || {}, {
|
|
28
|
+
setTheme,
|
|
29
|
+
toggleTheme,
|
|
30
|
+
});
|
|
31
|
+
})();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type DocumentTheme = 'light' | 'dark' | 'auto';
|
|
2
|
+
export interface ThemeCssBundle {
|
|
3
|
+
baseCss: string;
|
|
4
|
+
lightCss: string;
|
|
5
|
+
darkCss: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_THEME: ThemeCssBundle;
|
|
8
|
+
export declare const DEFAULT_CSS: string;
|
|
9
|
+
export declare const PRESET_COLORS: Record<string, string>;
|