@riebeckite/plugin-shortcodes 0.0.3 → 0.0.6

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/README.md CHANGED
@@ -107,4 +107,4 @@ re-exported from `@riebeckite/core`.
107
107
 
108
108
  ## See also
109
109
 
110
- - [Plugin guide](../../docs/plugins_en.md)
110
+ - [Plugin guide](../../../docs/en/plugin-system.md)
package/README_ja.md CHANGED
@@ -108,4 +108,4 @@ container }` を受け取り、文字列を返します。コンテナ型では
108
108
 
109
109
  ## 関連
110
110
 
111
- - [プラグインガイド](../../docs/plugins_ja.md)
111
+ - [プラグインガイド](../../../docs/ja/plugin-system.md)
package/dist/index.d.ts CHANGED
@@ -1,10 +1,8 @@
1
1
  import { builtinShortcodeNames, builtinShortcodes } from "./src/builtins.js";
2
- import { DEFAULT_SHORTCODE_CLASS_NAME, SHORTCODE_CHILDREN_MARKER, createShortcodeRenderContext, renderShortcode, resolveShortcodeOptions } from "./src/render.js";
3
- import { DIAGNOSTIC_INVALID, DIAGNOSTIC_UNKNOWN, SHORTCODES_SOURCE, remarkShortcodes } from "./src/remark.js";
2
+ import { DIAGNOSTIC_INVALID, DIAGNOSTIC_UNKNOWN, remarkShortcodes, SHORTCODES_SOURCE } from "./src/remark.js";
3
+ import { createShortcodeRenderContext, DEFAULT_SHORTCODE_CLASS_NAME, renderShortcode, resolveShortcodeOptions, SHORTCODE_CHILDREN_MARKER } from "./src/render.js";
4
4
  import type { ShortcodeOptions } from "./src/types.js";
5
- export type { DirectiveNode, RemarkShortcodesOptions, ResolvedShortcodeOptions, ShortcodeAttributes, ShortcodeOptions, ShortcodeRenderInput, ShortcodeRenderer, ShortcodeRenderRequest, } from "./src/types.js";
6
- export { builtinShortcodeNames, builtinShortcodes };
7
- export { DEFAULT_SHORTCODE_CLASS_NAME, SHORTCODE_CHILDREN_MARKER, createShortcodeRenderContext, renderShortcode, resolveShortcodeOptions, };
8
- export { DIAGNOSTIC_INVALID, DIAGNOSTIC_UNKNOWN, SHORTCODES_SOURCE, remarkShortcodes, };
5
+ export type { DirectiveNode, RemarkShortcodesOptions, ResolvedShortcodeOptions, ShortcodeAttributes, ShortcodeOptions, ShortcodeRenderer, ShortcodeRenderInput, ShortcodeRenderRequest, } from "./src/types.js";
6
+ export { builtinShortcodeNames, builtinShortcodes, createShortcodeRenderContext, DEFAULT_SHORTCODE_CLASS_NAME, DIAGNOSTIC_INVALID, DIAGNOSTIC_UNKNOWN, remarkShortcodes, renderShortcode, resolveShortcodeOptions, SHORTCODE_CHILDREN_MARKER, SHORTCODES_SOURCE, };
9
7
  export declare function shortcodes(options?: ShortcodeOptions): import("@riebeckite/core").RiebeckitePlugin<ShortcodeOptions>;
10
8
  export declare const shortcodesPlugin: typeof shortcodes;
package/dist/index.js CHANGED
@@ -107,9 +107,7 @@ function renderGist(input) {
107
107
  function renderKbd(input) {
108
108
  const keys = input.label || first(input.attributes, ["keys", "key", "text"]) || "";
109
109
  const parts = keys.split("+").map((part) => part.trim());
110
- return parts.filter((part) => part.length > 0).map(
111
- (part) => `<kbd class="rb-shortcode__kbd">${escapeHtml(part)}</kbd>`
112
- ).join('<span class="rb-shortcode__kbd-separator">+</span>');
110
+ return parts.filter((part) => part.length > 0).map((part) => `<kbd class="rb-shortcode__kbd">${escapeHtml(part)}</kbd>`).join('<span class="rb-shortcode__kbd-separator">+</span>');
113
111
  }
114
112
  function renderBadge(input) {
115
113
  const label = input.label || first(input.attributes, ["text", "label"]) || "badge";
@@ -208,9 +206,11 @@ var builtinShortcodes = {
208
206
  "link-card": renderLinkCard,
209
207
  file: renderFile
210
208
  };
211
- var builtinShortcodeNames = Object.keys(
212
- builtinShortcodes
213
- );
209
+ var builtinShortcodeNames = Object.keys(builtinShortcodes);
210
+
211
+ // src/remark.ts
212
+ import { escapeHtml as escapeHtml2, escapeHtmlAttribute as escapeHtmlAttribute3 } from "@riebeckite/core";
213
+ import { visit } from "unist-util-visit";
214
214
 
215
215
  // src/render.ts
216
216
  import {
@@ -302,8 +302,6 @@ function firstUrl(attributes) {
302
302
  }
303
303
 
304
304
  // src/remark.ts
305
- import { escapeHtml as escapeHtml2, escapeHtmlAttribute as escapeHtmlAttribute3 } from "@riebeckite/core";
306
- import { visit } from "unist-util-visit";
307
305
  var SHORTCODES_SOURCE = "@riebeckite/plugin-shortcodes";
308
306
  var DIAGNOSTIC_UNKNOWN = "shortcodes-unknown";
309
307
  var DIAGNOSTIC_INVALID = "shortcodes-invalid";
@@ -360,7 +358,14 @@ function transformDirective(target, resolved, options, file) {
360
358
  parent.children.splice(
361
359
  index,
362
360
  1,
363
- ...createFallback(resolved.className, name, label, attributes, container, children)
361
+ ...createFallback(
362
+ resolved.className,
363
+ name,
364
+ label,
365
+ attributes,
366
+ container,
367
+ children
368
+ )
364
369
  );
365
370
  return;
366
371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-shortcodes",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,11 @@
17
17
  "dependencies": {
18
18
  "@types/mdast": "^4.0.4",
19
19
  "unist-util-visit": "^5.1.0",
20
- "@riebeckite/core": "0.0.3"
20
+ "@riebeckite/core": "0.0.6"
21
+ },
22
+ "devDependencies": {
23
+ "tsx": "^4.22.4",
24
+ "@riebeckite/test": "0.0.6"
21
25
  },
22
26
  "publishConfig": {
23
27
  "access": "public"
@@ -52,6 +56,7 @@
52
56
  "./style.css"
53
57
  ],
54
58
  "scripts": {
55
- "build": "node ../../../scripts/build_package.mjs"
59
+ "build": "node ../../../scripts/build_package.mjs",
60
+ "test": "node --import tsx --test \"test/*.test.ts\""
56
61
  }
57
62
  }
package/style.css CHANGED
@@ -1,252 +1,252 @@
1
- .rb-shortcode {
2
- --rb-shortcode-accent: var(--rb-color-accent, #686868);
3
- --rb-shortcode-ink: var(--rb-color-ink, #1a1a1a);
4
- --rb-shortcode-rule: color-mix(
5
- in srgb,
6
- var(--rb-shortcode-ink) 20%,
7
- transparent
8
- );
9
- --rb-shortcode-surface: color-mix(
10
- in srgb,
11
- var(--rb-shortcode-ink) 5%,
12
- transparent
13
- );
14
- }
15
-
16
- div.rb-shortcode {
17
- display: block;
18
- margin-block: 1.25rem;
19
- }
20
-
21
- /* figure ------------------------------------------------------------------ */
22
-
23
- .rb-shortcode__figure {
24
- display: flex;
25
- flex-direction: column;
26
- gap: 0.5rem;
27
- margin: 0;
28
- }
29
-
30
- .rb-shortcode__image {
31
- display: block;
32
- max-width: 100%;
33
- height: auto;
34
- border: 1px solid var(--rb-shortcode-rule);
35
- }
36
-
37
- .rb-shortcode__caption {
38
- color: var(--rb-shortcode-accent);
39
- font-size: 0.875em;
40
- line-height: 1.7;
41
- }
42
-
43
- .rb-shortcode__figure-fallback,
44
- .rb-shortcode__video-fallback,
45
- .rb-shortcode__gist-fallback,
46
- .rb-shortcode__link-card-fallback,
47
- .rb-shortcode__file-fallback {
48
- color: var(--rb-shortcode-accent);
49
- font-style: italic;
50
- }
51
-
52
- /* video ------------------------------------------------------------------- */
53
-
54
- .rb-shortcode__video {
55
- position: relative;
56
- width: 100%;
57
- aspect-ratio: 16 / 9;
58
- overflow: hidden;
59
- border: 1px solid var(--rb-shortcode-rule);
60
- background: var(--rb-shortcode-surface);
61
- }
62
-
63
- .rb-shortcode__iframe {
64
- position: absolute;
65
- inset: 0;
66
- width: 100%;
67
- height: 100%;
68
- border: 0;
69
- }
70
-
71
- /* gist -------------------------------------------------------------------- */
72
-
73
- .rb-shortcode__gist {
74
- overflow: hidden;
75
- border: 1px solid var(--rb-shortcode-rule);
76
- }
77
-
78
- /* keyboard ---------------------------------------------------------------- */
79
-
80
- .rb-shortcode__kbd {
81
- display: inline-block;
82
- padding: 0.1em 0.4em;
83
- border: 1px solid var(--rb-shortcode-rule);
84
- border-bottom-width: 2px;
85
- border-radius: 4px;
86
- background: var(--rb-shortcode-surface);
87
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
88
- font-size: 0.85em;
89
- line-height: 1.4;
90
- }
91
-
92
- .rb-shortcode__kbd-separator {
93
- margin-inline: 0.15em;
94
- color: var(--rb-shortcode-accent);
95
- }
96
-
97
- /* badge ------------------------------------------------------------------- */
98
-
99
- .rb-shortcode__badge {
100
- display: inline-block;
101
- padding: 0.1em 0.5em;
102
- border: 1px solid currentcolor;
103
- border-radius: 999px;
104
- color: var(--rb-shortcode-accent);
105
- font-size: 0.75em;
106
- line-height: 1.6;
107
- vertical-align: middle;
108
- }
109
-
110
- .rb-shortcode__badge--info {
111
- color: #0b6bcb;
112
- }
113
-
114
- .rb-shortcode__badge--success {
115
- color: #1a7f37;
116
- }
117
-
118
- .rb-shortcode__badge--warning {
119
- color: #9a6700;
120
- }
121
-
122
- .rb-shortcode__badge--danger {
123
- color: #cf222e;
124
- }
125
-
126
- /* details / spoiler ------------------------------------------------------- */
127
-
128
- .rb-shortcode__details {
129
- border: 1px solid var(--rb-shortcode-rule);
130
- }
131
-
132
- .rb-shortcode__summary {
133
- padding: 0.5rem 0.75rem;
134
- cursor: pointer;
135
- font-weight: 600;
136
- }
137
-
138
- .rb-shortcode__details-body {
139
- padding: 0.25rem 0.75rem 0.75rem;
140
- }
141
-
142
- /* note / callout ---------------------------------------------------------- */
143
-
144
- .rb-shortcode__note {
145
- padding: 0.75rem 1rem;
146
- border-left: 4px solid var(--rb-shortcode-accent);
147
- background: var(--rb-shortcode-surface);
148
- }
149
-
150
- .rb-shortcode__note-title {
151
- margin: 0 0 0.35rem;
152
- font-weight: 700;
153
- }
154
-
155
- .rb-shortcode__note-body > :first-child,
156
- .rb-shortcode__details-body > :first-child {
157
- margin-top: 0;
158
- }
159
-
160
- .rb-shortcode__note-body > :last-child,
161
- .rb-shortcode__details-body > :last-child {
162
- margin-bottom: 0;
163
- }
164
-
165
- .rb-shortcode__note--tip {
166
- border-left-color: #1a7f37;
167
- }
168
-
169
- .rb-shortcode__note--warning {
170
- border-left-color: #9a6700;
171
- }
172
-
173
- .rb-shortcode__note--danger {
174
- border-left-color: #cf222e;
175
- }
176
-
177
- /* link card --------------------------------------------------------------- */
178
-
179
- .rb-shortcode__link-card {
180
- display: flex;
181
- gap: 0.75rem;
182
- padding: 0.75rem;
183
- border: 1px solid var(--rb-shortcode-rule);
184
- color: inherit;
185
- text-decoration: none;
186
- }
187
-
188
- .rb-shortcode__link-card:hover,
189
- .rb-shortcode__link-card:focus-visible {
190
- border-color: var(--rb-shortcode-accent);
191
- }
192
-
193
- .rb-shortcode__link-card-image {
194
- width: 96px;
195
- height: 96px;
196
- flex: none;
197
- object-fit: cover;
198
- }
199
-
200
- .rb-shortcode__link-card-body {
201
- display: flex;
202
- flex-direction: column;
203
- gap: 0.25rem;
204
- min-width: 0;
205
- }
206
-
207
- .rb-shortcode__link-card-title {
208
- font-weight: 700;
209
- }
210
-
211
- .rb-shortcode__link-card-description,
212
- .rb-shortcode__link-card-url {
213
- color: var(--rb-shortcode-accent);
214
- font-size: 0.875em;
215
- line-height: 1.6;
216
- }
217
-
218
- .rb-shortcode__link-card-url {
219
- overflow: hidden;
220
- text-overflow: ellipsis;
221
- white-space: nowrap;
222
- }
223
-
224
- /* file -------------------------------------------------------------------- */
225
-
226
- .rb-shortcode__file {
227
- display: inline-flex;
228
- align-items: center;
229
- gap: 0.5rem;
230
- padding: 0.35rem 0.75rem;
231
- border: 1px solid var(--rb-shortcode-rule);
232
- color: inherit;
233
- text-decoration: none;
234
- }
235
-
236
- .rb-shortcode__file:hover,
237
- .rb-shortcode__file:focus-visible {
238
- border-color: var(--rb-shortcode-accent);
239
- }
240
-
241
- .rb-shortcode__file-size {
242
- color: var(--rb-shortcode-accent);
243
- font-size: 0.8125em;
244
- }
245
-
246
- /* fallback ---------------------------------------------------------------- */
247
-
248
- .rb-shortcode--unknown {
249
- color: var(--rb-shortcode-accent);
250
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
251
- font-size: 0.875em;
252
- }
1
+ .rb-shortcode {
2
+ --rb-shortcode-accent: var(--rb-color-accent, #686868);
3
+ --rb-shortcode-ink: var(--rb-color-ink, #1a1a1a);
4
+ --rb-shortcode-rule: color-mix(
5
+ in srgb,
6
+ var(--rb-shortcode-ink) 20%,
7
+ transparent
8
+ );
9
+ --rb-shortcode-surface: color-mix(
10
+ in srgb,
11
+ var(--rb-shortcode-ink) 5%,
12
+ transparent
13
+ );
14
+ }
15
+
16
+ div.rb-shortcode {
17
+ display: block;
18
+ margin-block: 1.25rem;
19
+ }
20
+
21
+ /* figure ------------------------------------------------------------------ */
22
+
23
+ .rb-shortcode__figure {
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 0.5rem;
27
+ margin: 0;
28
+ }
29
+
30
+ .rb-shortcode__image {
31
+ display: block;
32
+ max-width: 100%;
33
+ height: auto;
34
+ border: 1px solid var(--rb-shortcode-rule);
35
+ }
36
+
37
+ .rb-shortcode__caption {
38
+ color: var(--rb-shortcode-accent);
39
+ font-size: 0.875em;
40
+ line-height: 1.7;
41
+ }
42
+
43
+ .rb-shortcode__figure-fallback,
44
+ .rb-shortcode__video-fallback,
45
+ .rb-shortcode__gist-fallback,
46
+ .rb-shortcode__link-card-fallback,
47
+ .rb-shortcode__file-fallback {
48
+ color: var(--rb-shortcode-accent);
49
+ font-style: italic;
50
+ }
51
+
52
+ /* video ------------------------------------------------------------------- */
53
+
54
+ .rb-shortcode__video {
55
+ position: relative;
56
+ width: 100%;
57
+ aspect-ratio: 16 / 9;
58
+ overflow: hidden;
59
+ border: 1px solid var(--rb-shortcode-rule);
60
+ background: var(--rb-shortcode-surface);
61
+ }
62
+
63
+ .rb-shortcode__iframe {
64
+ position: absolute;
65
+ inset: 0;
66
+ width: 100%;
67
+ height: 100%;
68
+ border: 0;
69
+ }
70
+
71
+ /* gist -------------------------------------------------------------------- */
72
+
73
+ .rb-shortcode__gist {
74
+ overflow: hidden;
75
+ border: 1px solid var(--rb-shortcode-rule);
76
+ }
77
+
78
+ /* keyboard ---------------------------------------------------------------- */
79
+
80
+ .rb-shortcode__kbd {
81
+ display: inline-block;
82
+ padding: 0.1em 0.4em;
83
+ border: 1px solid var(--rb-shortcode-rule);
84
+ border-bottom-width: 2px;
85
+ border-radius: 4px;
86
+ background: var(--rb-shortcode-surface);
87
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
88
+ font-size: 0.85em;
89
+ line-height: 1.4;
90
+ }
91
+
92
+ .rb-shortcode__kbd-separator {
93
+ margin-inline: 0.15em;
94
+ color: var(--rb-shortcode-accent);
95
+ }
96
+
97
+ /* badge ------------------------------------------------------------------- */
98
+
99
+ .rb-shortcode__badge {
100
+ display: inline-block;
101
+ padding: 0.1em 0.5em;
102
+ border: 1px solid currentcolor;
103
+ border-radius: 999px;
104
+ color: var(--rb-shortcode-accent);
105
+ font-size: 0.75em;
106
+ line-height: 1.6;
107
+ vertical-align: middle;
108
+ }
109
+
110
+ .rb-shortcode__badge--info {
111
+ color: #0b6bcb;
112
+ }
113
+
114
+ .rb-shortcode__badge--success {
115
+ color: #1a7f37;
116
+ }
117
+
118
+ .rb-shortcode__badge--warning {
119
+ color: #9a6700;
120
+ }
121
+
122
+ .rb-shortcode__badge--danger {
123
+ color: #cf222e;
124
+ }
125
+
126
+ /* details / spoiler ------------------------------------------------------- */
127
+
128
+ .rb-shortcode__details {
129
+ border: 1px solid var(--rb-shortcode-rule);
130
+ }
131
+
132
+ .rb-shortcode__summary {
133
+ padding: 0.5rem 0.75rem;
134
+ cursor: pointer;
135
+ font-weight: 600;
136
+ }
137
+
138
+ .rb-shortcode__details-body {
139
+ padding: 0.25rem 0.75rem 0.75rem;
140
+ }
141
+
142
+ /* note / callout ---------------------------------------------------------- */
143
+
144
+ .rb-shortcode__note {
145
+ padding: 0.75rem 1rem;
146
+ border-left: 4px solid var(--rb-shortcode-accent);
147
+ background: var(--rb-shortcode-surface);
148
+ }
149
+
150
+ .rb-shortcode__note-title {
151
+ margin: 0 0 0.35rem;
152
+ font-weight: 700;
153
+ }
154
+
155
+ .rb-shortcode__note-body > :first-child,
156
+ .rb-shortcode__details-body > :first-child {
157
+ margin-top: 0;
158
+ }
159
+
160
+ .rb-shortcode__note-body > :last-child,
161
+ .rb-shortcode__details-body > :last-child {
162
+ margin-bottom: 0;
163
+ }
164
+
165
+ .rb-shortcode__note--tip {
166
+ border-left-color: #1a7f37;
167
+ }
168
+
169
+ .rb-shortcode__note--warning {
170
+ border-left-color: #9a6700;
171
+ }
172
+
173
+ .rb-shortcode__note--danger {
174
+ border-left-color: #cf222e;
175
+ }
176
+
177
+ /* link card --------------------------------------------------------------- */
178
+
179
+ .rb-shortcode__link-card {
180
+ display: flex;
181
+ gap: 0.75rem;
182
+ padding: 0.75rem;
183
+ border: 1px solid var(--rb-shortcode-rule);
184
+ color: inherit;
185
+ text-decoration: none;
186
+ }
187
+
188
+ .rb-shortcode__link-card:hover,
189
+ .rb-shortcode__link-card:focus-visible {
190
+ border-color: var(--rb-shortcode-accent);
191
+ }
192
+
193
+ .rb-shortcode__link-card-image {
194
+ width: 96px;
195
+ height: 96px;
196
+ flex: none;
197
+ object-fit: cover;
198
+ }
199
+
200
+ .rb-shortcode__link-card-body {
201
+ display: flex;
202
+ flex-direction: column;
203
+ gap: 0.25rem;
204
+ min-width: 0;
205
+ }
206
+
207
+ .rb-shortcode__link-card-title {
208
+ font-weight: 700;
209
+ }
210
+
211
+ .rb-shortcode__link-card-description,
212
+ .rb-shortcode__link-card-url {
213
+ color: var(--rb-shortcode-accent);
214
+ font-size: 0.875em;
215
+ line-height: 1.6;
216
+ }
217
+
218
+ .rb-shortcode__link-card-url {
219
+ overflow: hidden;
220
+ text-overflow: ellipsis;
221
+ white-space: nowrap;
222
+ }
223
+
224
+ /* file -------------------------------------------------------------------- */
225
+
226
+ .rb-shortcode__file {
227
+ display: inline-flex;
228
+ align-items: center;
229
+ gap: 0.5rem;
230
+ padding: 0.35rem 0.75rem;
231
+ border: 1px solid var(--rb-shortcode-rule);
232
+ color: inherit;
233
+ text-decoration: none;
234
+ }
235
+
236
+ .rb-shortcode__file:hover,
237
+ .rb-shortcode__file:focus-visible {
238
+ border-color: var(--rb-shortcode-accent);
239
+ }
240
+
241
+ .rb-shortcode__file-size {
242
+ color: var(--rb-shortcode-accent);
243
+ font-size: 0.8125em;
244
+ }
245
+
246
+ /* fallback ---------------------------------------------------------------- */
247
+
248
+ .rb-shortcode--unknown {
249
+ color: var(--rb-shortcode-accent);
250
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
251
+ font-size: 0.875em;
252
+ }