@jasonbelmonti/markdown-engine 0.1.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.
Files changed (165) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +21 -0
  3. package/README.md +118 -0
  4. package/SECURITY.md +28 -0
  5. package/dist/api/contracts.d.ts +8 -0
  6. package/dist/api/contracts.d.ts.map +1 -0
  7. package/dist/api/contracts.js +7 -0
  8. package/dist/api/contracts.js.map +1 -0
  9. package/dist/api/diagnostics.d.ts +18 -0
  10. package/dist/api/diagnostics.d.ts.map +1 -0
  11. package/dist/api/diagnostics.js +2 -0
  12. package/dist/api/diagnostics.js.map +1 -0
  13. package/dist/api/document.d.ts +17 -0
  14. package/dist/api/document.d.ts.map +1 -0
  15. package/dist/api/document.js +2 -0
  16. package/dist/api/document.js.map +1 -0
  17. package/dist/api/normalize.d.ts +13 -0
  18. package/dist/api/normalize.d.ts.map +1 -0
  19. package/dist/api/normalize.js +7 -0
  20. package/dist/api/normalize.js.map +1 -0
  21. package/dist/api/parse.d.ts +20 -0
  22. package/dist/api/parse.d.ts.map +1 -0
  23. package/dist/api/parse.js +46 -0
  24. package/dist/api/parse.js.map +1 -0
  25. package/dist/api/serialize.d.ts +10 -0
  26. package/dist/api/serialize.d.ts.map +1 -0
  27. package/dist/api/serialize.js +18 -0
  28. package/dist/api/serialize.js.map +1 -0
  29. package/dist/api/validate.d.ts +21 -0
  30. package/dist/api/validate.d.ts.map +1 -0
  31. package/dist/api/validate.js +21 -0
  32. package/dist/api/validate.js.map +1 -0
  33. package/dist/config/index.d.ts +8 -0
  34. package/dist/config/index.d.ts.map +1 -0
  35. package/dist/config/index.js +53 -0
  36. package/dist/config/index.js.map +1 -0
  37. package/dist/diagnostics/index.d.ts +6 -0
  38. package/dist/diagnostics/index.d.ts.map +1 -0
  39. package/dist/diagnostics/index.js +27 -0
  40. package/dist/diagnostics/index.js.map +1 -0
  41. package/dist/frontmatter/adapter.d.ts +3 -0
  42. package/dist/frontmatter/adapter.d.ts.map +1 -0
  43. package/dist/frontmatter/adapter.js +20 -0
  44. package/dist/frontmatter/adapter.js.map +1 -0
  45. package/dist/frontmatter/extract.d.ts +3 -0
  46. package/dist/frontmatter/extract.d.ts.map +1 -0
  47. package/dist/frontmatter/extract.js +104 -0
  48. package/dist/frontmatter/extract.js.map +1 -0
  49. package/dist/frontmatter/index.d.ts +3 -0
  50. package/dist/frontmatter/index.d.ts.map +1 -0
  51. package/dist/frontmatter/index.js +2 -0
  52. package/dist/frontmatter/index.js.map +1 -0
  53. package/dist/frontmatter/types.d.ts +14 -0
  54. package/dist/frontmatter/types.d.ts.map +1 -0
  55. package/dist/frontmatter/types.js +2 -0
  56. package/dist/frontmatter/types.js.map +1 -0
  57. package/dist/frontmatter/yaml-diagnostics.d.ts +13 -0
  58. package/dist/frontmatter/yaml-diagnostics.d.ts.map +1 -0
  59. package/dist/frontmatter/yaml-diagnostics.js +117 -0
  60. package/dist/frontmatter/yaml-diagnostics.js.map +1 -0
  61. package/dist/frontmatter/yaml-json.d.ts +13 -0
  62. package/dist/frontmatter/yaml-json.d.ts.map +1 -0
  63. package/dist/frontmatter/yaml-json.js +94 -0
  64. package/dist/frontmatter/yaml-json.js.map +1 -0
  65. package/dist/frontmatter/yaml-key-policy.d.ts +3 -0
  66. package/dist/frontmatter/yaml-key-policy.d.ts.map +1 -0
  67. package/dist/frontmatter/yaml-key-policy.js +29 -0
  68. package/dist/frontmatter/yaml-key-policy.js.map +1 -0
  69. package/dist/frontmatter/yaml-options.d.ts +6 -0
  70. package/dist/frontmatter/yaml-options.d.ts.map +1 -0
  71. package/dist/frontmatter/yaml-options.js +20 -0
  72. package/dist/frontmatter/yaml-options.js.map +1 -0
  73. package/dist/frontmatter/yaml.d.ts +9 -0
  74. package/dist/frontmatter/yaml.d.ts.map +1 -0
  75. package/dist/frontmatter/yaml.js +59 -0
  76. package/dist/frontmatter/yaml.js.map +1 -0
  77. package/dist/index.d.ts +2 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +2 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/internal/plain-record.d.ts +3 -0
  82. package/dist/internal/plain-record.d.ts.map +1 -0
  83. package/dist/internal/plain-record.js +11 -0
  84. package/dist/internal/plain-record.js.map +1 -0
  85. package/dist/ir/document.d.ts +5 -0
  86. package/dist/ir/document.d.ts.map +1 -0
  87. package/dist/ir/document.js +56 -0
  88. package/dist/ir/document.js.map +1 -0
  89. package/dist/ir/index.d.ts +2 -0
  90. package/dist/ir/index.d.ts.map +1 -0
  91. package/dist/ir/index.js +2 -0
  92. package/dist/ir/index.js.map +1 -0
  93. package/dist/parser/adapter.d.ts +3 -0
  94. package/dist/parser/adapter.d.ts.map +1 -0
  95. package/dist/parser/adapter.js +33 -0
  96. package/dist/parser/adapter.js.map +1 -0
  97. package/dist/parser/engine-document.d.ts +6 -0
  98. package/dist/parser/engine-document.d.ts.map +1 -0
  99. package/dist/parser/engine-document.js +192 -0
  100. package/dist/parser/engine-document.js.map +1 -0
  101. package/dist/parser/index.d.ts +3 -0
  102. package/dist/parser/index.d.ts.map +1 -0
  103. package/dist/parser/index.js +2 -0
  104. package/dist/parser/index.js.map +1 -0
  105. package/dist/parser/mdast.d.ts +30 -0
  106. package/dist/parser/mdast.d.ts.map +1 -0
  107. package/dist/parser/mdast.js +2 -0
  108. package/dist/parser/mdast.js.map +1 -0
  109. package/dist/parser/types.d.ts +14 -0
  110. package/dist/parser/types.d.ts.map +1 -0
  111. package/dist/parser/types.js +2 -0
  112. package/dist/parser/types.js.map +1 -0
  113. package/dist/rules/code-fence-languages-config.d.ts +11 -0
  114. package/dist/rules/code-fence-languages-config.d.ts.map +1 -0
  115. package/dist/rules/code-fence-languages-config.js +38 -0
  116. package/dist/rules/code-fence-languages-config.js.map +1 -0
  117. package/dist/rules/code-fence-languages.d.ts +5 -0
  118. package/dist/rules/code-fence-languages.d.ts.map +1 -0
  119. package/dist/rules/code-fence-languages.js +44 -0
  120. package/dist/rules/code-fence-languages.js.map +1 -0
  121. package/dist/rules/document-query.d.ts +5 -0
  122. package/dist/rules/document-query.d.ts.map +1 -0
  123. package/dist/rules/document-query.js +21 -0
  124. package/dist/rules/document-query.js.map +1 -0
  125. package/dist/rules/headings-required-config.d.ts +10 -0
  126. package/dist/rules/headings-required-config.d.ts.map +1 -0
  127. package/dist/rules/headings-required-config.js +24 -0
  128. package/dist/rules/headings-required-config.js.map +1 -0
  129. package/dist/rules/headings-required.d.ts +5 -0
  130. package/dist/rules/headings-required.d.ts.map +1 -0
  131. package/dist/rules/headings-required.js +21 -0
  132. package/dist/rules/headings-required.js.map +1 -0
  133. package/dist/rules/index.d.ts +12 -0
  134. package/dist/rules/index.d.ts.map +1 -0
  135. package/dist/rules/index.js +42 -0
  136. package/dist/rules/index.js.map +1 -0
  137. package/dist/rules/links-allowed-schemes-config.d.ts +10 -0
  138. package/dist/rules/links-allowed-schemes-config.d.ts.map +1 -0
  139. package/dist/rules/links-allowed-schemes-config.js +24 -0
  140. package/dist/rules/links-allowed-schemes-config.js.map +1 -0
  141. package/dist/rules/links-allowed-schemes.d.ts +5 -0
  142. package/dist/rules/links-allowed-schemes.d.ts.map +1 -0
  143. package/dist/rules/links-allowed-schemes.js +32 -0
  144. package/dist/rules/links-allowed-schemes.js.map +1 -0
  145. package/dist/rules/raw-html-policy-config.d.ts +9 -0
  146. package/dist/rules/raw-html-policy-config.d.ts.map +1 -0
  147. package/dist/rules/raw-html-policy-config.js +20 -0
  148. package/dist/rules/raw-html-policy-config.js.map +1 -0
  149. package/dist/rules/raw-html-policy.d.ts +5 -0
  150. package/dist/rules/raw-html-policy.d.ts.map +1 -0
  151. package/dist/rules/raw-html-policy.js +29 -0
  152. package/dist/rules/raw-html-policy.js.map +1 -0
  153. package/dist/rules/required-frontmatter-config.d.ts +10 -0
  154. package/dist/rules/required-frontmatter-config.d.ts.map +1 -0
  155. package/dist/rules/required-frontmatter-config.js +24 -0
  156. package/dist/rules/required-frontmatter-config.js.map +1 -0
  157. package/dist/rules/required-frontmatter.d.ts +5 -0
  158. package/dist/rules/required-frontmatter.d.ts.map +1 -0
  159. package/dist/rules/required-frontmatter.js +21 -0
  160. package/dist/rules/required-frontmatter.js.map +1 -0
  161. package/dist/rules/rule-config.d.ts +15 -0
  162. package/dist/rules/rule-config.d.ts.map +1 -0
  163. package/dist/rules/rule-config.js +32 -0
  164. package/dist/rules/rule-config.js.map +1 -0
  165. package/package.json +62 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2026-05-01
4
+
5
+ Initial public release candidate for `@jasonbelmonti/markdown-engine`.
6
+
7
+ ### Added
8
+
9
+ - Public package root exports for `parse`, `normalize`, `validate`, and
10
+ `serialize`.
11
+ - Engine-owned normalized Markdown document and node contracts.
12
+ - YAML frontmatter extraction with JSON-safe materialization and structured
13
+ diagnostics.
14
+ - Deterministic validation rule families:
15
+ - `frontmatter.required`
16
+ - `headings.required`
17
+ - `codeFences.languages`
18
+ - `links.allowedSchemes`
19
+ - `rawHtml.policy`
20
+ - Stable JSON serialization for public parse, normalize, and validation
21
+ results.
22
+ - Parser/frontmatter fixtures, cmark-gfm comparison coverage, deterministic
23
+ repeatability proof, and dependency boundary audit tooling.
24
+
25
+ ### Release Status
26
+
27
+ This version is prepared as the first public package version. Publication still
28
+ requires MS-3 approval, downstream confirmation or owner waiver, final
29
+ release-candidate validation, and npm publish verification.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason Belmonti
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,118 @@
1
+ # @jasonbelmonti/markdown-engine
2
+
3
+ Deterministic Markdown parsing and validation engine package for downstream
4
+ profile and runtime work.
5
+
6
+ Current release candidate:
7
+
8
+ - package name: `@jasonbelmonti/markdown-engine`
9
+ - version: `0.1.0`
10
+ - release status: package metadata is public-release-ready; package tag and
11
+ npm publication still require MS-3 approval
12
+
13
+ ## Scope
14
+
15
+ `@jasonbelmonti/markdown-engine` owns the deterministic engine boundary:
16
+
17
+ - parse GFM Markdown and YAML frontmatter
18
+ - normalize parser output into engine-owned IR
19
+ - validate deterministic declarative rules
20
+ - emit structured diagnostics
21
+ - serialize public results with stable JSON key ordering
22
+
23
+ Out of scope for this package: profile compiler behavior, runtime lenses, MCP
24
+ transport, agent adapters, semantic or LLM evaluation, arbitrary rule plugins,
25
+ network services, persistence, and raw parser AST as a public contract.
26
+
27
+ ## Public API
28
+
29
+ The package root exports:
30
+
31
+ - `parse(markdown, options?)`
32
+ - `normalize(parsed, options?)`
33
+ - `validate(document, config?, options?)`
34
+ - `serialize(result, options?)`
35
+
36
+ Example:
37
+
38
+ ```ts
39
+ import {
40
+ normalize,
41
+ parse,
42
+ serialize,
43
+ validate,
44
+ } from "@jasonbelmonti/markdown-engine";
45
+
46
+ const markdown = `---
47
+ title: Mission Brief
48
+ owner: docs
49
+ ---
50
+
51
+ # Mission Brief
52
+
53
+ \`\`\`ts
54
+ const ready = true;
55
+ \`\`\`
56
+ `;
57
+
58
+ const parseResult = parse(markdown, { path: "mission.md" });
59
+ const normalizeResult = normalize(parseResult.parsed);
60
+ const validationResult = validate(normalizeResult.document, {
61
+ rules: {
62
+ "frontmatter.required": { fields: ["title", "owner"] },
63
+ "headings.required": { headings: ["Mission Brief"] },
64
+ "codeFences.languages": {
65
+ allowed: ["ts"],
66
+ requireLanguage: true,
67
+ },
68
+ },
69
+ });
70
+
71
+ console.log(validationResult.valid);
72
+ console.log(serialize(validationResult, { pretty: true }));
73
+ ```
74
+
75
+ Contract references:
76
+
77
+ - [Public API contract](docs/contracts/api.md)
78
+ - [Frontmatter contract](docs/contracts/frontmatter.md)
79
+ - [Changelog](CHANGELOG.md)
80
+ - [Security policy](SECURITY.md)
81
+
82
+ ## Validation
83
+
84
+ Run the release-readiness gates from the repository root:
85
+
86
+ ```sh
87
+ npm run release:verify
88
+ npm pack --dry-run
89
+ npm publish --dry-run --access public
90
+ ```
91
+
92
+ The WP-6 validation record is:
93
+
94
+ - [EVD-7 release readiness](docs/evidence/wp-6-evd-7-release-readiness.md)
95
+ - [EVD-9 merge readiness](docs/evidence/wp-6-evd-9-merge-readiness.md)
96
+ - [EVD-10 rollback containment](docs/evidence/wp-6-evd-10-rollback-containment.md)
97
+ - [EVD-11 downstream handoff](docs/evidence/wp-6-evd-11-downstream-handoff.md)
98
+
99
+ ## Release Gate
100
+
101
+ Do not tag or publish this package until MS-3 approval is recorded with:
102
+
103
+ - semver classification and package version decision
104
+ - release/tag decision
105
+ - rollback and containment notes
106
+ - downstream profile/runtime consumer confirmation
107
+ - complete evidence links from EVD-1 through EVD-11
108
+
109
+ When MS-3 is approved, publish the package as:
110
+
111
+ ```sh
112
+ npm publish --access public
113
+ ```
114
+
115
+ The publish path is guarded by npm lifecycle scripts: `prepublishOnly` and
116
+ `prepack` both run the release verification gate before `npm publish` or
117
+ `npm pack` creates an artifact. The gate rebuilds `dist` and fails if tracked
118
+ files drift from `HEAD`.
package/SECURITY.md ADDED
@@ -0,0 +1,28 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ `@jasonbelmonti/markdown-engine` is pre-1.0 software. Security fixes are
6
+ expected to target the latest published minor version unless a release note
7
+ states otherwise.
8
+
9
+ ## Reporting A Vulnerability
10
+
11
+ Report suspected vulnerabilities privately by emailing
12
+ jasonbelmonti@gmail.com. Include:
13
+
14
+ - affected package version
15
+ - reproduction steps or input Markdown/config
16
+ - expected and observed behavior
17
+ - any known impact or workaround
18
+
19
+ Do not publish exploit details publicly until a fix or mitigation plan is
20
+ available.
21
+
22
+ ## Scope
23
+
24
+ This package parses Markdown and YAML frontmatter, normalizes engine-owned IR,
25
+ evaluates deterministic validation rules, and serializes public result objects.
26
+
27
+ It does not execute raw HTML, fetch network resources, call LLM providers,
28
+ run plugins, start services, persist data, or evaluate semantic rules.
@@ -0,0 +1,8 @@
1
+ export type MarkdownEngineApiName = "parse" | "normalize" | "validate" | "serialize";
2
+ export * from "./diagnostics.js";
3
+ export * from "./document.js";
4
+ export * from "./normalize.js";
5
+ export * from "./parse.js";
6
+ export * from "./serialize.js";
7
+ export * from "./validate.js";
8
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAErF,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./diagnostics.js";
2
+ export * from "./document.js";
3
+ export * from "./normalize.js";
4
+ export * from "./parse.js";
5
+ export * from "./serialize.js";
6
+ export * from "./validate.js";
7
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../src/api/contracts.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,18 @@
1
+ export type MarkdownDiagnosticSeverity = "error" | "warning" | "info";
2
+ export interface SourcePosition {
3
+ line: number;
4
+ column: number;
5
+ offset?: number;
6
+ }
7
+ export interface SourceRange {
8
+ start: SourcePosition;
9
+ end: SourcePosition;
10
+ }
11
+ export interface MarkdownDiagnostic {
12
+ code: string;
13
+ ruleId?: string;
14
+ message: string;
15
+ severity: MarkdownDiagnosticSeverity;
16
+ sourceRange?: SourceRange;
17
+ }
18
+ //# sourceMappingURL=diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/api/diagnostics.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,cAAc,CAAC;IACtB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,0BAA0B,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../src/api/diagnostics.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { SourceRange } from "./diagnostics.js";
2
+ export interface EngineNode {
3
+ type: string;
4
+ text?: string;
5
+ attributes?: Record<string, unknown>;
6
+ sourceRange?: SourceRange;
7
+ children?: EngineNode[];
8
+ }
9
+ export interface EngineDocument {
10
+ kind: "markdown-document";
11
+ version: "0.0.0";
12
+ path?: string;
13
+ frontmatter?: unknown;
14
+ children: EngineNode[];
15
+ sourceRange?: SourceRange;
16
+ }
17
+ //# sourceMappingURL=document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/api/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/api/document.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import type { MarkdownDiagnostic } from "./diagnostics.js";
2
+ import type { EngineDocument } from "./document.js";
3
+ import type { ParsedMarkdown } from "./parse.js";
4
+ export interface NormalizeOptions {
5
+ preserveSourceLocations?: boolean;
6
+ }
7
+ export interface NormalizeResult {
8
+ document: EngineDocument;
9
+ diagnostics: MarkdownDiagnostic[];
10
+ }
11
+ export type NormalizeFunction = (parsed: ParsedMarkdown, options?: NormalizeOptions) => NormalizeResult;
12
+ export declare const normalize: NormalizeFunction;
13
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/api/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,MAAM,WAAW,gBAAgB;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,gBAAgB,KACvB,eAAe,CAAC;AAErB,eAAO,MAAM,SAAS,EAAE,iBAGtB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { cloneDiagnostics } from "../diagnostics/index.js";
2
+ import { normalizeParsedMarkdown } from "../ir/index.js";
3
+ export const normalize = (parsed, options = {}) => ({
4
+ document: normalizeParsedMarkdown(parsed, options),
5
+ diagnostics: cloneDiagnostics(parsed.diagnostics),
6
+ });
7
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/api/normalize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAgBzD,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IACrE,QAAQ,EAAE,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC;IAClD,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;CAClD,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { MarkdownDiagnostic } from "./diagnostics.js";
2
+ import type { EngineDocument } from "./document.js";
3
+ export interface ParseOptions {
4
+ path?: string;
5
+ }
6
+ export interface ParsedMarkdown {
7
+ markdown: string;
8
+ body: string;
9
+ path?: string;
10
+ frontmatter?: unknown;
11
+ document: EngineDocument;
12
+ diagnostics: MarkdownDiagnostic[];
13
+ }
14
+ export interface ParseResult {
15
+ parsed: ParsedMarkdown;
16
+ diagnostics: MarkdownDiagnostic[];
17
+ }
18
+ export type ParseFunction = (markdown: string, options?: ParseOptions) => ParseResult;
19
+ export declare const parse: ParseFunction;
20
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/api/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAKpD,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,KACnB,WAAW,CAAC;AAEjB,eAAO,MAAM,KAAK,EAAE,aAiCnB,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { parseFrontmatter } from "../frontmatter/index.js";
2
+ import { parseMarkdownBody } from "../parser/index.js";
3
+ export const parse = (markdown, options = {}) => {
4
+ const frontmatterResult = parseFrontmatter(markdown);
5
+ const parserOptions = {
6
+ ...(options.path !== undefined ? { path: options.path } : {}),
7
+ lineOffset: frontmatterResult.bodyStart.line - 1,
8
+ columnOffset: frontmatterResult.bodyStart.column - 1,
9
+ ...(frontmatterResult.bodyStart.offset !== undefined
10
+ ? { offsetOffset: frontmatterResult.bodyStart.offset }
11
+ : {}),
12
+ };
13
+ const bodyResult = parseMarkdownBody(frontmatterResult.body, parserOptions);
14
+ const diagnostics = [
15
+ ...frontmatterResult.diagnostics,
16
+ ...bodyResult.diagnostics,
17
+ ];
18
+ const frontmatter = parsedFrontmatterValue(frontmatterResult.frontmatter);
19
+ const document = {
20
+ ...bodyResult.document,
21
+ ...(frontmatter.hasValue ? { frontmatter: frontmatter.value } : {}),
22
+ };
23
+ const parsed = {
24
+ markdown,
25
+ body: frontmatterResult.body,
26
+ ...(options.path !== undefined ? { path: options.path } : {}),
27
+ ...(frontmatter.hasValue ? { frontmatter: frontmatter.value } : {}),
28
+ document,
29
+ diagnostics,
30
+ };
31
+ return {
32
+ parsed,
33
+ diagnostics,
34
+ };
35
+ };
36
+ function parsedFrontmatterValue(block) {
37
+ const hasValue = block !== undefined && Object.prototype.hasOwnProperty.call(block, "value");
38
+ if (hasValue) {
39
+ return {
40
+ hasValue: true,
41
+ value: block.value,
42
+ };
43
+ }
44
+ return { hasValue: false };
45
+ }
46
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/api/parse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAyBvD,MAAM,CAAC,MAAM,KAAK,GAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IAC7D,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACrD,MAAM,aAAa,GAAG;QACpB,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,UAAU,EAAE,iBAAiB,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC;QAChD,YAAY,EAAE,iBAAiB,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACpD,GAAG,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,KAAK,SAAS;YAClD,CAAC,CAAC,EAAE,YAAY,EAAE,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE;YACtD,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IACF,MAAM,UAAU,GAAG,iBAAiB,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC5E,MAAM,WAAW,GAAG;QAClB,GAAG,iBAAiB,CAAC,WAAW;QAChC,GAAG,UAAU,CAAC,WAAW;KAC1B,CAAC;IACF,MAAM,WAAW,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAmB;QAC/B,GAAG,UAAU,CAAC,QAAQ;QACtB,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpE,CAAC;IACF,MAAM,MAAM,GAAmB;QAC7B,QAAQ;QACR,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,QAAQ;QACR,WAAW;KACZ,CAAC;IAEF,OAAO;QACL,MAAM;QACN,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,sBAAsB,CAC7B,KAAmC;IAEnC,MAAM,QAAQ,GACZ,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE9E,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO;YACL,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { NormalizeResult } from "./normalize.js";
2
+ import type { ParseResult } from "./parse.js";
3
+ import type { ValidationResult } from "./validate.js";
4
+ export type SerializableMarkdownEngineResult = ParseResult | NormalizeResult | ValidationResult;
5
+ export interface SerializeOptions {
6
+ pretty?: boolean;
7
+ }
8
+ export type SerializeFunction = (result: SerializableMarkdownEngineResult, options?: SerializeOptions) => string;
9
+ export declare const serialize: SerializeFunction;
10
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,MAAM,MAAM,gCAAgC,GACxC,WAAW,GACX,eAAe,GACf,gBAAgB,CAAC;AAErB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,MAAM,EAAE,gCAAgC,EACxC,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,CAAC;AAEZ,eAAO,MAAM,SAAS,EAAE,iBAQvB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { isPlainRecord } from "../internal/plain-record.js";
2
+ export const serialize = (result, options = {}) => {
3
+ const serialized = JSON.stringify(normalizeSerializableValue(result), null, options.pretty === true ? 2 : 0);
4
+ return serialized ?? "null";
5
+ };
6
+ function normalizeSerializableValue(value) {
7
+ if (Array.isArray(value)) {
8
+ return value.map((item) => normalizeSerializableValue(item));
9
+ }
10
+ if (isPlainRecord(value)) {
11
+ return Object.fromEntries(Object.keys(value)
12
+ .filter((key) => value[key] !== undefined)
13
+ .sort()
14
+ .map((key) => [key, normalizeSerializableValue(value[key])]));
15
+ }
16
+ return value;
17
+ }
18
+ //# sourceMappingURL=serialize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../src/api/serialize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAgB5D,MAAM,CAAC,MAAM,SAAS,GAAsB,CAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE;IACnE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAC/B,0BAA0B,CAAC,MAAM,CAAC,EAClC,IAAI,EACJ,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAChC,CAAC;IAEF,OAAO,UAAU,IAAI,MAAM,CAAC;AAC9B,CAAC,CAAC;AAEF,SAAS,0BAA0B,CAAC,KAAc;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;aACf,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;aACzC,IAAI,EAAE;aACN,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,0BAA0B,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { MarkdownDiagnostic } from "./diagnostics.js";
2
+ import type { EngineDocument } from "./document.js";
3
+ export interface ValidationConfig {
4
+ rules?: Record<string, unknown>;
5
+ }
6
+ export interface ValidateOptions {
7
+ path?: string;
8
+ }
9
+ export interface ValidationRuleResult {
10
+ ruleId: string;
11
+ passed: boolean;
12
+ diagnostics: MarkdownDiagnostic[];
13
+ }
14
+ export interface ValidationResult {
15
+ valid: boolean;
16
+ diagnostics: MarkdownDiagnostic[];
17
+ ruleResults: ValidationRuleResult[];
18
+ }
19
+ export type ValidateFunction = (document: EngineDocument, config?: ValidationConfig, options?: ValidateOptions) => ValidationResult;
20
+ export declare const validate: ValidateFunction;
21
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/api/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAKpD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED,MAAM,MAAM,gBAAgB,GAAG,CAC7B,QAAQ,EAAE,cAAc,EACxB,MAAM,CAAC,EAAE,gBAAgB,EACzB,OAAO,CAAC,EAAE,eAAe,KACtB,gBAAgB,CAAC;AAEtB,eAAO,MAAM,QAAQ,EAAE,gBAqBtB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { loadValidationConfig } from "../config/index.js";
2
+ import { cloneDiagnostics, hasErrorDiagnostic } from "../diagnostics/index.js";
3
+ import { evaluateConfiguredRules } from "../rules/index.js";
4
+ export const validate = (document, config = {}, _options = {}) => {
5
+ const loadedConfig = loadValidationConfig(config);
6
+ const ruleResults = evaluateConfiguredRules(document, loadedConfig.rules);
7
+ const diagnostics = [
8
+ ...loadedConfig.diagnostics,
9
+ ...ruleResults.flatMap((result) => result.diagnostics),
10
+ ];
11
+ return {
12
+ valid: !hasErrorDiagnostic(diagnostics),
13
+ diagnostics: cloneDiagnostics(diagnostics),
14
+ ruleResults: ruleResults.map((result) => ({
15
+ ruleId: result.ruleId,
16
+ passed: result.passed,
17
+ diagnostics: cloneDiagnostics(result.diagnostics),
18
+ })),
19
+ };
20
+ };
21
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/api/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AA4B5D,MAAM,CAAC,MAAM,QAAQ,GAAqB,CACxC,QAAQ,EACR,MAAM,GAAG,EAAE,EACX,QAAQ,GAAG,EAAE,EACb,EAAE;IACF,MAAM,YAAY,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,WAAW,GAAG,uBAAuB,CAAC,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAC1E,MAAM,WAAW,GAAG;QAClB,GAAG,YAAY,CAAC,WAAW;QAC3B,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC;KACvD,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,CAAC,kBAAkB,CAAC,WAAW,CAAC;QACvC,WAAW,EAAE,gBAAgB,CAAC,WAAW,CAAC;QAC1C,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;SAClD,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { MarkdownDiagnostic } from "../api/diagnostics.js";
2
+ import { type SupportedValidationRuleConfig } from "../rules/index.js";
3
+ export interface LoadedValidationConfig {
4
+ rules: SupportedValidationRuleConfig[];
5
+ diagnostics: MarkdownDiagnostic[];
6
+ }
7
+ export declare function loadValidationConfig(config?: unknown): LoadedValidationConfig;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,6BAA6B,EAAE,CAAC;IACvC,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,wBAAgB,oBAAoB,CAClC,MAAM,GAAE,OAAY,GACnB,sBAAsB,CA2DxB"}
@@ -0,0 +1,53 @@
1
+ import { makeDiagnostic } from "../diagnostics/index.js";
2
+ import { isPlainRecord } from "../internal/plain-record.js";
3
+ import { parseValidationRuleConfig, } from "../rules/index.js";
4
+ export function loadValidationConfig(config = {}) {
5
+ if (!isPlainRecord(config)) {
6
+ return {
7
+ rules: [],
8
+ diagnostics: [
9
+ makeDiagnostic({
10
+ code: "config.invalid",
11
+ message: "Validation config must be an object.",
12
+ severity: "error",
13
+ }),
14
+ ],
15
+ };
16
+ }
17
+ const rules = config.rules;
18
+ if (rules === undefined) {
19
+ return { rules: [], diagnostics: [] };
20
+ }
21
+ if (!isPlainRecord(rules)) {
22
+ return {
23
+ rules: [],
24
+ diagnostics: [
25
+ makeDiagnostic({
26
+ code: "config.rules.invalid",
27
+ message: "Validation config rules must be an object.",
28
+ severity: "error",
29
+ }),
30
+ ],
31
+ };
32
+ }
33
+ const loaded = { rules: [], diagnostics: [] };
34
+ for (const [ruleId, ruleConfig] of Object.entries(rules)) {
35
+ const parsed = parseValidationRuleConfig(ruleId, ruleConfig);
36
+ if (parsed === undefined) {
37
+ loaded.diagnostics.push(makeDiagnostic({
38
+ code: "config.rule.unsupported",
39
+ ruleId,
40
+ message: `Unsupported validation rule "${ruleId}".`,
41
+ severity: "error",
42
+ }));
43
+ continue;
44
+ }
45
+ if (parsed.diagnostic !== undefined) {
46
+ loaded.diagnostics.push(parsed.diagnostic);
47
+ continue;
48
+ }
49
+ loaded.rules.push(parsed.rule);
50
+ }
51
+ return loaded;
52
+ }
53
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,yBAAyB,GAE1B,MAAM,mBAAmB,CAAC;AAO3B,MAAM,UAAU,oBAAoB,CAClC,SAAkB,EAAE;IAEpB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,OAAO;YACL,KAAK,EAAE,EAAE;YACT,WAAW,EAAE;gBACX,cAAc,CAAC;oBACb,IAAI,EAAE,gBAAgB;oBACtB,OAAO,EAAE,sCAAsC;oBAC/C,QAAQ,EAAE,OAAO;iBAClB,CAAC;aACH;SACF,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAE3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,KAAK,EAAE,EAAE;YACT,WAAW,EAAE;gBACX,cAAc,CAAC;oBACb,IAAI,EAAE,sBAAsB;oBAC5B,OAAO,EAAE,4CAA4C;oBACrD,QAAQ,EAAE,OAAO;iBAClB,CAAC;aACH;SACF,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAA2B,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IAEtE,KAAK,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,yBAAyB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAE7D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,CAAC,WAAW,CAAC,IAAI,CACrB,cAAc,CAAC;gBACb,IAAI,EAAE,yBAAyB;gBAC/B,MAAM;gBACN,OAAO,EAAE,gCAAgC,MAAM,IAAI;gBACnD,QAAQ,EAAE,OAAO;aAClB,CAAC,CACH,CAAC;YACF,SAAS;QACX,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC3C,SAAS;QACX,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { MarkdownDiagnostic } from "../api/diagnostics.js";
2
+ export declare function makeDiagnostic(diagnostic: MarkdownDiagnostic): MarkdownDiagnostic;
3
+ export declare function cloneDiagnostics(diagnostics: readonly MarkdownDiagnostic[]): MarkdownDiagnostic[];
4
+ export declare function cloneDiagnostic(diagnostic: MarkdownDiagnostic): MarkdownDiagnostic;
5
+ export declare function hasErrorDiagnostic(diagnostics: readonly MarkdownDiagnostic[]): boolean;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,uBAAuB,CAAC;AAE7E,wBAAgB,cAAc,CAC5B,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAEpB;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,kBAAkB,EAAE,GACzC,kBAAkB,EAAE,CAEtB;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,kBAAkB,GAC7B,kBAAkB,CAUpB;AAED,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,SAAS,kBAAkB,EAAE,GACzC,OAAO,CAET"}
@@ -0,0 +1,27 @@
1
+ export function makeDiagnostic(diagnostic) {
2
+ return cloneDiagnostic(diagnostic);
3
+ }
4
+ export function cloneDiagnostics(diagnostics) {
5
+ return diagnostics.map((diagnostic) => cloneDiagnostic(diagnostic));
6
+ }
7
+ export function cloneDiagnostic(diagnostic) {
8
+ return {
9
+ code: diagnostic.code,
10
+ ...(diagnostic.ruleId !== undefined ? { ruleId: diagnostic.ruleId } : {}),
11
+ message: diagnostic.message,
12
+ severity: diagnostic.severity,
13
+ ...(diagnostic.sourceRange !== undefined
14
+ ? { sourceRange: cloneSourceRange(diagnostic.sourceRange) }
15
+ : {}),
16
+ };
17
+ }
18
+ export function hasErrorDiagnostic(diagnostics) {
19
+ return diagnostics.some((diagnostic) => diagnostic.severity === "error");
20
+ }
21
+ function cloneSourceRange(sourceRange) {
22
+ return {
23
+ start: { ...sourceRange.start },
24
+ end: { ...sourceRange.end },
25
+ };
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAC5B,UAA8B;IAE9B,OAAO,eAAe,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,WAA0C;IAE1C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,UAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,QAAQ,EAAE,UAAU,CAAC,QAAQ;QAC7B,GAAG,CAAC,UAAU,CAAC,WAAW,KAAK,SAAS;YACtC,CAAC,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;YAC3D,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,WAA0C;IAE1C,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,gBAAgB,CAAC,WAAwB;IAChD,OAAO;QACL,KAAK,EAAE,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE;QAC/B,GAAG,EAAE,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FrontmatterParseResult } from "./types.js";
2
+ export declare function parseFrontmatter(markdown: string): FrontmatterParseResult;
3
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/frontmatter/adapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAoB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAG3E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAuBzE"}
@@ -0,0 +1,20 @@
1
+ import { extractFrontmatter } from "./extract.js";
2
+ import { parseYamlFrontmatter } from "./yaml.js";
3
+ export function parseFrontmatter(markdown) {
4
+ const extracted = extractFrontmatter(markdown);
5
+ if (extracted.frontmatter === undefined) {
6
+ return extracted;
7
+ }
8
+ const parsed = parseYamlFrontmatter(extracted.frontmatter.raw, extracted.frontmatter.contentStart, extracted.frontmatter.sourceRange);
9
+ const frontmatter = {
10
+ ...extracted.frontmatter,
11
+ ...(parsed.valueParsed ? { value: parsed.value } : {}),
12
+ };
13
+ return {
14
+ body: extracted.body,
15
+ bodyStart: extracted.bodyStart,
16
+ diagnostics: [...extracted.diagnostics, ...parsed.diagnostics],
17
+ frontmatter,
18
+ };
19
+ }
20
+ //# sourceMappingURL=adapter.js.map