@sakura-ui/sakura-ui 0.5.1 → 0.5.3
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/package.json +3 -3
- package/packages/core/package.json +1 -1
- package/packages/core/src/components/Card.tsx +52 -56
- package/packages/core/src/components/Code.tsx +6 -6
- package/packages/core/src/components/Faq.tsx +30 -26
- package/packages/core/src/components/Heading.tsx +50 -48
- package/packages/core/src/components/Icon.tsx +34 -34
- package/packages/core/src/components/Link.tsx +13 -12
- package/packages/core/src/components/LinkCard.tsx +87 -76
- package/packages/core/src/components/List.tsx +20 -13
- package/packages/core/src/components/OverflowContainer.tsx +9 -9
- package/packages/core/src/components/Pre.tsx +9 -9
- package/packages/core/src/components/Table.tsx +29 -24
- package/packages/core/src/components/index.ts +1 -0
- package/packages/core/src/components/styles.ts +42 -0
- package/packages/core/src/index.ts +2 -0
- package/packages/forms/.turbo/turbo-build.log +2 -2
- package/packages/helper/.turbo/turbo-build.log +2 -2
- package/packages/helper/node_modules/.bin/vitest +2 -2
- package/packages/markdown/.turbo/turbo-build.log +4 -4
- package/packages/markdown/README.md +240 -4
- package/packages/markdown/dist/index.cjs.js +71 -137
- package/packages/markdown/dist/index.es.js +2624 -16739
- package/packages/markdown/dist/types/components/Markdown.d.ts +15 -10
- package/packages/markdown/dist/types/components/Markdown.d.ts.map +1 -1
- package/packages/markdown/dist/types/components/index.d.ts +1 -1
- package/packages/markdown/dist/types/components/index.d.ts.map +1 -1
- package/packages/markdown/dist/types/decorate.d.ts +24 -0
- package/packages/markdown/dist/types/decorate.d.ts.map +1 -0
- package/packages/markdown/dist/types/index.d.ts +3 -1
- package/packages/markdown/dist/types/index.d.ts.map +1 -1
- package/packages/markdown/dist/types/marked/attributes.d.ts +31 -0
- package/packages/markdown/dist/types/marked/attributes.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/card.d.ts +3 -0
- package/packages/markdown/dist/types/marked/directives/card.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/context.d.ts +36 -0
- package/packages/markdown/dist/types/marked/directives/context.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/faq.d.ts +11 -0
- package/packages/markdown/dist/types/marked/directives/faq.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/grid.d.ts +9 -0
- package/packages/markdown/dist/types/marked/directives/grid.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/index.d.ts +8 -0
- package/packages/markdown/dist/types/marked/directives/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/linkButton.d.ts +6 -0
- package/packages/markdown/dist/types/marked/directives/linkButton.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/directives/youtube.d.ts +3 -0
- package/packages/markdown/dist/types/marked/directives/youtube.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/html.d.ts +15 -0
- package/packages/markdown/dist/types/marked/html.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/index.d.ts +13 -0
- package/packages/markdown/dist/types/marked/index.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/registry.d.ts +8 -0
- package/packages/markdown/dist/types/marked/registry.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/renderer.d.ts +16 -0
- package/packages/markdown/dist/types/marked/renderer.d.ts.map +1 -0
- package/packages/markdown/dist/types/marked/tokenizer.d.ts +40 -0
- package/packages/markdown/dist/types/marked/tokenizer.d.ts.map +1 -0
- package/packages/markdown/dist/types/render.d.ts +22 -0
- package/packages/markdown/dist/types/render.d.ts.map +1 -0
- package/packages/markdown/dist/types/sanitize.d.ts +11 -0
- package/packages/markdown/dist/types/sanitize.d.ts.map +1 -0
- package/packages/markdown/node_modules/.bin/marked +55 -0
- package/packages/markdown/package.json +6 -19
- package/packages/markdown/src/components/Markdown.tsx +49 -343
- package/packages/markdown/src/components/index.ts +1 -1
- package/packages/markdown/src/decorate.ts +164 -0
- package/packages/markdown/src/index.ts +3 -1
- package/packages/markdown/src/marked/attributes.ts +88 -0
- package/packages/markdown/src/marked/directives/card.ts +77 -0
- package/packages/markdown/src/marked/directives/context.ts +39 -0
- package/packages/markdown/src/marked/directives/faq.ts +29 -0
- package/packages/markdown/src/marked/directives/grid.ts +50 -0
- package/packages/markdown/src/marked/directives/index.ts +29 -0
- package/packages/markdown/src/marked/directives/linkButton.ts +20 -0
- package/packages/markdown/src/marked/directives/youtube.ts +46 -0
- package/packages/markdown/src/marked/html.ts +55 -0
- package/packages/markdown/src/marked/index.ts +45 -0
- package/packages/markdown/src/marked/registry.ts +34 -0
- package/packages/markdown/src/marked/renderer.ts +52 -0
- package/packages/markdown/src/marked/tokenizer.ts +175 -0
- package/packages/markdown/src/render.ts +55 -0
- package/packages/markdown/src/sanitize.ts +194 -0
- package/packages/markdown/tests/Markdown.test.tsx +122 -0
- package/packages/markdown/tests/__snapshots__/Markdown.test.tsx.snap +446 -0
- package/packages/markdown/tests/anchors.test.ts +108 -0
- package/packages/markdown/tests/fixtures.ts +100 -0
- package/packages/markdown/tests/sanitize.test.ts +168 -0
- package/packages/markdown/tests/server.test.tsx +51 -0
- package/packages/markdown/tests/vitest.setup.ts +4 -0
- package/packages/markdown/tsconfig.test.json +11 -0
- package/packages/markdown/vite.config.ts +5 -1
- package/packages/tailwind-theme-plugin/.turbo/turbo-build.log +1 -1
- package/packages/markdown/dist/types/plugins/attr.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/attr.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/card.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/card.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/cell.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/cell.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/faq.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/faq.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/grid.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/grid.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/headings.d.ts +0 -11
- package/packages/markdown/dist/types/plugins/headings.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/helper.d.ts +0 -9
- package/packages/markdown/dist/types/plugins/helper.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/index.d.ts +0 -9
- package/packages/markdown/dist/types/plugins/index.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/linkButton.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/linkButton.d.ts.map +0 -1
- package/packages/markdown/dist/types/plugins/youtube.d.ts +0 -3
- package/packages/markdown/dist/types/plugins/youtube.d.ts.map +0 -1
- package/packages/markdown/src/plugins/attr.ts +0 -19
- package/packages/markdown/src/plugins/card.ts +0 -71
- package/packages/markdown/src/plugins/cell.ts +0 -47
- package/packages/markdown/src/plugins/faq.ts +0 -40
- package/packages/markdown/src/plugins/grid.ts +0 -54
- package/packages/markdown/src/plugins/headings.ts +0 -38
- package/packages/markdown/src/plugins/helper.ts +0 -27
- package/packages/markdown/src/plugins/index.ts +0 -8
- package/packages/markdown/src/plugins/linkButton.ts +0 -26
- package/packages/markdown/src/plugins/youtube.ts +0 -49
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Markdown > directives > should render card 1`] = `
|
|
4
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden" data-sakura="card"><img class="object-cover mb-2 w-full aspect-[352/226]" src="/a.png" alt="図" data-sakura="card-img">
|
|
5
|
+
<h3 class="m-0 text-base leading-[2rem] font-medium first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-title" id="タイトル">タイトル</h3>
|
|
6
|
+
<div class="text-base-sm leading-[1.85rem] first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-description">説明</div>
|
|
7
|
+
</div>
|
|
8
|
+
</div></div>"
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports[`Markdown > directives > should render cell 1`] = `
|
|
12
|
+
"<div class="py-8 flex flex-col gap-8"><div><div data-sakura="cell"><img class="mb-4" src="/a.png" alt="図" data-sakura="cell-img">
|
|
13
|
+
<p>本文</p>
|
|
14
|
+
</div>
|
|
15
|
+
</div></div>"
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
exports[`Markdown > directives > should render faq 1`] = `
|
|
19
|
+
"<div class="py-8 flex flex-col gap-8"><div><dl class="flex flex-col gap-8" data-sakura="faq"><dt class="flex flex-row gap-8 mt-8 text-h-med-m sm:text-h-med" data-sakura="faq-q"><span aria-hidden="true">Q</span><span>質問は?</span></dt>
|
|
20
|
+
<dd class="flex flex-row items-start gap-8" data-sakura="faq-a"><span class="text-h-med-m sm:text-h-med !leading-none" aria-hidden="true">A</span><span>回答です。</span></dd>
|
|
21
|
+
<dt class="flex flex-row gap-8 mt-8 text-h-med-m sm:text-h-med" data-sakura="faq-q"><span aria-hidden="true">Q</span><span>二つ目の質問は?</span></dt>
|
|
22
|
+
<dd class="flex flex-row items-start gap-8" data-sakura="faq-a"><span class="text-h-med-m sm:text-h-med !leading-none" aria-hidden="true">A</span><span>二つ目の回答。</span></dd>
|
|
23
|
+
</dl>
|
|
24
|
+
</div></div>"
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`Markdown > directives > should render grid 1`] = `
|
|
28
|
+
"<div class="py-8 flex flex-col gap-8"><div><ul class="flex flex-col md:grid md:grid-cols-3 gap-8" data-sakura="grid-cols-3"><li class="sm:grid"><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden" data-sakura="card"><h3 class="m-0 text-base leading-[2rem] font-medium first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-title" id="1つ目">1つ目</h3>
|
|
29
|
+
</div></li>
|
|
30
|
+
<li class="sm:grid"><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden" data-sakura="card"><h3 class="m-0 text-base leading-[2rem] font-medium first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-title" id="2つ目">2つ目</h3>
|
|
31
|
+
</div></li>
|
|
32
|
+
</ul>
|
|
33
|
+
</div></div>"
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`Markdown > directives > should render gridMixed 1`] = `
|
|
37
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="flex flex-col md:grid md:grid-cols-2 gap-8" data-sakura="grid-cols-2"><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden" data-sakura="card"><h3 class="m-0 text-base leading-[2rem] font-medium first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-title" id="1つ目">1つ目</h3>
|
|
38
|
+
</div>
|
|
39
|
+
<div data-sakura="cell"><p>本文</p>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</div></div>"
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Markdown > directives > should render gridOfCells 1`] = `
|
|
46
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="flex flex-col md:grid md:grid-cols-2 gap-8" data-sakura="grid-cols-2"><div data-sakura="cell"><p><img src="/a.png" alt="alt"><br>本文1</p>
|
|
47
|
+
</div>
|
|
48
|
+
<div data-sakura="cell"><p>本文2</p>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div></div>"
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
exports[`Markdown > directives > should render linkButton 1`] = `
|
|
55
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>ご案内です。<a class="inline-block text-button text-center cursor-pointer select-none touch-manipulation whitespace-nowrap outline-offset-2 border border-solid border-blue-900 hover:border-blue-1000 active:border-blue-1200 disabled:border-solid-gray-500 disabled:cursor-not-allowed text-blue-900 hover:text-blue-1000 active:text-blue-1200 bg-transparent hover:bg-blue-200 active:bg-blue-300 disabled:bg-transparent disabled:text-solid-gray-500 hover:underline hover:underline-offset-[calc(3/16*1rem)] focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:rounded-sm p-4 text-button leading-snug rounded-lg" href="/services" data-sakura="link-button">サービス一覧</a> をどうぞ。</p>
|
|
56
|
+
</div></div>"
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
exports[`Markdown > directives > should render linkCard 1`] = `
|
|
60
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden relative z-0 group hover:outline hover:outline-2 hover:outline-black hover:bg-solid-gray-50 has-[a:focus-visible]:outline has-[a:focus-visible]:outline-4 has-[a:focus-visible]:outline-black has-[a:focus-visible]:outline-offset-[calc(2/16*1rem)] has-[a:focus-visible]:ring-[calc(2/16*1rem)] has-[a:focus-visible]:ring-yellow-300" data-sakura="card"><h3 class="m-0 text-base leading-[2rem] font-medium first:pt-4 pt-2 last:pb-4 px-6 decoration-blue-900 underline underline-offset-[calc(3/16*1rem)] group-hover:text-blue-900 group-hover:decoration-[calc(3/16*1rem)]" data-sakura="card-title" id="タイトル"><a class="after:content-[''] after:absolute after:inset-0 after:z-10 focus-visible:outline-none" href="/x" data-sakura="card-title">タイトル</a></h3>
|
|
61
|
+
<div class="text-base-sm leading-[1.85rem] first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-description">説明</div>
|
|
62
|
+
<div class="sticky top-full text-base-sm leading-[1.85rem] first:pt-4 pt-2 last:pb-4 px-6 flex justify-between items-center" data-sakura="card-footer"><span>2026年8月</span><span class="inline-flex items-center justify-center w-6 h-6 text-blue-1000 border border-blue-1000 rounded-full group-hover:bg-blue-1000 group-hover:text-white"><span aria-hidden="true" class="!text-[16px] font-icon font-light inline-block leading-none align-middle whitespace-nowrap">arrow_forward</span><span class="sr-only"></span></span></div>
|
|
63
|
+
</div>
|
|
64
|
+
</div></div>"
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
exports[`Markdown > directives > should render linkCardWithoutTitle 1`] = `
|
|
68
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="border border-solid border-solid-gray-500 rounded-2xl sm:rounded-3xl text-solid-gray-900 overflow-hidden" data-sakura="card"><div class="text-base-sm leading-[1.85rem] first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-description">説明</div>
|
|
69
|
+
<div class="sticky top-full text-base-sm leading-[1.85rem] first:pt-4 pt-2 last:pb-4 px-6" data-sakura="card-footer">2026年8月</div>
|
|
70
|
+
</div>
|
|
71
|
+
</div></div>"
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
exports[`Markdown > directives > should render youtube 1`] = `
|
|
75
|
+
"<div class="py-8 flex flex-col gap-8"><div><iframe title="動画タイトル" src="https://www.youtube-nocookie.com/embed/yXdbvBzxeb8" class="aspect-video w-full max-w-[470px]" style="width:560px;" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy" data-sakura="youtube"></iframe>
|
|
76
|
+
</div></div>"
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
exports[`Markdown > heading shift > should move the headings down by the given amount 1`] = `
|
|
80
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="見出し1" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">見出し1</h2>
|
|
81
|
+
<h3 id="見出し2" class="text-h-sm-m sm:text-h-sm pt-[4rem] sm:pt-[4.5rem]">見出し2</h3>
|
|
82
|
+
</div></div>"
|
|
83
|
+
`;
|
|
84
|
+
|
|
85
|
+
exports[`Markdown > headings > should render duplicated 1`] = `
|
|
86
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="概要" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">概要</h2>
|
|
87
|
+
<h2 id="概要-1" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">概要</h2>
|
|
88
|
+
<h2 id="概要-2" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">概要</h2>
|
|
89
|
+
</div></div>"
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
exports[`Markdown > headings > should render japanese 1`] = `
|
|
93
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="概要" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">概要</h2>
|
|
94
|
+
<h2 id="はじめに概要" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">はじめに(概要)</h2>
|
|
95
|
+
<h2 id="ab-テスト" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">A/B テスト</h2>
|
|
96
|
+
<h2 id="サービスアプリ" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">サービス・アプリ</h2>
|
|
97
|
+
</div></div>"
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
exports[`Markdown > headings > should render withCode 1`] = `
|
|
101
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="code-を含む見出し" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]"><code class="bg-solid-gray-50 font-mono">code</code> を含む見出し</h2>
|
|
102
|
+
</div></div>"
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
exports[`Markdown > headings > should render withImage 1`] = `
|
|
106
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="-会社概要" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]"><img src="/a.png" alt="ロゴ"> 会社概要</h2>
|
|
107
|
+
</div></div>"
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
exports[`Markdown > headings > should render withInlineHtml 1`] = `
|
|
111
|
+
"<div class="py-8 flex flex-col gap-8"><div><h2 id="太字-タイトル" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]"><b>太字</b> タイトル</h2>
|
|
112
|
+
</div></div>"
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
exports[`Markdown > malformed html > should recover from closingBr 1`] = `
|
|
116
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>一行目<br>二行目<br>三行目<br>四行目</p>
|
|
117
|
+
</div></div>"
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
exports[`Markdown > malformed html > should recover from crossedNesting 1`] = `
|
|
121
|
+
"<div class="py-8 flex flex-col gap-8"><div><ul class="list-disc [&_&]:list-circle [&_&_&]:list-square pl-8">
|
|
122
|
+
<details>
|
|
123
|
+
<summary>まとめ</summary>
|
|
124
|
+
中身
|
|
125
|
+
</details>
|
|
126
|
+
</ul></div></div>"
|
|
127
|
+
`;
|
|
128
|
+
|
|
129
|
+
exports[`Markdown > malformed html > should recover from mistypedClose 1`] = `"<div class="py-8 flex flex-col gap-8"><div><div class="w-full overflow-x-auto whitespace-nowrap print:overflow-visible print:whitespace-normal" data-sakura-table-container="true"><table class="border border-collapse border-solid-gray-420"><tbody><tr class="border border-collapse border-solid-gray-420"><td class="p-2 text-label border border-collapse border-solid-gray-420">値</td></tr></tbody></table></div></div></div>"`;
|
|
130
|
+
|
|
131
|
+
exports[`Markdown > malformed html > should recover from unclosedCell 1`] = `"<div class="py-8 flex flex-col gap-8"><div><div class="w-full overflow-x-auto whitespace-nowrap print:overflow-visible print:whitespace-normal" data-sakura-table-container="true"><table class="border border-collapse border-solid-gray-420"><tbody><tr class="border border-collapse border-solid-gray-420"><td class="p-2 text-label border border-collapse border-solid-gray-420">閉じ忘れ</td></tr><tr class="border border-collapse border-solid-gray-420"><td class="p-2 text-label border border-collapse border-solid-gray-420">次の行</td></tr></tbody></table></div></div></div>"`;
|
|
132
|
+
|
|
133
|
+
exports[`Markdown > plain markdown > should render blockquote 1`] = `
|
|
134
|
+
"<div class="py-8 flex flex-col gap-8"><div><blockquote>
|
|
135
|
+
<p>引用文<br>続き</p>
|
|
136
|
+
</blockquote>
|
|
137
|
+
</div></div>"
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
exports[`Markdown > plain markdown > should render cjkSoftBreak 1`] = `
|
|
141
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>東京都<br>港区</p>
|
|
142
|
+
</div></div>"
|
|
143
|
+
`;
|
|
144
|
+
|
|
145
|
+
exports[`Markdown > plain markdown > should render codeFence 1`] = `
|
|
146
|
+
"<div class="py-8 flex flex-col gap-8"><div><pre class="p-4 bg-solid-gray-50 rounded-lg whitespace-pre-wrap overflow-y-scroll"><code class="language-sh bg-solid-gray-50 font-mono">echo "hello"
|
|
147
|
+
</code></pre>
|
|
148
|
+
<pre class="p-4 bg-solid-gray-50 rounded-lg whitespace-pre-wrap overflow-y-scroll"><code class="bg-solid-gray-50 font-mono">言語指定なし
|
|
149
|
+
</code></pre>
|
|
150
|
+
</div></div>"
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
exports[`Markdown > plain markdown > should render footnote 1`] = `
|
|
154
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>本文<a href="%E8%84%9A%E6%B3%A8%E3%81%AE%E4%B8%AD%E8%BA%AB" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">^1</a></p>
|
|
155
|
+
</div></div>"
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
exports[`Markdown > plain markdown > should render gfmTable 1`] = `
|
|
159
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="w-full overflow-x-auto whitespace-nowrap print:overflow-visible print:whitespace-normal" data-sakura-table-container="true"><table class="border border-collapse border-solid-gray-420">
|
|
160
|
+
<thead>
|
|
161
|
+
<tr class="border border-collapse border-solid-gray-420">
|
|
162
|
+
<th class="p-2 bg-[#f8f8fb] text-label text-left border border-collapse border-solid-gray-420">見出し</th>
|
|
163
|
+
<th class="p-2 bg-[#f8f8fb] text-label text-left border border-collapse border-solid-gray-420">値</th>
|
|
164
|
+
</tr>
|
|
165
|
+
</thead>
|
|
166
|
+
<tbody><tr class="border border-collapse border-solid-gray-420">
|
|
167
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">あ</td>
|
|
168
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">1</td>
|
|
169
|
+
</tr>
|
|
170
|
+
<tr class="border border-collapse border-solid-gray-420">
|
|
171
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">い</td>
|
|
172
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">2</td>
|
|
173
|
+
</tr>
|
|
174
|
+
</tbody></table></div>
|
|
175
|
+
</div></div>"
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
exports[`Markdown > plain markdown > should render headings 1`] = `
|
|
179
|
+
"<div class="py-8 flex flex-col gap-8"><div><h1 id="見出し1" class="text-h-lg-m sm:text-h-lg pt-[2rem] sm:pt-[6.5rem]">見出し1</h1>
|
|
180
|
+
<h2 id="見出し-2" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">見出し 2</h2>
|
|
181
|
+
<h3 id="見出し3" class="text-h-sm-m sm:text-h-sm pt-[4rem] sm:pt-[4.5rem]">見出し・3</h3>
|
|
182
|
+
<h4 id="はじめに概要" class="text-h-xs-m sm:text-h-xs pt-[3.5rem] sm:pt-[4.5rem]">はじめに(概要)</h4>
|
|
183
|
+
</div></div>"
|
|
184
|
+
`;
|
|
185
|
+
|
|
186
|
+
exports[`Markdown > plain markdown > should render image 1`] = `
|
|
187
|
+
"<div class="py-8 flex flex-col gap-8"><div><p><img src="/images/a.png" alt="代替テキスト"></p>
|
|
188
|
+
</div></div>"
|
|
189
|
+
`;
|
|
190
|
+
|
|
191
|
+
exports[`Markdown > plain markdown > should render links 1`] = `
|
|
192
|
+
"<div class="py-8 flex flex-col gap-8"><div><p><a href="/foo" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">内部</a> と <a href="https://example.com" target="_blank" rel="noopener noreferrer" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">外部<span aria-hidden="true" data-sakura-new-tab="true" class="!text-[16px] font-icon font-light inline-block leading-none align-middle whitespace-nowrap ml-0.5">open_in_new</span><span class="sr-only">Opens in new tab</span></a> と <a href="https://example.com/bare" target="_blank" rel="noopener noreferrer" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">https://example.com/bare<span aria-hidden="true" data-sakura-new-tab="true" class="!text-[16px] font-icon font-light inline-block leading-none align-middle whitespace-nowrap ml-0.5">open_in_new</span><span class="sr-only">Opens in new tab</span></a></p>
|
|
193
|
+
</div></div>"
|
|
194
|
+
`;
|
|
195
|
+
|
|
196
|
+
exports[`Markdown > plain markdown > should render list 1`] = `
|
|
197
|
+
"<div class="py-8 flex flex-col gap-8"><div><ul class="list-disc [&_&]:list-circle [&_&_&]:list-square pl-8">
|
|
198
|
+
<li>項目1</li>
|
|
199
|
+
<li>項目2<ul class="list-disc [&_&]:list-circle [&_&_&]:list-square pl-8">
|
|
200
|
+
<li>入れ子<ul class="list-disc [&_&]:list-circle [&_&_&]:list-square pl-8">
|
|
201
|
+
<li>さらに</li>
|
|
202
|
+
</ul>
|
|
203
|
+
</li>
|
|
204
|
+
</ul>
|
|
205
|
+
</li>
|
|
206
|
+
</ul>
|
|
207
|
+
<ol class="list-decimal [&_&]:list-lower-latin pl-8">
|
|
208
|
+
<li>one</li>
|
|
209
|
+
<li>two</li>
|
|
210
|
+
</ol>
|
|
211
|
+
</div></div>"
|
|
212
|
+
`;
|
|
213
|
+
|
|
214
|
+
exports[`Markdown > plain markdown > should render paragraph 1`] = `
|
|
215
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>段落です。<strong>強調</strong> と <em>斜体</em> と <code class="bg-solid-gray-50 font-mono">コード</code> と <del>取り消し</del>。</p>
|
|
216
|
+
</div></div>"
|
|
217
|
+
`;
|
|
218
|
+
|
|
219
|
+
exports[`Markdown > plain markdown > should render rule 1`] = `
|
|
220
|
+
"<div class="py-8 flex flex-col gap-8"><div><hr>
|
|
221
|
+
</div></div>"
|
|
222
|
+
`;
|
|
223
|
+
|
|
224
|
+
exports[`Markdown > raw html > should render details 1`] = `
|
|
225
|
+
"<div class="py-8 flex flex-col gap-8"><div><details>
|
|
226
|
+
<summary>詳細はこちら</summary><ul class="list-disc [&_&]:list-circle [&_&_&]:list-square pl-8">
|
|
227
|
+
<li>リスト項目</li>
|
|
228
|
+
</ul>
|
|
229
|
+
<div class="w-full overflow-x-auto whitespace-nowrap print:overflow-visible print:whitespace-normal" data-sakura-table-container="true"><table class="border border-collapse border-solid-gray-420">
|
|
230
|
+
<thead>
|
|
231
|
+
<tr class="border border-collapse border-solid-gray-420">
|
|
232
|
+
<th class="p-2 bg-[#f8f8fb] text-label text-left border border-collapse border-solid-gray-420">表</th>
|
|
233
|
+
<th class="p-2 bg-[#f8f8fb] text-label text-left border border-collapse border-solid-gray-420">見出し</th>
|
|
234
|
+
</tr>
|
|
235
|
+
</thead>
|
|
236
|
+
<tbody><tr class="border border-collapse border-solid-gray-420">
|
|
237
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">a</td>
|
|
238
|
+
<td class="p-2 text-label border border-collapse border-solid-gray-420">b</td>
|
|
239
|
+
</tr>
|
|
240
|
+
</tbody></table></div>
|
|
241
|
+
</details></div></div>"
|
|
242
|
+
`;
|
|
243
|
+
|
|
244
|
+
exports[`Markdown > raw html > should render externalAnchor 1`] = `
|
|
245
|
+
"<div class="py-8 flex flex-col gap-8"><div><p><a href="https://example.com" target="_blank" rel="noopener noreferrer" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">外部リンク<span aria-hidden="true" data-sakura-new-tab="true" class="!text-[16px] font-icon font-light inline-block leading-none align-middle whitespace-nowrap ml-0.5">open_in_new</span><span class="sr-only">Opens in new tab</span></a></p>
|
|
246
|
+
</div></div>"
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
exports[`Markdown > raw html > should render inlineTags 1`] = `
|
|
250
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>本文に <strong>太字</strong> と <u>下線</u> と <sup>(※1)</sup> と <small>小</small>。</p>
|
|
251
|
+
</div></div>"
|
|
252
|
+
`;
|
|
253
|
+
|
|
254
|
+
exports[`Markdown > raw html > should render styledBlock 1`] = `
|
|
255
|
+
"<div class="py-8 flex flex-col gap-8"><div><div style="background-color: #E8F1FE; padding: 12px 16px; border-radius: 8px; margin: 0 24px;">
|
|
256
|
+
注記のボックス
|
|
257
|
+
</div></div></div>"
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
exports[`Markdown > raw html > should render styledImg 1`] = `"<div class="py-8 flex flex-col gap-8"><div><img src="/images/a.png" alt="図" style="width: 800px; color-scheme: light;"></div></div>"`;
|
|
261
|
+
|
|
262
|
+
exports[`Markdown > raw html > should render tableSpan 1`] = `
|
|
263
|
+
"<div class="py-8 flex flex-col gap-8"><div><div class="w-full overflow-x-auto whitespace-nowrap print:overflow-visible print:whitespace-normal" data-sakura-table-container="true"><table class="border border-collapse border-solid-gray-420">
|
|
264
|
+
<caption class="text-left">表:01 キャプション</caption>
|
|
265
|
+
<colgroup><col style="width: 15%;"><col style="width: auto;"></colgroup>
|
|
266
|
+
<thead><tr class="border border-collapse border-solid-gray-420"><th colspan="2" class="p-2 bg-[#f8f8fb] text-label text-left border border-collapse border-solid-gray-420">見出し</th></tr></thead>
|
|
267
|
+
<tbody><tr class="border border-collapse border-solid-gray-420"><td rowspan="2" style="vertical-align: top;" class="p-2 text-label border border-collapse border-solid-gray-420">結合</td><td class="p-2 text-label border border-collapse border-solid-gray-420">値</td></tr><tr class="border border-collapse border-solid-gray-420"><td class="p-2 text-label border border-collapse border-solid-gray-420">値2</td></tr></tbody>
|
|
268
|
+
</table></div></div></div>"
|
|
269
|
+
`;
|
|
270
|
+
|
|
271
|
+
exports[`Markdown > table of contents > should render the table of contents when asked for it 1`] = `
|
|
272
|
+
"<div class="py-8 flex flex-col gap-8"><nav class="rounded-3xl p-10 bg-yellow-50"><h2 class="mb-4 font-bold text-h-xs-m sm:text-h-xs">目次</h2><ul class="
|
|
273
|
+
list-disc
|
|
274
|
+
[&_&]:list-circle
|
|
275
|
+
[&_&_&]:list-square
|
|
276
|
+
pl-8
|
|
277
|
+
"><li><a class="
|
|
278
|
+
cursor-pointer
|
|
279
|
+
text-blue-1000
|
|
280
|
+
active:text-orange-700
|
|
281
|
+
visited:text-magenta-900
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
focus-visible:outline-4
|
|
287
|
+
focus-visible:outline-black
|
|
288
|
+
focus-visible:ring-yellow-300
|
|
289
|
+
|
|
290
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
291
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
292
|
+
|
|
293
|
+
focus-visible:bg-yellow-300
|
|
294
|
+
|
|
295
|
+
focus-visible:rounded-sm
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
underline
|
|
299
|
+
underline-offset-[calc(3/16*1rem)]
|
|
300
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
301
|
+
|
|
302
|
+
disabled:border-solid-gray-500
|
|
303
|
+
[overflow-wrap:anywhere]
|
|
304
|
+
" href="#章1">章1</a></li><li><a class="
|
|
305
|
+
cursor-pointer
|
|
306
|
+
text-blue-1000
|
|
307
|
+
active:text-orange-700
|
|
308
|
+
visited:text-magenta-900
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
focus-visible:outline-4
|
|
314
|
+
focus-visible:outline-black
|
|
315
|
+
focus-visible:ring-yellow-300
|
|
316
|
+
|
|
317
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
318
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
319
|
+
|
|
320
|
+
focus-visible:bg-yellow-300
|
|
321
|
+
|
|
322
|
+
focus-visible:rounded-sm
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
underline
|
|
326
|
+
underline-offset-[calc(3/16*1rem)]
|
|
327
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
328
|
+
|
|
329
|
+
disabled:border-solid-gray-500
|
|
330
|
+
[overflow-wrap:anywhere]
|
|
331
|
+
" href="#節1">節1</a></li><li><a class="
|
|
332
|
+
cursor-pointer
|
|
333
|
+
text-blue-1000
|
|
334
|
+
active:text-orange-700
|
|
335
|
+
visited:text-magenta-900
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
focus-visible:outline-4
|
|
341
|
+
focus-visible:outline-black
|
|
342
|
+
focus-visible:ring-yellow-300
|
|
343
|
+
|
|
344
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
345
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
346
|
+
|
|
347
|
+
focus-visible:bg-yellow-300
|
|
348
|
+
|
|
349
|
+
focus-visible:rounded-sm
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
underline
|
|
353
|
+
underline-offset-[calc(3/16*1rem)]
|
|
354
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
355
|
+
|
|
356
|
+
disabled:border-solid-gray-500
|
|
357
|
+
[overflow-wrap:anywhere]
|
|
358
|
+
" href="#節2">節2</a></li><li><a class="
|
|
359
|
+
cursor-pointer
|
|
360
|
+
text-blue-1000
|
|
361
|
+
active:text-orange-700
|
|
362
|
+
visited:text-magenta-900
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
focus-visible:outline-4
|
|
368
|
+
focus-visible:outline-black
|
|
369
|
+
focus-visible:ring-yellow-300
|
|
370
|
+
|
|
371
|
+
focus-visible:outline-offset-[calc(2/16*1rem)]
|
|
372
|
+
focus-visible:ring-[calc(2/16*1rem)]
|
|
373
|
+
|
|
374
|
+
focus-visible:bg-yellow-300
|
|
375
|
+
|
|
376
|
+
focus-visible:rounded-sm
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
underline
|
|
380
|
+
underline-offset-[calc(3/16*1rem)]
|
|
381
|
+
hover:decoration-[calc(3/16*1rem)]
|
|
382
|
+
|
|
383
|
+
disabled:border-solid-gray-500
|
|
384
|
+
[overflow-wrap:anywhere]
|
|
385
|
+
" href="#章2">章2</a></li></ul></nav><div><h1 id="章1" class="text-h-lg-m sm:text-h-lg pt-[2rem] sm:pt-[6.5rem]">章1</h1>
|
|
386
|
+
<h2 id="節1" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">節1</h2>
|
|
387
|
+
<h3 id="項1" class="text-h-sm-m sm:text-h-sm pt-[4rem] sm:pt-[4.5rem]">項1</h3>
|
|
388
|
+
<h2 id="節2" class="text-h-med-m sm:text-h-med pt-[4rem] sm:pt-[4.5rem]">節2</h2>
|
|
389
|
+
<h1 id="章2" class="text-h-lg-m sm:text-h-lg pt-[2rem] sm:pt-[6.5rem]">章2</h1>
|
|
390
|
+
</div></div>"
|
|
391
|
+
`;
|
|
392
|
+
|
|
393
|
+
exports[`Markdown > text that only looks like a directive > should leave chapter alone 1`] = `
|
|
394
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>第1章:はじめに</p>
|
|
395
|
+
</div></div>"
|
|
396
|
+
`;
|
|
397
|
+
|
|
398
|
+
exports[`Markdown > text that only looks like a directive > should leave colonWord alone 1`] = `
|
|
399
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>参照:example と note:important を見てください。</p>
|
|
400
|
+
</div></div>"
|
|
401
|
+
`;
|
|
402
|
+
|
|
403
|
+
exports[`Markdown > text that only looks like a directive > should leave emoji alone 1`] = `
|
|
404
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>絵文字 :smile: です。</p>
|
|
405
|
+
</div></div>"
|
|
406
|
+
`;
|
|
407
|
+
|
|
408
|
+
exports[`Markdown > text that only looks like a directive > should leave functionCall alone 1`] = `
|
|
409
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>関数 foo:bar() を呼びます。</p>
|
|
410
|
+
</div></div>"
|
|
411
|
+
`;
|
|
412
|
+
|
|
413
|
+
exports[`Markdown > text that only looks like a directive > should leave linkLabel alone 1`] = `
|
|
414
|
+
"<div class="py-8 flex flex-col gap-8"><div><p><a href="https://example.com" target="_blank" rel="noopener noreferrer" class="cursor-pointer text-blue-1000 active:text-orange-700 visited:text-magenta-900 focus-visible:outline-4 focus-visible:outline-black focus-visible:ring-yellow-300 focus-visible:outline-offset-[calc(2/16*1rem)] focus-visible:ring-[calc(2/16*1rem)] focus-visible:bg-yellow-300 focus-visible:rounded-sm underline underline-offset-[calc(3/16*1rem)] hover:decoration-[calc(3/16*1rem)] disabled:border-solid-gray-500 [overflow-wrap:anywhere]">AWSドキュメント:AWS PrivateLink<span aria-hidden="true" data-sakura-new-tab="true" class="!text-[16px] font-icon font-light inline-block leading-none align-middle whitespace-nowrap ml-0.5">open_in_new</span><span class="sr-only">Opens in new tab</span></a></p>
|
|
415
|
+
</div></div>"
|
|
416
|
+
`;
|
|
417
|
+
|
|
418
|
+
exports[`Markdown > text that only looks like a directive > should leave ratio alone 1`] = `
|
|
419
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>比率は 16:9 です。</p>
|
|
420
|
+
</div></div>"
|
|
421
|
+
`;
|
|
422
|
+
|
|
423
|
+
exports[`Markdown > text that only looks like a directive > should leave scopeName alone 1`] = `
|
|
424
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>スコープ chat:write を付与する。</p>
|
|
425
|
+
</div></div>"
|
|
426
|
+
`;
|
|
427
|
+
|
|
428
|
+
exports[`Markdown > text that only looks like a directive > should leave time alone 1`] = `
|
|
429
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>開始は 10:30 です。</p>
|
|
430
|
+
</div></div>"
|
|
431
|
+
`;
|
|
432
|
+
|
|
433
|
+
exports[`Markdown > text that only looks like a directive > should leave timeFormat alone 1`] = `
|
|
434
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>開始時刻は HH:MM 形式で記載する。</p>
|
|
435
|
+
</div></div>"
|
|
436
|
+
`;
|
|
437
|
+
|
|
438
|
+
exports[`Markdown > text that only looks like a directive > should leave todo alone 1`] = `
|
|
439
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>TODO: あとで直す</p>
|
|
440
|
+
</div></div>"
|
|
441
|
+
`;
|
|
442
|
+
|
|
443
|
+
exports[`Markdown > text that only looks like a directive > should leave xmlAttr alone 1`] = `
|
|
444
|
+
"<div class="py-8 flex flex-col gap-8"><div><p>属性は xml:lang です。</p>
|
|
445
|
+
</div></div>"
|
|
446
|
+
`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { render } from '../src/render'
|
|
3
|
+
|
|
4
|
+
const html = (markdown: string) => render(markdown).html
|
|
5
|
+
|
|
6
|
+
const ids = (markdown: string) =>
|
|
7
|
+
Array.from(html(markdown).matchAll(/ id="([^"]*)"/g)).map((m) => m[1])
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `{#name}` names the element a directive renders, so a link elsewhere on the
|
|
11
|
+
* site can point at it. The parser has read the sigil since the syntax existed;
|
|
12
|
+
* nothing passed it on, so writers reached for an empty <div id> instead.
|
|
13
|
+
*/
|
|
14
|
+
describe('anchors', () => {
|
|
15
|
+
it('should put the name on the element', () => {
|
|
16
|
+
expect(ids(':::card{#pricing}\n::card-title[料金]\n:::')).toContain(
|
|
17
|
+
'pricing'
|
|
18
|
+
)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should name each kind of directive', () => {
|
|
22
|
+
const cases: Array<[string, string]> = [
|
|
23
|
+
['grid', '::::grid-cols-2{#a}\n:::cell\n本文\n:::\n::::'],
|
|
24
|
+
['cell', ':::cell{#a}\n本文\n:::'],
|
|
25
|
+
['faq', ':::faq{#a}\n::faq-q[問]\n::faq-a[答]\n:::'],
|
|
26
|
+
['card-description', '::card-description[説明]{#a}'],
|
|
27
|
+
['card-img', '::card-img{#a src=/a.png alt=図}'],
|
|
28
|
+
['link-button', ':link-button[押す]{#a href=/x}']
|
|
29
|
+
]
|
|
30
|
+
for (const [what, markdown] of cases) {
|
|
31
|
+
expect(ids(markdown), what).toContain('a')
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should name the heading a card title renders as', () => {
|
|
36
|
+
// Not the anchor inside it as well, which would be the id twice.
|
|
37
|
+
expect(ids(':::card{href=/x}\n::card-title[題]{#top}\n:::')).toEqual(['top'])
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should be reachable from a link in the prose', () => {
|
|
41
|
+
// The point of naming one. decorate.ts marks up links that leave the page,
|
|
42
|
+
// and a link to a name on this one must not be taken for one of those.
|
|
43
|
+
const out = html('[料金へ](#pricing)\n\n:::cell{#pricing}\n本文\n:::')
|
|
44
|
+
expect(out).toContain('href="#pricing"')
|
|
45
|
+
expect(out).toContain('id="pricing"')
|
|
46
|
+
expect(out).not.toContain('target="_blank"')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should not answer to {id=name}', () => {
|
|
50
|
+
// A sigil says something about the element and means the same everywhere;
|
|
51
|
+
// an attribute belongs to the directive that reads it. Keeping them apart
|
|
52
|
+
// is what stopped the video on a youtube embed taking the anchor's place.
|
|
53
|
+
expect(ids(':::cell{id=pricing}\n本文\n:::')).not.toContain('pricing')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('should leave the video to the video', () => {
|
|
57
|
+
const out = html('::youtube[題]{#player video=dQw4w9WgXcQ}')
|
|
58
|
+
expect(out).toContain('id="player"')
|
|
59
|
+
expect(out).toContain('embed/dQw4w9WgXcQ')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('should keep a name a heading would otherwise have taken', () => {
|
|
63
|
+
const out = render('## 概要\n\n:::cell{#概要}\n本文\n:::')
|
|
64
|
+
expect(out.html).toContain('id="概要"')
|
|
65
|
+
// The heading is generated first and keeps the plain slug; what matters is
|
|
66
|
+
// that the two do not both answer to it.
|
|
67
|
+
const all = Array.from(out.html.matchAll(/ id="([^"]*)"/g)).map((m) => m[1])
|
|
68
|
+
expect(new Set(all).size).toBe(all.length)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should not let a later heading repeat a name written by hand', () => {
|
|
72
|
+
const out = render('<h2 id="概要">前書き</h2>\n\n## 概要')
|
|
73
|
+
const all = Array.from(out.html.matchAll(/ id="([^"]*)"/g)).map((m) => m[1])
|
|
74
|
+
expect(new Set(all).size).toBe(all.length)
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A writer has the address of the video, not its id, so the address is what
|
|
80
|
+
* the directive takes.
|
|
81
|
+
*/
|
|
82
|
+
describe('the youtube video', () => {
|
|
83
|
+
const src = (markdown: string) =>
|
|
84
|
+
/src="([^"]*)"/.exec(render(markdown).html)?.[1]
|
|
85
|
+
|
|
86
|
+
const ID = 'dQw4w9WgXcQ'
|
|
87
|
+
const embed = `https://www.youtube-nocookie.com/embed/${ID}`
|
|
88
|
+
|
|
89
|
+
it.each([
|
|
90
|
+
['the id itself', ID],
|
|
91
|
+
['the watch page', `https://www.youtube.com/watch?v=${ID}`],
|
|
92
|
+
['the watch page with more on it', `https://www.youtube.com/watch?v=${ID}&t=42s`],
|
|
93
|
+
['the share link', `https://youtu.be/${ID}`],
|
|
94
|
+
['a short', `https://www.youtube.com/shorts/${ID}`],
|
|
95
|
+
['an embed already written', `https://www.youtube.com/embed/${ID}`]
|
|
96
|
+
])('should take %s', (_what, written) => {
|
|
97
|
+
expect(src(`::youtube[題]{video=${written}}`)).toBe(embed)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('should not let the document decide what the frame may reach for', () => {
|
|
101
|
+
const out = render(
|
|
102
|
+
'::youtube[題]{video=dQw4w9WgXcQ allow=camera referrerpolicy=unsafe-url}'
|
|
103
|
+
).html
|
|
104
|
+
expect(out).not.toContain('camera')
|
|
105
|
+
expect(out).not.toContain('unsafe-url')
|
|
106
|
+
expect(out).toContain('referrerpolicy="strict-origin-when-cross-origin"')
|
|
107
|
+
})
|
|
108
|
+
})
|