docmedown 0.1.7 → 0.1.9
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/cli.js +11 -5
- package/dist/docmedown.cjs +43 -40
- package/dist/docmedown.iife.js +314 -311
- package/dist/docmedown.mjs +7922 -5655
- package/dist/types/runtime/components/Builtins.d.ts +149 -4
- package/dist/types/runtime/markdown/component-body.d.ts +7 -0
- package/dist/types/runtime/markdown/highlighter.d.ts +18 -0
- package/dist/types/runtime/markdown/renderer.d.ts +1 -1
- package/package.json +2 -1
- package/templates/guides/custom-components.md +20 -0
|
@@ -1,34 +1,102 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Universal `<Item>` resolution context.
|
|
4
|
+
*
|
|
5
|
+
* Container components that render a paired "child" (Timeline→TimelineItem,
|
|
6
|
+
* Accordion→AccordionItem, Columns→Column, Steps→Step, CardGrid→Card) provide
|
|
7
|
+
* this context around their children. A bare `<Item>` reads the nearest
|
|
8
|
+
* provider and renders as that container's designated child, forwarding all
|
|
9
|
+
* props — so `<Timeline><Item title="…"/></Timeline>` behaves exactly like
|
|
10
|
+
* `<TimelineItem title="…"/>`, regardless of how deeply the Item is nested.
|
|
11
|
+
*
|
|
12
|
+
* With no provider up the tree, `<Item>` degrades to an `<li>` (the child of
|
|
13
|
+
* an unordered list), so it works as a generic list item anywhere.
|
|
14
|
+
*/
|
|
15
|
+
export type ItemParentKind = "timeline" | "accordion" | "columns" | "steps" | "cardgrid" | "tabs";
|
|
16
|
+
export interface ItemParentContextValue {
|
|
17
|
+
kind: ItemParentKind;
|
|
18
|
+
/** 1-based position, used by `Steps` to auto-number. */
|
|
19
|
+
index?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const ItemParentContext: React.Context<ItemParentContextValue | null>;
|
|
22
|
+
export type TabsType = "recessed" | "underline" | "pills" | "postit";
|
|
2
23
|
export interface TabsProps {
|
|
3
24
|
children?: React.ReactNode;
|
|
4
25
|
defaultIndex?: number;
|
|
5
26
|
groupId?: string;
|
|
27
|
+
/** Visual treatment. `recessed` (default) renders inset/recessed tab buttons.
|
|
28
|
+
Also accepts `underline`, `pills`, or `postit`. */
|
|
29
|
+
type?: TabsType;
|
|
30
|
+
/** Legacy alias for `type` (`underline` | `pills`); kept for backward compat. */
|
|
31
|
+
variant?: "underline" | "pills";
|
|
6
32
|
}
|
|
7
33
|
export interface TabItemProps {
|
|
8
|
-
label
|
|
34
|
+
label?: string;
|
|
9
35
|
value?: string;
|
|
10
36
|
icon?: React.ReactNode;
|
|
11
37
|
children: React.ReactNode;
|
|
12
38
|
}
|
|
13
39
|
export declare const Tabs: React.FC<TabsProps>;
|
|
14
40
|
export declare const Tab: React.FC<TabItemProps>;
|
|
41
|
+
export type CardColor = "blue" | "green" | "violet" | "amber" | "red" | "neutral";
|
|
15
42
|
export interface CardProps {
|
|
16
|
-
title
|
|
43
|
+
title?: string;
|
|
17
44
|
description?: string;
|
|
18
45
|
href?: string;
|
|
19
46
|
icon?: React.ReactNode | string;
|
|
47
|
+
image?: string;
|
|
48
|
+
imageAlt?: string;
|
|
20
49
|
badge?: string;
|
|
21
|
-
badgeType?: "info" | "success" | "warning" | "new";
|
|
50
|
+
badgeType?: "info" | "success" | "warning" | "new" | "danger" | "neutral";
|
|
51
|
+
footer?: React.ReactNode;
|
|
52
|
+
/** Named accent variant or any CSS color (hex/rgb/var(...)) applied as the card accent. */
|
|
53
|
+
color?: CardColor | string;
|
|
54
|
+
/** Soft drop shadow — enabled by default. */
|
|
55
|
+
shadow?: boolean;
|
|
22
56
|
children?: React.ReactNode;
|
|
23
57
|
}
|
|
24
58
|
export declare const Card: React.FC<CardProps>;
|
|
25
59
|
export interface CardGridProps {
|
|
26
60
|
cols?: 1 | 2 | 3 | 4;
|
|
61
|
+
/**
|
|
62
|
+
* Max visible cards in carousel mode (when cards outnumber `cols`).
|
|
63
|
+
* Defaults to `cols` and auto-shrinks when space is tight (mobile → 1).
|
|
64
|
+
*/
|
|
65
|
+
carouselCols?: 1 | 2 | 3 | 4;
|
|
27
66
|
children: React.ReactNode;
|
|
28
67
|
}
|
|
68
|
+
/** Clamp a column count into the supported 1–4 range. */
|
|
69
|
+
export declare function clampCarouselCols(value: unknown, fallback: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve how many cards fit side-by-side in the carousel viewport.
|
|
72
|
+
* `maxPerView` is the `carouselCols` cap; narrow containers shrink below it
|
|
73
|
+
* (mobile-first) so a `carouselCols={2}` grid still shows 1 card on phones.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveCarouselPerView(maxPerView: number, containerWidth: number): number;
|
|
76
|
+
/** Normalize any card index into the `0 … total-1` loop range. */
|
|
77
|
+
export declare function normalizeLoopIndex(index: number, total: number): number;
|
|
78
|
+
/** Clone ranges that make the loop seamless: last N before, first N after. */
|
|
79
|
+
export declare function buildLoopRange(total: number, perView: number): {
|
|
80
|
+
leading: number[];
|
|
81
|
+
trailing: number[];
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Sliding-window math for the CardGrid carousel. The window shows `perView`
|
|
85
|
+
* consecutive cards and cycles with wrap-around; there are
|
|
86
|
+
* `total - perView + 1` positions and every window stays full (cards from the
|
|
87
|
+
* end wrap to the front circularly).
|
|
88
|
+
*/
|
|
89
|
+
export declare function carouselWindow(total: number, perView: number, start: number): {
|
|
90
|
+
positions: number;
|
|
91
|
+
index: number;
|
|
92
|
+
indices: number[];
|
|
93
|
+
};
|
|
29
94
|
export declare const CardGrid: React.FC<CardGridProps>;
|
|
30
95
|
export interface BadgeProps {
|
|
31
|
-
type?: "info" | "success" | "warning" | "danger" | "new";
|
|
96
|
+
type?: "info" | "success" | "warning" | "danger" | "new" | "neutral";
|
|
97
|
+
pill?: boolean;
|
|
98
|
+
dot?: boolean;
|
|
99
|
+
icon?: React.ReactNode;
|
|
32
100
|
children: React.ReactNode;
|
|
33
101
|
}
|
|
34
102
|
export declare const Badge: React.FC<BadgeProps>;
|
|
@@ -42,3 +110,80 @@ export interface StepProps {
|
|
|
42
110
|
children: React.ReactNode;
|
|
43
111
|
}
|
|
44
112
|
export declare const Step: React.FC<StepProps>;
|
|
113
|
+
export type AlertType = "note" | "tip" | "important" | "warning" | "caution" | "info" | "success" | "danger";
|
|
114
|
+
export interface AlertProps {
|
|
115
|
+
type?: AlertType;
|
|
116
|
+
title?: string;
|
|
117
|
+
children?: React.ReactNode;
|
|
118
|
+
}
|
|
119
|
+
export declare const Alert: React.FC<AlertProps>;
|
|
120
|
+
/** Alias of <Alert> for Markdown-familiar authoring. */
|
|
121
|
+
export declare const Callout: React.FC<AlertProps>;
|
|
122
|
+
export interface ButtonProps {
|
|
123
|
+
variant?: "primary" | "secondary" | "outline" | "ghost" | "danger";
|
|
124
|
+
size?: "sm" | "md" | "lg";
|
|
125
|
+
href?: string;
|
|
126
|
+
external?: boolean;
|
|
127
|
+
block?: boolean;
|
|
128
|
+
icon?: React.ReactNode;
|
|
129
|
+
iconPosition?: "left" | "right";
|
|
130
|
+
loading?: boolean;
|
|
131
|
+
disabled?: boolean;
|
|
132
|
+
type?: "button" | "submit" | "reset";
|
|
133
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
134
|
+
children: React.ReactNode;
|
|
135
|
+
}
|
|
136
|
+
export declare const Button: React.FC<ButtonProps>;
|
|
137
|
+
export interface KbdProps {
|
|
138
|
+
keys?: string;
|
|
139
|
+
children: React.ReactNode;
|
|
140
|
+
}
|
|
141
|
+
export declare const Kbd: React.FC<KbdProps>;
|
|
142
|
+
export interface DetailsProps {
|
|
143
|
+
summary: string;
|
|
144
|
+
open?: boolean;
|
|
145
|
+
children?: React.ReactNode;
|
|
146
|
+
}
|
|
147
|
+
export declare const Details: React.FC<DetailsProps>;
|
|
148
|
+
export interface AccordionProps {
|
|
149
|
+
children: React.ReactNode;
|
|
150
|
+
}
|
|
151
|
+
export declare const Accordion: React.FC<AccordionProps>;
|
|
152
|
+
export interface AccordionItemProps {
|
|
153
|
+
title: string;
|
|
154
|
+
defaultOpen?: boolean;
|
|
155
|
+
children?: React.ReactNode;
|
|
156
|
+
}
|
|
157
|
+
export declare const AccordionItem: React.FC<AccordionItemProps>;
|
|
158
|
+
export interface ColumnsProps {
|
|
159
|
+
cols?: 2 | 3 | 4;
|
|
160
|
+
/** Visual treatment for each column. `normal` (default) is borderless/flush. */
|
|
161
|
+
type?: "normal" | "card" | "recessed" | "neon";
|
|
162
|
+
children: React.ReactNode;
|
|
163
|
+
}
|
|
164
|
+
export declare const Columns: React.FC<ColumnsProps>;
|
|
165
|
+
export interface ColumnProps {
|
|
166
|
+
children?: React.ReactNode;
|
|
167
|
+
}
|
|
168
|
+
export declare const Column: React.FC<ColumnProps>;
|
|
169
|
+
export interface TimelineProps {
|
|
170
|
+
children: React.ReactNode;
|
|
171
|
+
}
|
|
172
|
+
export declare const Timeline: React.FC<TimelineProps>;
|
|
173
|
+
export interface TimelineItemProps {
|
|
174
|
+
title: string;
|
|
175
|
+
subtitle?: string;
|
|
176
|
+
children?: React.ReactNode;
|
|
177
|
+
}
|
|
178
|
+
export declare const TimelineItem: React.FC<TimelineItemProps>;
|
|
179
|
+
export interface ItemProps {
|
|
180
|
+
[key: string]: any;
|
|
181
|
+
children?: React.ReactNode;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Universal child element. Reads the nearest {@link ItemParentContext} and
|
|
185
|
+
* renders as that container's designated child — TimelineItem, AccordionItem,
|
|
186
|
+
* Column, Step (auto-numbered), or Card — forwarding every prop. With no
|
|
187
|
+
* container ancestor, it renders as an `<li>` (the child of an unordered list).
|
|
188
|
+
*/
|
|
189
|
+
export declare const Item: React.FC<ItemProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function restoreFencePlaceholders(html: string, fences: string[]): string;
|
|
2
|
+
export declare function processComponentBodies(src: string): {
|
|
3
|
+
html: string;
|
|
4
|
+
fences: string[];
|
|
5
|
+
};
|
|
6
|
+
export declare function expandSelfClosingComponents(html: string): string;
|
|
7
|
+
export declare function unwrapBlockComponents(html: string): string;
|
|
@@ -14,6 +14,24 @@ import "prismjs/components/prism-go";
|
|
|
14
14
|
import "prismjs/components/prism-sql";
|
|
15
15
|
import "prismjs/components/prism-docker";
|
|
16
16
|
import "prismjs/components/prism-diff";
|
|
17
|
+
import "prismjs/components/prism-c";
|
|
18
|
+
import "prismjs/components/prism-cpp";
|
|
19
|
+
import "prismjs/components/prism-csharp";
|
|
20
|
+
import "prismjs/components/prism-java";
|
|
21
|
+
import "prismjs/components/prism-kotlin";
|
|
22
|
+
import "prismjs/components/prism-swift";
|
|
23
|
+
import "prismjs/components/prism-markup-templating";
|
|
24
|
+
import "prismjs/components/prism-php";
|
|
25
|
+
import "prismjs/components/prism-ruby";
|
|
26
|
+
import "prismjs/components/prism-toml";
|
|
27
|
+
import "prismjs/components/prism-ini";
|
|
28
|
+
import "prismjs/components/prism-nginx";
|
|
29
|
+
import "prismjs/components/prism-graphql";
|
|
30
|
+
import "prismjs/components/prism-http";
|
|
31
|
+
import "prismjs/components/prism-dart";
|
|
32
|
+
import "prismjs/components/prism-scala";
|
|
33
|
+
export declare function normalizeLanguage(lang: string): string;
|
|
34
|
+
export declare function registerLanguage(name: string, definition: Record<string, unknown>): void;
|
|
17
35
|
export declare function highlightCode(code: string, lang?: string): string;
|
|
18
36
|
export declare function escapeHtml(str: string): string;
|
|
19
37
|
export declare function renderCodeBlock(code: string, infoString?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docmedown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "The simplest MarkDown documenter yet. CLI & Web Script React SPA documentation engine.",
|
|
5
5
|
"main": "./dist/docmedown.cjs",
|
|
6
6
|
"module": "./dist/docmedown.mjs",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"test": "npx tsx --test tests/parser.test.ts tests/scanner.test.ts tests/theme-schema.test.ts tests/runtime-integration.test.ts tests/package-smoke.test.ts tests/hosting.test.ts tests/deploy.test.ts tests/home.test.ts",
|
|
50
50
|
"test:artifacts": "npx tsx --test tests/offline-artifact.test.ts",
|
|
51
51
|
"test:release": "npm run typecheck && npm run lint && npm run test && npm run build && npm run build:docs && npm run test:artifacts && npm pack --dry-run",
|
|
52
|
+
"login": "npm login",
|
|
52
53
|
"deploy": "node ./scripts/deploy.mjs",
|
|
53
54
|
"deploy:dry-run": "npm run deploy -- --dry-run",
|
|
54
55
|
"prepublishOnly": "npm run test:release"
|
|
@@ -62,6 +62,13 @@ DocMeDown comes with built-in interactive components ready to use:
|
|
|
62
62
|
|
|
63
63
|
### Feature Card Grid
|
|
64
64
|
|
|
65
|
+
Cards can be fully prop-driven (self-closing) or container-style with arbitrary
|
|
66
|
+
Markdown/HTML bodies. `title` is optional; `color` accepts a named variant
|
|
67
|
+
(`blue`, `green`, `violet`, `amber`, `red`, `neutral`) or any CSS color, and
|
|
68
|
+
`shadow={false}` opts out of the default drop shadow. Grids containing more
|
|
69
|
+
cards than columns automatically become a carousel with prev/next controls,
|
|
70
|
+
position dots, and wrap-around cycling.
|
|
71
|
+
|
|
65
72
|
```html
|
|
66
73
|
<CardGrid cols={2}>
|
|
67
74
|
<Card
|
|
@@ -78,3 +85,16 @@ DocMeDown comes with built-in interactive components ready to use:
|
|
|
78
85
|
/>
|
|
79
86
|
</CardGrid>
|
|
80
87
|
```
|
|
88
|
+
|
|
89
|
+
Container-style card with a Markdown body:
|
|
90
|
+
|
|
91
|
+
```html
|
|
92
|
+
<Card color="blue" title="Quick start">
|
|
93
|
+
Install with **npm**, then write Markdown:
|
|
94
|
+
|
|
95
|
+
- zero config
|
|
96
|
+
- hot reload
|
|
97
|
+
|
|
98
|
+
<Badge type="success">STABLE</Badge>
|
|
99
|
+
</Card>
|
|
100
|
+
```
|