@dogsbay/format-dogsbay-md 0.2.0-beta.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/dist/attributes.d.ts +33 -0
- package/dist/attributes.d.ts.map +1 -0
- package/dist/attributes.js +83 -0
- package/dist/attributes.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/directives.d.ts +19 -0
- package/dist/directives.d.ts.map +1 -0
- package/dist/directives.js +76 -0
- package/dist/directives.js.map +1 -0
- package/dist/escape.d.ts +42 -0
- package/dist/escape.d.ts.map +1 -0
- package/dist/escape.js +79 -0
- package/dist/escape.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/inline.d.ts +9 -0
- package/dist/inline.d.ts.map +1 -0
- package/dist/inline.js +122 -0
- package/dist/inline.js.map +1 -0
- package/dist/nav-file.d.ts +38 -0
- package/dist/nav-file.d.ts.map +1 -0
- package/dist/nav-file.js +257 -0
- package/dist/nav-file.js.map +1 -0
- package/dist/nav.d.ts +34 -0
- package/dist/nav.d.ts.map +1 -0
- package/dist/nav.js +169 -0
- package/dist/nav.js.map +1 -0
- package/dist/parse-attrs.d.ts +24 -0
- package/dist/parse-attrs.d.ts.map +1 -0
- package/dist/parse-attrs.js +117 -0
- package/dist/parse-attrs.js.map +1 -0
- package/dist/parse.d.ts +18 -0
- package/dist/parse.d.ts.map +1 -0
- package/dist/parse.js +1076 -0
- package/dist/parse.js.map +1 -0
- package/dist/plugin-block-leaf.d.ts +19 -0
- package/dist/plugin-block-leaf.d.ts.map +1 -0
- package/dist/plugin-block-leaf.js +81 -0
- package/dist/plugin-block-leaf.js.map +1 -0
- package/dist/plugin-containers.d.ts +11 -0
- package/dist/plugin-containers.d.ts.map +1 -0
- package/dist/plugin-containers.js +63 -0
- package/dist/plugin-containers.js.map +1 -0
- package/dist/plugin-inline-directives.d.ts +18 -0
- package/dist/plugin-inline-directives.d.ts.map +1 -0
- package/dist/plugin-inline-directives.js +121 -0
- package/dist/plugin-inline-directives.js.map +1 -0
- package/dist/serialize.d.ts +25 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +712 -0
- package/dist/serialize.js.map +1 -0
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/yaml.d.ts +22 -0
- package/dist/yaml.d.ts.map +1 -0
- package/dist/yaml.js +113 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an `{...}` attribute block body into structured attrs.
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* #id → id
|
|
6
|
+
* .class → class append
|
|
7
|
+
* key="value" → quoted prop
|
|
8
|
+
* key=value → unquoted bareword prop
|
|
9
|
+
* key → boolean true
|
|
10
|
+
*
|
|
11
|
+
* Whitespace-separated. Values with spaces must be quoted.
|
|
12
|
+
*/
|
|
13
|
+
export interface ParsedAttrs {
|
|
14
|
+
id?: string;
|
|
15
|
+
classes: string[];
|
|
16
|
+
props: Record<string, string | boolean>;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseAttrs(inner: string): ParsedAttrs;
|
|
19
|
+
/**
|
|
20
|
+
* Merge ParsedAttrs into a props dict suitable for TreeNode.props.
|
|
21
|
+
* `id` and `classes` become `id` and `class`; other props flow through.
|
|
22
|
+
*/
|
|
23
|
+
export declare function attrsToProps(attrs: ParsedAttrs): Record<string, unknown>;
|
|
24
|
+
//# sourceMappingURL=parse-attrs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-attrs.d.ts","sourceRoot":"","sources":["../src/parse-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CACzC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAgFrD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQxE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an `{...}` attribute block body into structured attrs.
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* #id → id
|
|
6
|
+
* .class → class append
|
|
7
|
+
* key="value" → quoted prop
|
|
8
|
+
* key=value → unquoted bareword prop
|
|
9
|
+
* key → boolean true
|
|
10
|
+
*
|
|
11
|
+
* Whitespace-separated. Values with spaces must be quoted.
|
|
12
|
+
*/
|
|
13
|
+
export function parseAttrs(inner) {
|
|
14
|
+
const result = { classes: [], props: {} };
|
|
15
|
+
let pos = 0;
|
|
16
|
+
const len = inner.length;
|
|
17
|
+
while (pos < len) {
|
|
18
|
+
// Skip whitespace
|
|
19
|
+
while (pos < len && /\s/.test(inner[pos]))
|
|
20
|
+
pos++;
|
|
21
|
+
if (pos >= len)
|
|
22
|
+
break;
|
|
23
|
+
const ch = inner[pos];
|
|
24
|
+
if (ch === "#") {
|
|
25
|
+
// ID
|
|
26
|
+
pos++;
|
|
27
|
+
const start = pos;
|
|
28
|
+
while (pos < len && !/[\s=}]/.test(inner[pos]))
|
|
29
|
+
pos++;
|
|
30
|
+
result.id = inner.slice(start, pos);
|
|
31
|
+
}
|
|
32
|
+
else if (ch === ".") {
|
|
33
|
+
// Class
|
|
34
|
+
pos++;
|
|
35
|
+
const start = pos;
|
|
36
|
+
while (pos < len && !/[\s=}]/.test(inner[pos]))
|
|
37
|
+
pos++;
|
|
38
|
+
const cls = inner.slice(start, pos);
|
|
39
|
+
if (cls)
|
|
40
|
+
result.classes.push(cls);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// key=value or bare key
|
|
44
|
+
const keyStart = pos;
|
|
45
|
+
while (pos < len && !/[\s=}]/.test(inner[pos]))
|
|
46
|
+
pos++;
|
|
47
|
+
const key = inner.slice(keyStart, pos);
|
|
48
|
+
if (!key) {
|
|
49
|
+
pos++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (inner[pos] !== "=") {
|
|
53
|
+
// Boolean prop
|
|
54
|
+
result.props[key] = true;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
pos++; // consume =
|
|
58
|
+
// Read value
|
|
59
|
+
if (pos >= len)
|
|
60
|
+
break;
|
|
61
|
+
if (inner[pos] === '"') {
|
|
62
|
+
// Quoted value
|
|
63
|
+
pos++;
|
|
64
|
+
const valStart = pos;
|
|
65
|
+
let value = "";
|
|
66
|
+
while (pos < len && inner[pos] !== '"') {
|
|
67
|
+
if (inner[pos] === "\\" && pos + 1 < len) {
|
|
68
|
+
value += inner[pos + 1];
|
|
69
|
+
pos += 2;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
value += inner[pos];
|
|
73
|
+
pos++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (pos < len)
|
|
77
|
+
pos++; // consume closing "
|
|
78
|
+
result.props[key] = value;
|
|
79
|
+
void valStart;
|
|
80
|
+
}
|
|
81
|
+
else if (inner[pos] === "'") {
|
|
82
|
+
// Single-quoted value
|
|
83
|
+
pos++;
|
|
84
|
+
const valStart = pos;
|
|
85
|
+
while (pos < len && inner[pos] !== "'")
|
|
86
|
+
pos++;
|
|
87
|
+
result.props[key] = inner.slice(valStart, pos);
|
|
88
|
+
if (pos < len)
|
|
89
|
+
pos++;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Bareword value
|
|
93
|
+
const valStart = pos;
|
|
94
|
+
while (pos < len && !/[\s}]/.test(inner[pos]))
|
|
95
|
+
pos++;
|
|
96
|
+
result.props[key] = inner.slice(valStart, pos);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Merge ParsedAttrs into a props dict suitable for TreeNode.props.
|
|
104
|
+
* `id` and `classes` become `id` and `class`; other props flow through.
|
|
105
|
+
*/
|
|
106
|
+
export function attrsToProps(attrs) {
|
|
107
|
+
const props = {};
|
|
108
|
+
if (attrs.id)
|
|
109
|
+
props.id = attrs.id;
|
|
110
|
+
if (attrs.classes.length > 0)
|
|
111
|
+
props.class = attrs.classes.join(" ");
|
|
112
|
+
for (const [k, v] of Object.entries(attrs.props)) {
|
|
113
|
+
props[k] = v;
|
|
114
|
+
}
|
|
115
|
+
return props;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=parse-attrs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-attrs.js","sourceRoot":"","sources":["../src/parse-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,MAAM,MAAM,GAAgB,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACvD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC;IAEzB,OAAO,GAAG,GAAG,GAAG,EAAE,CAAC;QACjB,kBAAkB;QAClB,OAAO,GAAG,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAAE,GAAG,EAAE,CAAC;QACjD,IAAI,GAAG,IAAI,GAAG;YAAE,MAAM;QAEtB,MAAM,EAAE,GAAG,KAAK,CA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G,GAAG;oBAAE,GAAG,EAAE,CAAC;YACvB,CAAC;iBAAM,CAAC;gBACN,iBAAiB;gBACjB,MAAM,QAAQ,GAAG,GAAG,CAAC;gBACrB,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAAE,GAAG,EAAE,CAAC;gBACrD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,IAAI,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpE,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TreeNode, InlineNode } from "@dogsbay/types";
|
|
2
|
+
export interface ParseResult {
|
|
3
|
+
tree: TreeNode[];
|
|
4
|
+
frontmatter: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface ParseOptions {
|
|
7
|
+
/** Strip surrounding whitespace from block content. Default: true */
|
|
8
|
+
trimContent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Parse Dogsbay Markdown into TreeNode[] plus extracted frontmatter.
|
|
12
|
+
*/
|
|
13
|
+
export declare function dogsbayMdToTree(source: string, _options?: ParseOptions): ParseResult;
|
|
14
|
+
/**
|
|
15
|
+
* Parse a single inline string to InlineNode[] (useful for testing).
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseInline(source: string): InlineNode[];
|
|
18
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAS3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,CAkBpF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE,CAKxD"}
|