@dr-ishaan/remake-blocks 1.0.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 astro-callout-blocks contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,319 @@
1
+ # @dr-ishaan/remake-blocks
2
+
3
+ Professional Astro 6 integration for rendering GitHub-style callouts (admonitions) and enhanced blockquotes in Markdown content.
4
+
5
+ **29 first-class callout types** — each directive maps 1:1 to its own unique visual identity, SVG icon, color palette, and CSS class. No alias resolution.
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - **29 built-in callout types** — GFM standard (5) + Obsidian core (10) + promoted aliases (14), each with unique styling
12
+ - **GitHub admonition syntax** — `> [!NOTE]`, `> [!TIP]`, `> [!WARNING]`, etc.
13
+ - **Custom titles** — `> [!WARNING] Deprecated API` renders with your title
14
+ - **Collapsible callouts** — `> [!FAQ]-` (collapsed) and `> [!TIP]+` (expanded)
15
+ - **Custom callout types** — define your own with icon, color, and CSS class
16
+ - **Enhanced blockquotes** — regular blockquotes get improved styling automatically
17
+ - **Dark mode** — automatic via `prefers-color-scheme` and manual via `data-theme` attribute
18
+ - **Auto CSS injection** — styles injected into every page by default
19
+ - **Zero JavaScript** — pure CSS + HTML (collapsibles use native `<details>`/`<summary>`)
20
+ - **Accessible** — proper ARIA roles, semantic HTML
21
+ - **Print-optimized** — clean print styles
22
+
23
+ ---
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ npm install @dr-ishaan/remake-blocks
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```js
34
+ // astro.config.mjs
35
+ import { defineConfig } from "astro/config";
36
+ import remakeBlocks from "@dr-ishaan/remake-blocks";
37
+
38
+ export default defineConfig({
39
+ integrations: [remakeBlocks()],
40
+ });
41
+ ```
42
+
43
+ Then use callouts in any Markdown or MDX file:
44
+
45
+ ```markdown
46
+ > [!NOTE]
47
+ > This is a note callout with useful information.
48
+
49
+ > [!TIP] Keyboard Shortcut
50
+ > Press `Ctrl+Shift+P` to open the command palette.
51
+
52
+ > [!WARNING]-
53
+ > This collapsible warning starts collapsed.
54
+ ```
55
+
56
+ ---
57
+
58
+ ## All 29 Callout Types
59
+
60
+ ### GFM Standard (5)
61
+
62
+ | Directive | Default Title | CSS Class |
63
+ |-----------|--------------|-----------|
64
+ | `[!NOTE]` | Note | `callout-note` |
65
+ | `[!TIP]` | Tip | `callout-tip` |
66
+ | `[!IMPORTANT]` | Important | `callout-important` |
67
+ | `[!WARNING]` | Warning | `callout-warning` |
68
+ | `[!CAUTION]` | Caution | `callout-caution` |
69
+
70
+ ### Obsidian Core (10)
71
+
72
+ | Directive | Default Title | CSS Class |
73
+ |-----------|--------------|-----------|
74
+ | `[!ABSTRACT]` | Abstract | `callout-abstract` |
75
+ | `[!INFO]` | Info | `callout-info` |
76
+ | `[!SUCCESS]` | Success | `callout-success` |
77
+ | `[!QUESTION]` | Question | `callout-question` |
78
+ | `[!FAILURE]` | Failure | `callout-failure` |
79
+ | `[!DANGER]` | Danger | `callout-danger` |
80
+ | `[!QUOTE]` | Quote | `callout-quote` |
81
+ | `[!BUG]` | Bug | `callout-bug` |
82
+ | `[!EXAMPLE]` | Example | `callout-example` |
83
+ | `[!TODO]` | Todo | `callout-todo` |
84
+
85
+ ### Promoted Aliases — First-Class Types (14)
86
+
87
+ Each of these is its **own distinct type** with unique colors, not an alias:
88
+
89
+ | Directive | Default Title | CSS Class |
90
+ |-----------|--------------|-----------|
91
+ | `[!SUMMARY]` | Summary | `callout-summary` |
92
+ | `[!TLDR]` | TL;DR | `callout-tldr` |
93
+ | `[!HINT]` | Hint | `callout-hint` |
94
+ | `[!CHECK]` | Check | `callout-check` |
95
+ | `[!DONE]` | Done | `callout-done` |
96
+ | `[!HELP]` | Help | `callout-help` |
97
+ | `[!FAQ]` | FAQ | `callout-faq` |
98
+ | `[!ATTENTION]` | Attention | `callout-attention` |
99
+ | `[!FAIL]` | Fail | `callout-fail` |
100
+ | `[!MISSING]` | Missing | `callout-missing` |
101
+ | `[!ERROR]` | Error | `callout-error` |
102
+ | `[!CITE]` | Cite | `callout-cite` |
103
+
104
+ ---
105
+
106
+ ## Syntax
107
+
108
+ ### Basic Callout
109
+
110
+ ```markdown
111
+ > [!NOTE]
112
+ > Content goes here.
113
+ ```
114
+
115
+ ### Custom Title
116
+
117
+ ```markdown
118
+ > [!WARNING] Breaking Change
119
+ > The v2 API has been deprecated.
120
+ ```
121
+
122
+ ### Collapsible (Collapsed)
123
+
124
+ ```markdown
125
+ > [!FAQ]-
126
+ > Click to reveal the answer.
127
+ ```
128
+
129
+ ### Collapsible (Expanded)
130
+
131
+ ```markdown
132
+ > [!TIP]+
133
+ > This starts expanded but can be collapsed.
134
+ ```
135
+
136
+ ### Multi-Paragraph
137
+
138
+ ```markdown
139
+ > [!IMPORTANT]
140
+ > First paragraph.
141
+ >
142
+ > Second paragraph with **bold** and `code`.
143
+ >
144
+ > - List item 1
145
+ > - List item 2
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Configuration
151
+
152
+ ```js
153
+ // astro.config.mjs
154
+ import { defineConfig } from "astro/config";
155
+ import remakeBlocks from "@dr-ishaan/remake-blocks";
156
+
157
+ export default defineConfig({
158
+ integrations: [
159
+ remakeBlocks({
160
+ // Whether to auto-inject CSS styles (default: true)
161
+ injectStyles: true,
162
+
163
+ // Whether to enhance regular blockquotes (default: true)
164
+ enhanceBlockquotes: true,
165
+
166
+ // CSS class for callout container (default: "callout")
167
+ calloutClass: "callout",
168
+
169
+ // CSS class for callout title (default: "callout-title")
170
+ calloutTitleClass: "callout-title",
171
+
172
+ // CSS class for callout body (default: "callout-body")
173
+ calloutBodyClass: "callout-body",
174
+
175
+ // Add data-callout-type attribute (default: true)
176
+ dataCalloutType: true,
177
+
178
+ // Custom callout types
179
+ customCallouts: [
180
+ {
181
+ type: "custom",
182
+ icon: "🚀",
183
+ className: "callout-custom",
184
+ defaultTitle: "Custom",
185
+ color: "#8b5cf6",
186
+ backgroundColor: "#f5f3ff",
187
+ },
188
+ ],
189
+ }),
190
+ ],
191
+ });
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Custom Callout Types
197
+
198
+ Define your own callout types with full control over appearance:
199
+
200
+ ```js
201
+ remakeBlocks({
202
+ customCallouts: [
203
+ {
204
+ type: "machine-learning", // [!MACHINE-LEARNING]
205
+ icon: "🧠", // Emoji or SVG string
206
+ className: "callout-ml", // CSS class
207
+ defaultTitle: "Machine Learning",
208
+ color: "#7c3aed", // Border & accent color
209
+ backgroundColor: "#f5f3ff", // Background color
210
+ iconColor: "#7c3aed", // Icon color (optional, defaults to color)
211
+ },
212
+ ],
213
+ })
214
+ ```
215
+
216
+ If a custom callout's `type` matches a built-in, the built-in is overridden.
217
+
218
+ ---
219
+
220
+ ## Manual CSS Import
221
+
222
+ If you set `injectStyles: false`, import the stylesheet manually:
223
+
224
+ ```js
225
+ // In a layout component or global CSS file
226
+ import "@dr-ishaan/remake-blocks/styles.css";
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Dark Mode
232
+
233
+ Dark mode is supported automatically via `prefers-color-scheme: dark` and manually via the `data-theme` attribute:
234
+
235
+ ```html
236
+ <html data-theme="dark">
237
+ <!-- callouts switch to dark palette -->
238
+ </html>
239
+ ```
240
+
241
+ Supported `data-theme` values: `"dark"`, `"dim"`.
242
+
243
+ ---
244
+
245
+ ## CSS Custom Properties
246
+
247
+ Override any design token at the `:root` level:
248
+
249
+ ```css
250
+ :root {
251
+ --callout-radius: 8px;
252
+ --callout-padding-y: 12px;
253
+ --callout-padding-x: 16px;
254
+ --callout-icon-size: 24px;
255
+ --callout-title-font-size: 1.1em;
256
+
257
+ /* Per-type overrides */
258
+ --callout-note-border: #3b82f6;
259
+ --callout-note-bg: #eff6ff;
260
+ }
261
+ ```
262
+
263
+ See `styles.css` for the complete list of CSS custom properties.
264
+
265
+ ---
266
+
267
+ ## HTML Output
268
+
269
+ Each callout renders as:
270
+
271
+ ```html
272
+ <div class="callout callout-note" data-callout-type="note" role="note">
273
+ <div class="callout-title" style="color:#0969da">
274
+ <span class="callout-icon" style="color:#0969da">
275
+ <!-- SVG icon -->
276
+ </span>
277
+ <span class="callout-title-text">Note</span>
278
+ </div>
279
+ <div class="callout-body">
280
+ <p>Content goes here.</p>
281
+ </div>
282
+ </div>
283
+ ```
284
+
285
+ Collapsible callouts use `<details>`/`<summary>`:
286
+
287
+ ```html
288
+ <details class="callout callout-faq collapsible" data-callout-type="faq" role="note">
289
+ <summary class="callout-title" style="color:#b45309">
290
+ <span class="callout-icon" style="color:#b45309"><!-- SVG --></span>
291
+ <span class="callout-title-text">FAQ</span>
292
+ </summary>
293
+ <div class="callout-body">
294
+ <p>Content revealed on click.</p>
295
+ </div>
296
+ </details>
297
+ ```
298
+
299
+ ---
300
+
301
+ ## Advanced: Using the Remark Plugin Directly
302
+
303
+ The remark plugin can be used independently of the Astro integration:
304
+
305
+ ```js
306
+ import { unified } from "unified";
307
+ import remarkParse from "remark-parse";
308
+ import { remarkCalloutBlocks } from "@dr-ishaan/remake-blocks";
309
+
310
+ const processor = unified()
311
+ .use(remarkParse)
312
+ .use(remarkCalloutBlocks, { enhanceBlockquotes: true });
313
+ ```
314
+
315
+ ---
316
+
317
+ ## License
318
+
319
+ MIT
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @dr-ishaan/remake-blocks
3
+ *
4
+ * Astro 6 integration for rendering GitHub-style callouts (admonitions)
5
+ * and enhanced blockquotes in Markdown content.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // astro.config.mjs
10
+ * import { defineConfig } from "astro/config";
11
+ * import remakeBlocks from "@dr-ishaan/remake-blocks";
12
+ *
13
+ * export default defineConfig({
14
+ * integrations: [remakeBlocks()],
15
+ * });
16
+ * ```
17
+ *
18
+ * @example With custom callout types:
19
+ * ```ts
20
+ * export default defineConfig({
21
+ * integrations: [
22
+ * remakeBlocks({
23
+ * customCallouts: [
24
+ * {
25
+ * type: "example",
26
+ * icon: "💡",
27
+ * className: "callout-example",
28
+ * defaultTitle: "Example",
29
+ * color: "#8b5cf6",
30
+ * backgroundColor: "#f5f3ff",
31
+ * },
32
+ * ],
33
+ * }),
34
+ * ],
35
+ * });
36
+ * ```
37
+ */
38
+ import type { AstroIntegration } from "astro";
39
+ import type { AstroCalloutBlocksOptions } from "./types.js";
40
+ export type { AstroCalloutBlocksOptions, RemarkCalloutBlocksOptions, CalloutConfig, CalloutType, BuiltinCalloutType, ParsedCallout } from "./types.js";
41
+ export { remarkCalloutBlocks } from "./remark-callout-blocks.js";
42
+ /**
43
+ * Create the `@dr-ishaan/remake-blocks` Astro integration.
44
+ *
45
+ * This integration:
46
+ * 1. Registers the `remarkCalloutBlocks` remark plugin so that GitHub-style
47
+ * admonition directives (`> [!NOTE]`, `> [!TIP]`, etc.) inside blockquotes
48
+ * are transformed into styled callout HTML elements.
49
+ * 2. Optionally injects the default CSS styles into every page.
50
+ * 3. Optionally enhances regular blockquotes with improved styling.
51
+ *
52
+ * @param options - Plugin configuration options.
53
+ * @returns An Astro integration object.
54
+ */
55
+ export default function remakeBlocks(options?: AstroCalloutBlocksOptions): AstroIntegration;
56
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAA8B,MAAM,YAAY,CAAC;AAIxF,YAAY,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGvJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,OAAO,GAAE,yBAA8B,GACtC,gBAAgB,CAwClB"}
package/dist/index.js ADDED
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @dr-ishaan/remake-blocks
3
+ *
4
+ * Astro 6 integration for rendering GitHub-style callouts (admonitions)
5
+ * and enhanced blockquotes in Markdown content.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // astro.config.mjs
10
+ * import { defineConfig } from "astro/config";
11
+ * import remakeBlocks from "@dr-ishaan/remake-blocks";
12
+ *
13
+ * export default defineConfig({
14
+ * integrations: [remakeBlocks()],
15
+ * });
16
+ * ```
17
+ *
18
+ * @example With custom callout types:
19
+ * ```ts
20
+ * export default defineConfig({
21
+ * integrations: [
22
+ * remakeBlocks({
23
+ * customCallouts: [
24
+ * {
25
+ * type: "example",
26
+ * icon: "💡",
27
+ * className: "callout-example",
28
+ * defaultTitle: "Example",
29
+ * color: "#8b5cf6",
30
+ * backgroundColor: "#f5f3ff",
31
+ * },
32
+ * ],
33
+ * }),
34
+ * ],
35
+ * });
36
+ * ```
37
+ */
38
+ import { fileURLToPath } from "url";
39
+ import path from "path";
40
+ import { remarkCalloutBlocks } from "./remark-callout-blocks.js";
41
+ // Re-export the remark plugin for advanced usage
42
+ export { remarkCalloutBlocks } from "./remark-callout-blocks.js";
43
+ /**
44
+ * Create the `@dr-ishaan/remake-blocks` Astro integration.
45
+ *
46
+ * This integration:
47
+ * 1. Registers the `remarkCalloutBlocks` remark plugin so that GitHub-style
48
+ * admonition directives (`> [!NOTE]`, `> [!TIP]`, etc.) inside blockquotes
49
+ * are transformed into styled callout HTML elements.
50
+ * 2. Optionally injects the default CSS styles into every page.
51
+ * 3. Optionally enhances regular blockquotes with improved styling.
52
+ *
53
+ * @param options - Plugin configuration options.
54
+ * @returns An Astro integration object.
55
+ */
56
+ export default function remakeBlocks(options = {}) {
57
+ const { injectStyles = true, ...remarkOptions } = options;
58
+ return {
59
+ name: "@dr-ishaan/remake-blocks",
60
+ hooks: {
61
+ /**
62
+ * During the Astro config setup, inject the remark plugin into the
63
+ * markdown.remarkPlugins array and optionally inject the stylesheet.
64
+ */
65
+ "astro:config:setup": ({ config, updateConfig, injectScript }) => {
66
+ // Inject the remark plugin
67
+ updateConfig({
68
+ markdown: {
69
+ remarkPlugins: [
70
+ ...(config.markdown?.remarkPlugins ?? []),
71
+ [remarkCalloutBlocks, remarkOptions],
72
+ ],
73
+ },
74
+ });
75
+ // If auto-injecting styles, add the stylesheet via Astro's
76
+ // built-in injectScript mechanism.
77
+ if (injectStyles) {
78
+ // Resolve the path to the bundled stylesheet
79
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
80
+ const stylesPath = path.resolve(__dirname, "styles.css");
81
+ // Inject an import so the styles are included in every page.
82
+ // Users who need more control can set injectStyles: false
83
+ // and import "@dr-ishaan/remake-blocks/styles.css" manually.
84
+ injectScript("page-ssr", `import "${stylesPath}";`);
85
+ }
86
+ },
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,iDAAiD;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAqC,EAAE;IAEvC,MAAM,EACJ,YAAY,GAAG,IAAI,EACnB,GAAG,aAAa,EACjB,GAAG,OAAO,CAAC;IAEZ,OAAO;QACL,IAAI,EAAE,0BAA0B;QAEhC,KAAK,EAAE;YACL;;;eAGG;YACH,oBAAoB,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,EAAE;gBAC/D,2BAA2B;gBAC3B,YAAY,CAAC;oBACX,QAAQ,EAAE;wBACR,aAAa,EAAE;4BACb,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE,aAAa,IAAI,EAAE,CAAC;4BACzC,CAAC,mBAAmB,EAAE,aAAa,CAAC;yBACrC;qBACF;iBACF,CAAC,CAAC;gBAEH,2DAA2D;gBAC3D,mCAAmC;gBACnC,IAAI,YAAY,EAAE,CAAC;oBACjB,6CAA6C;oBAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;oBAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;oBAEzD,6DAA6D;oBAC7D,0DAA0D;oBAC1D,6DAA6D;oBAC7D,YAAY,CAAC,UAAU,EAAE,WAAW,UAAU,IAAI,CAAC,CAAC;gBACtD,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * remark plugin for @dr-ishaan/remake-blocks
3
+ *
4
+ * A remark plugin that transforms callout directives inside blockquotes
5
+ * into styled callout components, and optionally enhances regular blockquotes.
6
+ *
7
+ * 29 first-class callout types — each directive maps 1:1 to its own
8
+ * unique visual identity. No alias resolution.
9
+ */
10
+ import type { Root } from "mdast";
11
+ import type { Plugin } from "unified";
12
+ import type { RemarkCalloutBlocksOptions, CalloutConfig } from "./types.js";
13
+ declare const BUILTIN_CALLOUTS: CalloutConfig[];
14
+ export declare const remarkCalloutBlocks: Plugin<[RemarkCalloutBlocksOptions?], Root>;
15
+ export { BUILTIN_CALLOUTS };
16
+ //# sourceMappingURL=remark-callout-blocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remark-callout-blocks.d.ts","sourceRoot":"","sources":["../src/remark-callout-blocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAqC,MAAM,OAAO,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EAId,MAAM,YAAY,CAAC;AAMpB,QAAA,MAAM,gBAAgB,EAAE,aAAa,EA4PpC,CAAC;AAyYF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,CAAC,0BAA0B,CAAC,CAAC,EAAE,IAAI,CAkC3E,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}