@cosense-toolbox/tailwind 0.1.0-beta.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/dist/index.cjs ADDED
@@ -0,0 +1,719 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ let tailwindcss_plugin = require("tailwindcss/plugin");
24
+ tailwindcss_plugin = __toESM(tailwindcss_plugin, 1);
25
+ //#region src/modifiers.ts
26
+ const MODIFIERS = [
27
+ {
28
+ name: "title",
29
+ target: ".title",
30
+ notation: "タイトル (1 行目)"
31
+ },
32
+ {
33
+ name: "line",
34
+ target: ".line",
35
+ notation: "各行"
36
+ },
37
+ {
38
+ name: "heading",
39
+ target: ".decoration[data-size-level]",
40
+ notation: "`[** 見出し]` などの大きな文字"
41
+ },
42
+ {
43
+ name: "strong",
44
+ target: "strong",
45
+ notation: "`[[太字]]` `[* 太字]`"
46
+ },
47
+ {
48
+ name: "em",
49
+ target: "em",
50
+ notation: "`[/ 斜体]`"
51
+ },
52
+ {
53
+ name: "s",
54
+ target: "s",
55
+ notation: "`[- 打ち消し]`"
56
+ },
57
+ {
58
+ name: "u",
59
+ target: "u",
60
+ notation: "`[_ 下線]`"
61
+ },
62
+ {
63
+ name: "link",
64
+ target: ".link",
65
+ notation: "リンクすべて (`[ページ]` `[https://…]` `[/project/ページ]`)"
66
+ },
67
+ {
68
+ name: "link-external",
69
+ target: ".link-external",
70
+ notation: "外部リンク `[https://…]`"
71
+ },
72
+ {
73
+ name: "link-project",
74
+ target: ".link-project",
75
+ notation: "別プロジェクトへのリンク `[/project/ページ]`"
76
+ },
77
+ {
78
+ name: "hashtag",
79
+ target: ".hashtag",
80
+ notation: "`#タグ`"
81
+ },
82
+ {
83
+ name: "code",
84
+ target: ".code",
85
+ notation: "`` `コード` ``"
86
+ },
87
+ {
88
+ name: "code-block",
89
+ target: ".code-block > code",
90
+ notation: "`code:ファイル名` のブロックの各行"
91
+ },
92
+ {
93
+ name: "code-filename",
94
+ target: ".code-block-start",
95
+ notation: "`code:ファイル名` のファイル名"
96
+ },
97
+ {
98
+ name: "quote",
99
+ target: ".quote",
100
+ notation: "`>` で始まる引用"
101
+ },
102
+ {
103
+ name: "table",
104
+ target: ".table",
105
+ notation: "`table:名前` の表"
106
+ },
107
+ {
108
+ name: "td",
109
+ target: ".table td",
110
+ notation: "表のセル"
111
+ },
112
+ {
113
+ name: "image",
114
+ target: ".image",
115
+ notation: "画像"
116
+ },
117
+ {
118
+ name: "icon",
119
+ target: ".icon",
120
+ notation: "`[ユーザー名.icon]`"
121
+ },
122
+ {
123
+ name: "formula",
124
+ target: ".formula",
125
+ notation: "`[$ 数式]`"
126
+ }
127
+ ];
128
+ //#endregion
129
+ //#region src/styles.generated.ts
130
+ const styles = {
131
+ "root": {
132
+ "font-family": "var(--cosense-font, \"Open Sans\", Helvetica, Arial, \"Hiragino Sans\", sans-serif)",
133
+ "font-size": "var(--cosense-font-size, 15px)",
134
+ "line-height": "var(--cosense-line-height, 1.87)",
135
+ "color": "var(--cosense-text, var(--page-text-color, #4a4a4a))",
136
+ "background": "var(--cosense-bg, var(--page-bg, #fefefe))",
137
+ "text-align": "left",
138
+ "word-wrap": "break-word"
139
+ },
140
+ "rules": [
141
+ {
142
+ "selector": {
143
+ "body": ".title",
144
+ "pseudo": ""
145
+ },
146
+ "declarations": {
147
+ "margin": "0 0 0.77em",
148
+ "font-size": "1.73em",
149
+ "font-weight": "700",
150
+ "line-height": "1.62",
151
+ "color": "var(--cosense-title, var(--line-title-color, var(--page-text-color, #4a4a4a)))"
152
+ }
153
+ },
154
+ {
155
+ "selector": {
156
+ "body": ".line",
157
+ "pseudo": ""
158
+ },
159
+ "declarations": {
160
+ "position": "relative",
161
+ "min-height": "1em",
162
+ "font-variant-ligatures": "no-common-ligatures"
163
+ }
164
+ },
165
+ {
166
+ "selector": {
167
+ "body": ".indent-mark",
168
+ "pseudo": ""
169
+ },
170
+ "declarations": {
171
+ "position": "absolute",
172
+ "left": "0",
173
+ "top": "0",
174
+ "height": "1em",
175
+ "color": "transparent"
176
+ }
177
+ },
178
+ {
179
+ "selector": {
180
+ "body": ".pad",
181
+ "pseudo": ""
182
+ },
183
+ "declarations": {
184
+ "display": "inline-block",
185
+ "width": "var(--cosense-indent, 1.5em)",
186
+ "height": "1em",
187
+ "overflow": "hidden"
188
+ }
189
+ },
190
+ {
191
+ "selector": {
192
+ "body": ".dot",
193
+ "pseudo": ""
194
+ },
195
+ "declarations": {
196
+ "position": "absolute",
197
+ "right": "0.65em",
198
+ "top": "0.7em",
199
+ "width": "6px",
200
+ "height": "6px",
201
+ "border-radius": "50%",
202
+ "background": "var(--cosense-text, var(--page-text-color, #555))"
203
+ }
204
+ },
205
+ {
206
+ "selector": {
207
+ "body": ".link",
208
+ "pseudo": ""
209
+ },
210
+ "declarations": {
211
+ "color": "var(--cosense-link, var(--page-link-color, #3d72f5))",
212
+ "text-decoration": "none",
213
+ "-webkit-tap-highlight-color": "rgba(0, 0, 0, 0.2)"
214
+ }
215
+ },
216
+ {
217
+ "selector": {
218
+ "body": ".hashtag",
219
+ "pseudo": ""
220
+ },
221
+ "declarations": {
222
+ "color": "var(--cosense-link, var(--page-link-color, #3d72f5))",
223
+ "text-decoration": "none",
224
+ "-webkit-tap-highlight-color": "rgba(0, 0, 0, 0.2)"
225
+ }
226
+ },
227
+ {
228
+ "selector": {
229
+ "body": ".code",
230
+ "pseudo": ""
231
+ },
232
+ "declarations": {
233
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
234
+ "color": "var(--cosense-code-text, var(--code-color, #342d9c))"
235
+ }
236
+ },
237
+ {
238
+ "selector": {
239
+ "body": ".code-start",
240
+ "pseudo": ""
241
+ },
242
+ "declarations": {
243
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
244
+ "color": "var(--cosense-code-text, var(--code-color, #342d9c))"
245
+ }
246
+ },
247
+ {
248
+ "selector": {
249
+ "body": ".code-body",
250
+ "pseudo": ""
251
+ },
252
+ "declarations": {
253
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
254
+ "color": "var(--cosense-code-text, var(--code-color, #342d9c))"
255
+ }
256
+ },
257
+ {
258
+ "selector": {
259
+ "body": ".monospace",
260
+ "pseudo": ""
261
+ },
262
+ "declarations": {
263
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
264
+ "color": "var(--cosense-code-text, var(--code-color, #342d9c))"
265
+ }
266
+ },
267
+ {
268
+ "selector": {
269
+ "body": ".code",
270
+ "pseudo": ""
271
+ },
272
+ "declarations": {
273
+ "padding": "0 0.2em",
274
+ "border-radius": "4px",
275
+ "font-size": "90%",
276
+ "word-wrap": "break-word",
277
+ "background": "var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))"
278
+ }
279
+ },
280
+ {
281
+ "selector": {
282
+ "body": ".monospace",
283
+ "pseudo": ""
284
+ },
285
+ "declarations": {
286
+ "padding": "0 0.2em",
287
+ "border-radius": "4px",
288
+ "font-size": "90%",
289
+ "word-wrap": "break-word",
290
+ "background": "var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))"
291
+ }
292
+ },
293
+ {
294
+ "selector": {
295
+ "body": ".code-block-start",
296
+ "pseudo": ""
297
+ },
298
+ "declarations": {
299
+ "padding": "1px 2px",
300
+ "font-size": "0.95em",
301
+ "color": "var(--cosense-badge-text, #342d9c)",
302
+ "background": "var(--cosense-badge-bg, #ffcfc6)"
303
+ }
304
+ },
305
+ {
306
+ "selector": {
307
+ "body": ".quote",
308
+ "pseudo": ""
309
+ },
310
+ "declarations": {
311
+ "display": "block",
312
+ "margin": "0",
313
+ "padding-left": "3px",
314
+ "border-left": "solid 1px #a0a0a0",
315
+ "background": "var(--cosense-quote-bg, var(--quote-bg-color, rgba(0, 0, 0, 0.05)))"
316
+ }
317
+ },
318
+ {
319
+ "selector": {
320
+ "body": ".table",
321
+ "pseudo": ""
322
+ },
323
+ "declarations": {
324
+ "margin": "0",
325
+ "border-collapse": "collapse",
326
+ "caption-side": "top"
327
+ }
328
+ },
329
+ {
330
+ "selector": {
331
+ "body": ".image",
332
+ "pseudo": ""
333
+ },
334
+ "declarations": {
335
+ "display": "inline-block",
336
+ "max-width": "100%",
337
+ "max-height": "300px",
338
+ "vertical-align": "bottom"
339
+ }
340
+ },
341
+ {
342
+ "selector": {
343
+ "body": ".formula",
344
+ "pseudo": ""
345
+ },
346
+ "declarations": {
347
+ "margin": "auto 6px",
348
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
349
+ "font-style": "italic"
350
+ }
351
+ },
352
+ {
353
+ "selector": {
354
+ "body": ".table caption",
355
+ "pseudo": ""
356
+ },
357
+ "declarations": {
358
+ "padding": "1px 2px",
359
+ "text-align": "center",
360
+ "font-size": "0.9em",
361
+ "color": "var(--cosense-badge-text, #342d9c)",
362
+ "background": "var(--cosense-badge-bg, #ffcfc6)"
363
+ }
364
+ },
365
+ {
366
+ "selector": {
367
+ "body": ".table td",
368
+ "pseudo": ""
369
+ },
370
+ "declarations": {
371
+ "padding": "0 2px 0 8px",
372
+ "white-space": "nowrap"
373
+ }
374
+ },
375
+ {
376
+ "selector": {
377
+ "body": "img.icon",
378
+ "pseudo": ""
379
+ },
380
+ "declarations": {
381
+ "display": "inline-block",
382
+ "position": "relative",
383
+ "top": "-0.3em",
384
+ "height": "1.3em",
385
+ "max-width": "100%",
386
+ "vertical-align": "baseline"
387
+ }
388
+ },
389
+ {
390
+ "selector": {
391
+ "body": ".line[data-indent=\"1\"]",
392
+ "pseudo": ""
393
+ },
394
+ "declarations": { "--cosense-depth": "1" }
395
+ },
396
+ {
397
+ "selector": {
398
+ "body": ".line[data-indent=\"2\"]",
399
+ "pseudo": ""
400
+ },
401
+ "declarations": { "--cosense-depth": "2" }
402
+ },
403
+ {
404
+ "selector": {
405
+ "body": ".line[data-indent=\"3\"]",
406
+ "pseudo": ""
407
+ },
408
+ "declarations": { "--cosense-depth": "3" }
409
+ },
410
+ {
411
+ "selector": {
412
+ "body": ".line[data-indent=\"4\"]",
413
+ "pseudo": ""
414
+ },
415
+ "declarations": { "--cosense-depth": "4" }
416
+ },
417
+ {
418
+ "selector": {
419
+ "body": ".line[data-indent=\"5\"]",
420
+ "pseudo": ""
421
+ },
422
+ "declarations": { "--cosense-depth": "5" }
423
+ },
424
+ {
425
+ "selector": {
426
+ "body": ".line[data-indent=\"6\"]",
427
+ "pseudo": ""
428
+ },
429
+ "declarations": { "--cosense-depth": "6" }
430
+ },
431
+ {
432
+ "selector": {
433
+ "body": ".line[data-indent=\"7\"]",
434
+ "pseudo": ""
435
+ },
436
+ "declarations": { "--cosense-depth": "7" }
437
+ },
438
+ {
439
+ "selector": {
440
+ "body": ".line[data-indent=\"8\"]",
441
+ "pseudo": ""
442
+ },
443
+ "declarations": { "--cosense-depth": "8" }
444
+ },
445
+ {
446
+ "selector": {
447
+ "body": ".line[data-indent=\"9\"]",
448
+ "pseudo": ""
449
+ },
450
+ "declarations": { "--cosense-depth": "9" }
451
+ },
452
+ {
453
+ "selector": {
454
+ "body": ".line[data-indent=\"10\"]",
455
+ "pseudo": ""
456
+ },
457
+ "declarations": { "--cosense-depth": "10" }
458
+ },
459
+ {
460
+ "selector": {
461
+ "body": ".line[data-indent]",
462
+ "pseudo": ""
463
+ },
464
+ "declarations": { "padding-left": "calc(var(--cosense-indent, 1.5em) * var(--cosense-depth, 0))" }
465
+ },
466
+ {
467
+ "selector": {
468
+ "body": ".link:hover",
469
+ "pseudo": ""
470
+ },
471
+ "declarations": { "color": "var(--cosense-link-hover, var(--page-link-hover-color, #0d4ff3))" }
472
+ },
473
+ {
474
+ "selector": {
475
+ "body": ".hashtag:hover",
476
+ "pseudo": ""
477
+ },
478
+ "declarations": { "color": "var(--cosense-link-hover, var(--page-link-hover-color, #0d4ff3))" }
479
+ },
480
+ {
481
+ "selector": {
482
+ "body": ".image[data-large]",
483
+ "pseudo": ""
484
+ },
485
+ "declarations": {
486
+ "margin": "3px 0",
487
+ "max-width": "95%",
488
+ "max-height": "none"
489
+ }
490
+ },
491
+ {
492
+ "selector": {
493
+ "body": ".decoration[data-size-level=\"1\"]",
494
+ "pseudo": ""
495
+ },
496
+ "declarations": { "font-size": "1.2em" }
497
+ },
498
+ {
499
+ "selector": {
500
+ "body": ".decoration[data-size-level=\"2\"]",
501
+ "pseudo": ""
502
+ },
503
+ "declarations": { "font-size": "1.44em" }
504
+ },
505
+ {
506
+ "selector": {
507
+ "body": ".decoration[data-size-level=\"3\"]",
508
+ "pseudo": ""
509
+ },
510
+ "declarations": { "font-size": "1.73em" }
511
+ },
512
+ {
513
+ "selector": {
514
+ "body": ".decoration[data-size-level=\"4\"]",
515
+ "pseudo": ""
516
+ },
517
+ "declarations": { "font-size": "2.07em" }
518
+ },
519
+ {
520
+ "selector": {
521
+ "body": ".decoration[data-size-level]",
522
+ "pseudo": ""
523
+ },
524
+ "declarations": {
525
+ "display": "inline-block",
526
+ "line-height": "1.6"
527
+ }
528
+ },
529
+ {
530
+ "selector": {
531
+ "body": ".line[data-indent]",
532
+ "pseudo": "::before"
533
+ },
534
+ "declarations": {
535
+ "content": "\"\"",
536
+ "position": "absolute",
537
+ "top": "0.7em",
538
+ "left": "calc(var(--cosense-indent, 1.5em) * var(--cosense-depth, 0) - 1.05em)",
539
+ "width": "6px",
540
+ "height": "6px",
541
+ "border-radius": "50%",
542
+ "background": "var(--cosense-text, var(--page-text-color, #555))"
543
+ }
544
+ },
545
+ {
546
+ "selector": {
547
+ "body": ".line:has(> .indent-mark)",
548
+ "pseudo": "::before"
549
+ },
550
+ "declarations": { "content": "none" }
551
+ },
552
+ {
553
+ "selector": {
554
+ "body": ".line.code-block > code",
555
+ "pseudo": ""
556
+ },
557
+ "declarations": {
558
+ "display": "block",
559
+ "min-height": "1.7em",
560
+ "line-height": "1.7em",
561
+ "tab-size": "4",
562
+ "background": "var(--cosense-code-bg, var(--code-bg, rgba(0, 0, 0, 0.04)))"
563
+ }
564
+ },
565
+ {
566
+ "selector": {
567
+ "body": ".table td:nth-child(odd)",
568
+ "pseudo": ""
569
+ },
570
+ "declarations": { "background": "rgba(0, 0, 0, 0.04)" }
571
+ },
572
+ {
573
+ "selector": {
574
+ "body": ".table td:nth-child(even)",
575
+ "pseudo": ""
576
+ },
577
+ "declarations": { "background": "rgba(0, 0, 0, 0.06)" }
578
+ },
579
+ {
580
+ "selector": {
581
+ "body": ".line.code-block > .code-body",
582
+ "pseudo": ""
583
+ },
584
+ "declarations": {
585
+ "margin-left": "calc(var(--cosense-indent, 1.5em) * -1)",
586
+ "padding-left": "var(--cosense-indent, 1.5em)",
587
+ "white-space": "pre-wrap"
588
+ }
589
+ },
590
+ {
591
+ "selector": {
592
+ "body": ".line.code-block[data-line-digits=\"1\"]",
593
+ "pseudo": ""
594
+ },
595
+ "declarations": { "--cosense-line-digits": "1" }
596
+ },
597
+ {
598
+ "selector": {
599
+ "body": ".line.code-block[data-line-digits=\"2\"]",
600
+ "pseudo": ""
601
+ },
602
+ "declarations": { "--cosense-line-digits": "2" }
603
+ },
604
+ {
605
+ "selector": {
606
+ "body": ".line.code-block[data-line-digits=\"3\"]",
607
+ "pseudo": ""
608
+ },
609
+ "declarations": { "--cosense-line-digits": "3" }
610
+ },
611
+ {
612
+ "selector": {
613
+ "body": ".line.code-block[data-line-digits=\"4\"]",
614
+ "pseudo": ""
615
+ },
616
+ "declarations": { "--cosense-line-digits": "4" }
617
+ },
618
+ {
619
+ "selector": {
620
+ "body": ".line.code-block[data-line-digits=\"5\"]",
621
+ "pseudo": ""
622
+ },
623
+ "declarations": { "--cosense-line-digits": "5" }
624
+ },
625
+ {
626
+ "selector": {
627
+ "body": ".line.code-block:not(:has(> .code-start))",
628
+ "pseudo": "::before"
629
+ },
630
+ "declarations": { "content": "none" }
631
+ },
632
+ {
633
+ "selector": {
634
+ "body": ".line.code-block[data-line]",
635
+ "pseudo": "::before"
636
+ },
637
+ "declarations": {
638
+ "content": "attr(data-line)",
639
+ "top": "0",
640
+ "left": "calc(var(--cosense-indent, 1.5em) * (var(--cosense-depth, 1) - 1))",
641
+ "width": "calc(0.6em + var(--cosense-line-digits, 5) * 1ch)",
642
+ "height": "auto",
643
+ "display": "flex",
644
+ "justify-content": "flex-end",
645
+ "white-space": "nowrap",
646
+ "border-radius": "0",
647
+ "background": "none",
648
+ "font-family": "var(--cosense-code-font, ui-monospace, SFMono-Regular, Menlo, monospace)",
649
+ "line-height": "1.7em",
650
+ "color": "var(--cosense-line-number, rgba(0, 0, 0, 0.35))"
651
+ }
652
+ },
653
+ {
654
+ "selector": {
655
+ "body": ".line.code-block[data-line] > .code-body",
656
+ "pseudo": ""
657
+ },
658
+ "declarations": { "padding-left": "calc(0.6em + (var(--cosense-line-digits, 5) + 1) * 1ch)" }
659
+ }
660
+ ]
661
+ };
662
+ //#endregion
663
+ //#region src/index.ts
664
+ /**
665
+ * `@cosense-toolbox/tailwind` — `class="cosense"` を付けた要素の中に、Cosense 記法の既定の見た目を当てる。
666
+ * typography の `prose` と同じ使い方をする。
667
+ *
668
+ * ```css
669
+ * @import "tailwindcss";
670
+ * @plugin "@cosense-toolbox/tailwind";
671
+ * ```
672
+ *
673
+ * 当てるスタイルは `@cosense-toolbox/style` の style.css と同じもの。`cosense-link:underline` のような
674
+ * modifier で、記事の中の特定の記法にだけ utility を当てられる。
675
+ */
676
+ /** 生成したデータは readonly なので、Tailwind の可変の型に合わせる (中身は書き換えない)。 */
677
+ const mutable = (declarations) => declarations;
678
+ /**
679
+ * `not-{className}` を付けた要素とその中を除く条件。`:where()` の中なので詳細度を増やさない。
680
+ */
681
+ const outside = (className) => `:not(:where([class~="not-${className}"],[class~="not-${className}"] *))`;
682
+ /**
683
+ * 1 つのルールのセレクタ。本文を `:where()` で包み、どのルールも `.cosense` と同じ詳細度にする。
684
+ * 除く条件は擬似要素より前に付ける。
685
+ *
686
+ * 詳細度を揃えるので、ルールどうしの勝ち負けは並び順だけで決まる。生成したデータは元の詳細度の
687
+ * 低い順に並んでいるので、style.css と同じ勝ち負けになる。後ろに出る `cosense-link:` などの
688
+ * modifier や、同じ詳細度の utility が既定のスタイルに勝てるのは、このため。
689
+ */
690
+ const selectorOf = ({ selector }, className) => `& :where(${selector.body})${outside(className)}${selector.pseudo}`;
691
+ /**
692
+ * ルールごとに別のオブジェクトにする。1 つのオブジェクトのキーにすると、同じセレクタのルールが
693
+ * 後のもので上書きされてしまうため。Tailwind は並べた順のまま `.cosense` の中に出す。
694
+ */
695
+ const componentsOf = (className) => [{ [`.${className}`]: mutable(styles.root) }, ...styles.rules.map((rule) => ({ [`.${className}`]: { [selectorOf(rule, className)]: mutable(rule.declarations) } }))];
696
+ /** `cosense-link:` なら `.cosense-link\:underline :is(…)` のように、中の対象だけに当てる。 */
697
+ const modifierOf = (modifier, className) => `& :is(:where(${modifier.target})${outside(className)})`;
698
+ /** class 名に使えない記号を、CSS のセレクタ用にエスケープする。 */
699
+ const escapeClassChar = (char) => /[A-Za-z0-9_-]/.test(char) ? char : `\\${char}`;
700
+ /**
701
+ * `cosense-deco-[|]:` の `[...]` に書いた記号の装飾。`toHtml` は装飾を
702
+ * `<span class="decoration deco-|">` のように記号ごとの class で出すので、それを選ぶ。
703
+ * 記号を並べると (`[-/]`)、それらをすべて持つ装飾に当たる。
704
+ *
705
+ * Tailwind は `[...]` の中の `_` を空白に変える。下線の記号 `_` は `[\_]` と書く (Tailwind の決まり)。
706
+ */
707
+ const decorationOf = (markers, className) => {
708
+ return `& :is(:where(.decoration${[...new Set(markers)].map((marker) => `.deco-${escapeClassChar(marker)}`).join("")})${outside(className)})`;
709
+ };
710
+ const cosense = tailwindcss_plugin.default.withOptions((options) => ({ addComponents, addVariant, matchVariant }) => {
711
+ const className = options?.className ?? "cosense";
712
+ addComponents(componentsOf(className));
713
+ for (const modifier of MODIFIERS) addVariant(`${className}-${modifier.name}`, modifierOf(modifier, className));
714
+ matchVariant(`${className}-deco`, (markers) => decorationOf(markers, className));
715
+ });
716
+ //#endregion
717
+ module.exports = cosense;
718
+
719
+ //# sourceMappingURL=index.cjs.map