markdown_composer 0.7.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +278 -0
- data/ROADMAP.md +80 -0
- data/docs/_md_composer_architecture.md +50 -0
- data/docs/_md_composer_cheatsheet.md +72 -0
- data/docs/_md_composer_concepts.md +64 -0
- data/docs/_md_composer_dev_guide.md +55 -0
- data/docs/_md_composer_getting_started.md +114 -0
- data/docs/_md_composer_readme.md +93 -0
- data/docs/_md_composer_user_guide.md +65 -0
- data/docs/ai/md_composer_ai_audit.md +35 -0
- data/docs/ai/md_composer_ai_canonical_docs.md +44 -0
- data/docs/ai/md_composer_ai_source_map.md +39 -0
- data/docs/compose/md_composer_compose_actions.md +338 -0
- data/docs/compose/md_composer_compose_anatomy.md +156 -0
- data/docs/compose/md_composer_compose_buffer.md +81 -0
- data/docs/compose/md_composer_compose_examples.md +31 -0
- data/docs/compose/md_composer_compose_include.md +136 -0
- data/docs/compose/md_composer_compose_select.md +198 -0
- data/docs/compose/md_composer_compose_sources.md +161 -0
- data/docs/compose/md_composer_compose_targets.md +194 -0
- data/docs/examples/md_composer_example_basic_compose.md +57 -0
- data/docs/examples/md_composer_example_buffer_target_actions.md +83 -0
- data/docs/examples/md_composer_example_fixtures.md +62 -0
- data/docs/examples/md_composer_example_html_output.md +50 -0
- data/docs/examples/md_composer_example_modify.md +77 -0
- data/docs/examples/md_composer_example_multi_row_compose.md +67 -0
- data/docs/examples/md_composer_example_ruby_plans.md +62 -0
- data/docs/examples/md_composer_example_structured_data.md +68 -0
- data/docs/examples/md_composer_example_transforms.md +68 -0
- data/docs/examples/md_composer_example_yaml_json_rows.md +56 -0
- data/docs/examples/md_composer_examples_readme.md +45 -0
- data/docs/examples/md_composer_runnable_examples.md +374 -0
- data/docs/examples/md_composer_source_ruby_dsl.md +88 -0
- data/docs/reference/md_composer_nested.md +170 -0
- data/docs/reference/md_composer_reference_api.md +71 -0
- data/docs/reference/md_composer_reference_capabilities.md +63 -0
- data/docs/reference/md_composer_reference_diagnostics.md +54 -0
- data/docs/reference/md_composer_reference_plan_schema.md +75 -0
- data/docs/reference/md_composer_reference_registries.md +63 -0
- data/docs/reference/md_composer_take.md +221 -0
- data/docs/reference/md_composer_unit_tokens.md +228 -0
- data/docs/reference/md_composer_where.md +227 -0
- data/docs/transform/md_composer_transform_anatomy.md +112 -0
- data/docs/transform/md_composer_transform_examples.md +30 -0
- data/docs/transform/md_composer_transform_modes.md +83 -0
- data/docs/transform/md_composer_transform_options.md +142 -0
- data/docs/transform/md_composer_transform_scope.md +97 -0
- data/docs/transform/md_composer_transform_transforms.md +99 -0
- data/examples/README.md +20 -0
- data/examples/advanced_composer.rb +207 -0
- data/examples/basic_compose.rb +24 -0
- data/examples/complex_composer.rb +235 -0
- data/examples/example_support.rb +18 -0
- data/examples/fixtures/current.md +179 -0
- data/examples/fixtures/faq.md +58 -0
- data/examples/fixtures/guide.md +62 -0
- data/examples/fixtures/site_intro.md +29 -0
- data/examples/fixtures/source.html +22 -0
- data/examples/html_input.rb +26 -0
- data/examples/output/advanced_composer.md +76 -0
- data/examples/output/basic_compose.md +25 -0
- data/examples/output/complex_composer.md +85 -0
- data/examples/output/html_input.md +4 -0
- data/examples/output/source_list_dsl.md +126 -0
- data/examples/output/standard_composer.md +46 -0
- data/examples/output/standard_sources_buffer.md +31 -0
- data/examples/output/yaml_plan.md +43 -0
- data/examples/plans/basic.yml +20 -0
- data/examples/source_list_dsl.rb +41 -0
- data/examples/standard_composer.rb +42 -0
- data/examples/standard_sources_buffer.rb +62 -0
- data/examples/yaml_plan.rb +17 -0
- data/lib/markdown_composer/capabilities.rb +223 -0
- data/lib/markdown_composer/composition_buffer.rb +378 -0
- data/lib/markdown_composer/data_path.rb +313 -0
- data/lib/markdown_composer/diagnostics.rb +63 -0
- data/lib/markdown_composer/document_index/html_parser.rb +84 -0
- data/lib/markdown_composer/document_index/markdown_parser.rb +338 -0
- data/lib/markdown_composer/document_index.rb +94 -0
- data/lib/markdown_composer/executor.rb +284 -0
- data/lib/markdown_composer/markdown_renderer.rb +105 -0
- data/lib/markdown_composer/plan.rb +436 -0
- data/lib/markdown_composer/plan_builder.rb +111 -0
- data/lib/markdown_composer/registries/action_entries.rb +26 -0
- data/lib/markdown_composer/registries/condition_entries.rb +58 -0
- data/lib/markdown_composer/registries/registry.rb +69 -0
- data/lib/markdown_composer/registries/source_entries.rb +18 -0
- data/lib/markdown_composer/registries/support_values.rb +23 -0
- data/lib/markdown_composer/registries/take_entries.rb +31 -0
- data/lib/markdown_composer/registries/take_registry.rb +18 -0
- data/lib/markdown_composer/registries/target_entries.rb +40 -0
- data/lib/markdown_composer/registries/unit_token_entries.rb +62 -0
- data/lib/markdown_composer/registries/where_registry.rb +84 -0
- data/lib/markdown_composer/registries.rb +46 -0
- data/lib/markdown_composer/result.rb +34 -0
- data/lib/markdown_composer/selection_resolver.rb +181 -0
- data/lib/markdown_composer/source.rb +57 -0
- data/lib/markdown_composer/source_list_builder.rb +47 -0
- data/lib/markdown_composer/take.rb +129 -0
- data/lib/markdown_composer/transform_options.rb +66 -0
- data/lib/markdown_composer/transform_runner/content_placement.rb +63 -0
- data/lib/markdown_composer/transform_runner/field_interpolator.rb +213 -0
- data/lib/markdown_composer/transform_runner/heading_numbering.rb +106 -0
- data/lib/markdown_composer/transform_runner/scope_resolver.rb +87 -0
- data/lib/markdown_composer/transform_runner.rb +264 -0
- data/lib/markdown_composer/transforms/default_entries.rb +31 -0
- data/lib/markdown_composer/transforms/registry.rb +11 -0
- data/lib/markdown_composer/validator.rb +378 -0
- data/lib/markdown_composer/value_object.rb +15 -0
- data/lib/markdown_composer/version.rb +5 -0
- data/lib/markdown_composer/where.rb +313 -0
- data/lib/markdown_composer.rb +114 -0
- metadata +260 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer Nested Syntax
|
|
3
|
+
type: reference
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-02
|
|
6
|
+
description: Public reference for Markdown Composer nested include syntax, selector-embedded projections, where/take ordering, and structured equivalents.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer Nested Syntax
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| Select syntax | [../compose/md_composer_compose_select.md](../compose/md_composer_compose_select.md) |
|
|
16
|
+
| Include syntax | [../compose/md_composer_compose_include.md](../compose/md_composer_compose_include.md) |
|
|
17
|
+
| Unit tokens | [./md_composer_unit_tokens.md](./md_composer_unit_tokens.md) |
|
|
18
|
+
| Take modifiers | [./md_composer_take.md](./md_composer_take.md) |
|
|
19
|
+
| Where conditions | [./md_composer_where.md](./md_composer_where.md) |
|
|
20
|
+
| Plan normalisation | `gems/markdown_composer/lib/markdown_composer/plan.rb` |
|
|
21
|
+
| Selection resolver | `gems/markdown_composer/lib/markdown_composer/selection_resolver.rb` |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. Purpose
|
|
26
|
+
|
|
27
|
+
Nested syntax lets a Composer expression select parent units, then project child units from inside each match.
|
|
28
|
+
|
|
29
|
+
Use this doc when you need the shared grammar around `unit[take] where condition { nested include }`. Use the include, take, where, and unit-token references for the full option tables.
|
|
30
|
+
|
|
31
|
+
## 2. Compact Grammar
|
|
32
|
+
|
|
33
|
+
The compact selector shape is:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
unit[take] where condition { nested include }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Each part is optional except the unit token.
|
|
40
|
+
|
|
41
|
+
| Part | Example | Meaning |
|
|
42
|
+
|------|---------|---------|
|
|
43
|
+
| `unit` | `section` | The document unit to match. |
|
|
44
|
+
| `[take]` | `[first:2]` | Narrows ordered matches. |
|
|
45
|
+
| `where condition` | `where title:contains("API")` | Filters matches before take. |
|
|
46
|
+
| `{ nested include }` | `{ heading_title; paragraph[first:1] }` | Projects child units from each match. |
|
|
47
|
+
|
|
48
|
+
## 3. Where And Take Ordering
|
|
49
|
+
|
|
50
|
+
Composer applies nested selector filters in this order:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
candidate units -> where -> take -> nested include
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Example:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
section[first:2] where title:contains("Release") { heading_title; paragraph[first:1] }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This finds child sections whose title contains `Release`, keeps the first two matching sections, then emits each section title and first paragraph.
|
|
63
|
+
|
|
64
|
+
## 4. Nested Include Separators
|
|
65
|
+
|
|
66
|
+
Top-level include strings use commas between include items:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
heading_title, paragraph[first:1]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Nested include braces use semicolons between child include items:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
section[first:2] { heading_title; paragraph[first:1] }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This keeps nested include parsing unambiguous when child expressions contain commas, predicates, brackets, or deeper braces.
|
|
79
|
+
|
|
80
|
+
## 5. Structured Equivalent
|
|
81
|
+
|
|
82
|
+
Compact nested include:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
section[first:2] { heading_title; paragraph[first:1] }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Structured equivalent:
|
|
89
|
+
|
|
90
|
+
```ruby
|
|
91
|
+
{
|
|
92
|
+
"type" => "section",
|
|
93
|
+
"take" => { "first" => 2 },
|
|
94
|
+
"include" => [
|
|
95
|
+
{ "type" => "heading_title" },
|
|
96
|
+
{ "type" => "paragraph", "take" => { "first" => 1 } }
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Use structured syntax for stored configs, generated plans, and GUI builders.
|
|
102
|
+
|
|
103
|
+
## 6. Compose Row Pattern
|
|
104
|
+
|
|
105
|
+
For normal compose rows, keep parent selection in `select` and child projection in `include`:
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
{
|
|
109
|
+
"select" => "heading_1_section[first:1]",
|
|
110
|
+
"include" => "section[first:2] { heading_title; paragraph[first:1] }",
|
|
111
|
+
"action" => "set"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`select` chooses the parent unit. `include` decides what to emit from inside that parent.
|
|
116
|
+
|
|
117
|
+
## 7. Recursion
|
|
118
|
+
|
|
119
|
+
Nested include items can themselves contain nested include blocks:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
section[first:2] { heading_title; section[first:1] { heading_title; paragraph[first:1] } }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Resolution is recursive:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
parent match -> child matches -> child where/take -> child include -> grandchild matches
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Keep deeply nested compact syntax for advanced cases only. Prefer structured syntax when a generated plan needs more than one nested level.
|
|
132
|
+
|
|
133
|
+
## 8. Exclusions
|
|
134
|
+
|
|
135
|
+
Nested include can combine with exclusions:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
all except section[first:1]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Structured form:
|
|
142
|
+
|
|
143
|
+
```ruby
|
|
144
|
+
[
|
|
145
|
+
{ "type" => "all" },
|
|
146
|
+
{ "exclude" => { "type" => "section", "take" => { "first" => 1 } } }
|
|
147
|
+
]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Exclusions are evaluated inside the current parent unit, then subtracted from included matches.
|
|
151
|
+
|
|
152
|
+
## 9. Scope Notes
|
|
153
|
+
|
|
154
|
+
| Context | Nested support | Notes |
|
|
155
|
+
|---------|----------------|-------|
|
|
156
|
+
| Row `include` | Yes | Primary place for nested projection. |
|
|
157
|
+
| Transform `scope` | Yes | Selector-embedded include can narrow the units transformed. |
|
|
158
|
+
| Target selector | Parsed | Use sparingly; target docs should define action-specific behavior. |
|
|
159
|
+
| Row `select` | Parsed | Prefer the separate row `include` field for normal composition. |
|
|
160
|
+
| `where` conditions | No | `where` supports grouped predicates and field-take, but not nested include projection. |
|
|
161
|
+
|
|
162
|
+
## 10. GUI Guidance
|
|
163
|
+
|
|
164
|
+
For UI builders:
|
|
165
|
+
|
|
166
|
+
- Build parent choice from unit tokens with `support.select`.
|
|
167
|
+
- Build nested include choices from unit tokens with `support.include`.
|
|
168
|
+
- Offer `take` and `where` controls at each nested level.
|
|
169
|
+
- Treat nested include and exclusions as advanced controls.
|
|
170
|
+
- Prefer structured config internally, even when showing compact preview text to authors.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer API Reference
|
|
3
|
+
type: contract
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-01
|
|
6
|
+
description: Public API reference for Markdown Composer facade methods and result objects.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer API Reference
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| Plan schema | [./md_composer_reference_plan_schema.md](./md_composer_reference_plan_schema.md) |
|
|
16
|
+
| Diagnostics | [./md_composer_reference_diagnostics.md](./md_composer_reference_diagnostics.md) |
|
|
17
|
+
| Capabilities | [./md_composer_reference_capabilities.md](./md_composer_reference_capabilities.md) |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. Main Methods
|
|
22
|
+
|
|
23
|
+
| Method | Purpose |
|
|
24
|
+
|--------|---------|
|
|
25
|
+
| `MarkdownComposer.compose(sources:, config: nil, plan: nil, options: {})` | Execute a plan and return a `Result`. |
|
|
26
|
+
| `MarkdownComposer.validate(config:, sources: [], options: {})` | Validate a config or plan without composing output. |
|
|
27
|
+
| `MarkdownComposer.normalise(config_or_rows)` | Return canonical plan hash. Alias: `normalize`. |
|
|
28
|
+
| `MarkdownComposer.capabilities(options: {})` | Return JSON-compatible UI/metadata contract. |
|
|
29
|
+
| `MarkdownComposer.plan { ... }` | Build a plan with the Ruby DSL. |
|
|
30
|
+
| `MarkdownComposer.parse_yaml(string)` | Parse YAML into a `Plan`. |
|
|
31
|
+
| `MarkdownComposer.parse_json(string)` | Parse JSON into a `Plan`. |
|
|
32
|
+
| `MarkdownComposer.to_yaml(plan)` | Export a plan to YAML. |
|
|
33
|
+
| `MarkdownComposer.to_json(plan, pretty: true)` | Export a plan to JSON. |
|
|
34
|
+
| `MarkdownComposer.parse_rows(rows)` | Build a plan from row hashes. |
|
|
35
|
+
| `MarkdownComposer.to_rows(plan)` | Export compose rows from a plan. |
|
|
36
|
+
|
|
37
|
+
## 2. Compose Result
|
|
38
|
+
|
|
39
|
+
`compose` returns a `MarkdownComposer::Result`.
|
|
40
|
+
|
|
41
|
+
| Attribute | Meaning |
|
|
42
|
+
|-----------|---------|
|
|
43
|
+
| `success?` | True when there are no errors. |
|
|
44
|
+
| `markdown` | Markdown output. |
|
|
45
|
+
| `html` | HTML output when `output` is `html`; otherwise nil. |
|
|
46
|
+
| `diagnostics` | Non-error diagnostics. |
|
|
47
|
+
| `errors` | Error diagnostics. |
|
|
48
|
+
| `stages` | Optional stage snapshots when enabled. |
|
|
49
|
+
| `to_h` | Serializable result hash. |
|
|
50
|
+
|
|
51
|
+
## 3. Sources
|
|
52
|
+
|
|
53
|
+
Sources are hashes or source-like objects with content:
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
{ "key" => "current", "type" => "current", "markdown" => "# Title\n" }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
HTML sources are supported as best-effort/lossy input.
|
|
60
|
+
|
|
61
|
+
## 4. Validation Result
|
|
62
|
+
|
|
63
|
+
`validate` returns a hash:
|
|
64
|
+
|
|
65
|
+
| Key | Meaning |
|
|
66
|
+
|-----|---------|
|
|
67
|
+
| `:valid` | False when any errors are present. |
|
|
68
|
+
| `:plan` | Normalized plan hash. |
|
|
69
|
+
| `:diagnostics` | All diagnostics as JSON-compatible hashes. |
|
|
70
|
+
| `:errors` | Error diagnostics only. |
|
|
71
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer Capabilities Reference
|
|
3
|
+
type: contract
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-01
|
|
6
|
+
description: Public reference for Markdown Composer capabilities metadata used by host UIs.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer Capabilities Reference
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| GUI-oriented source material | [../ai/md_composer_ai_canonical_docs.md](../ai/md_composer_ai_canonical_docs.md) |
|
|
16
|
+
| Registries | [./md_composer_reference_registries.md](./md_composer_reference_registries.md) |
|
|
17
|
+
| Unit tokens | [./md_composer_unit_tokens.md](./md_composer_unit_tokens.md) |
|
|
18
|
+
| Take modifiers | [./md_composer_take.md](./md_composer_take.md) |
|
|
19
|
+
| Where conditions | [./md_composer_where.md](./md_composer_where.md) |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. Purpose
|
|
24
|
+
|
|
25
|
+
`MarkdownComposer.capabilities` returns a JSON-compatible metadata contract for GUI builders and host integrations.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
capabilities = MarkdownComposer.capabilities
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 2. Top-Level Keys
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
version, headless, fields, formats, sources, actions, targets,
|
|
35
|
+
unit_tokens, take, where, transforms, outputs,
|
|
36
|
+
diagnostic_code_families, policy_options
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 3. Entry Metadata
|
|
40
|
+
|
|
41
|
+
Registry entries expose labels, tooltips, aliases, meanings, support metadata, `support_status`, and `enabled`.
|
|
42
|
+
|
|
43
|
+
Use this metadata for UI controls instead of hard-coding token lists.
|
|
44
|
+
|
|
45
|
+
For the human-facing unit-token table, see [Unit Tokens](./md_composer_unit_tokens.md).
|
|
46
|
+
For the human-facing take table, see [Take Modifiers](./md_composer_take.md).
|
|
47
|
+
For the human-facing field/predicate table, see [Where Conditions](./md_composer_where.md).
|
|
48
|
+
|
|
49
|
+
## 4. GUI Rules
|
|
50
|
+
|
|
51
|
+
| Rule | Reason |
|
|
52
|
+
|------|--------|
|
|
53
|
+
| Inspect per-consumer unit token support. | A token can be valid for `include` but not `select`. |
|
|
54
|
+
| Filter transform modes by mode-level `enabled`. | A transform can be visible while a mode is gated. |
|
|
55
|
+
| Treat policy-gated entries separately. | Host policy must opt in. |
|
|
56
|
+
| Do not hide where fields only because `enabled` is false. | Specialized where entries currently expose a misleading enabled flag. |
|
|
57
|
+
|
|
58
|
+
## 5. Policy Options
|
|
59
|
+
|
|
60
|
+
| Option | Unlocks |
|
|
61
|
+
|--------|---------|
|
|
62
|
+
| `adapter_policy_tokens` | Token families such as `raw_html`. |
|
|
63
|
+
| `adapter_transforms` | Host-policy transforms such as `adapter` and `sanitise`. |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer Diagnostics Reference
|
|
3
|
+
type: contract
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-01
|
|
6
|
+
description: Public reference for Markdown Composer diagnostics and validation errors.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer Diagnostics Reference
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| API reference | [./md_composer_reference_api.md](./md_composer_reference_api.md) |
|
|
16
|
+
| Plan schema | [./md_composer_reference_plan_schema.md](./md_composer_reference_plan_schema.md) |
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 1. Purpose
|
|
21
|
+
|
|
22
|
+
Diagnostics explain validation and execution problems. Errors block successful composition; warnings report behavior such as empty selections or empty destructive targets.
|
|
23
|
+
|
|
24
|
+
## 2. Validation Example
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
validation = MarkdownComposer.validate(config: config, sources: sources)
|
|
28
|
+
validation[:valid]
|
|
29
|
+
validation[:errors]
|
|
30
|
+
validation[:diagnostics]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 3. Common Codes
|
|
34
|
+
|
|
35
|
+
| Code | Meaning |
|
|
36
|
+
|------|---------|
|
|
37
|
+
| `source.missing` | A source reference cannot be resolved. |
|
|
38
|
+
| `selection.empty` | A selector matched no content. |
|
|
39
|
+
| `take.invalid` | Take syntax or values are invalid. |
|
|
40
|
+
| `where.invalid` | Where syntax or predicate usage is invalid. |
|
|
41
|
+
| `action.target_required` | Action requires a target. |
|
|
42
|
+
| `target.selector_required` | Action requires selector target, not positional target. |
|
|
43
|
+
| `target.in_place_source_invalid` | `in_place` requires original `source: "buffer"`. |
|
|
44
|
+
| `transform.option_missing` | Required transform option is missing. |
|
|
45
|
+
| `transform.option_unknown` | Transform option is not accepted for that mode. |
|
|
46
|
+
| `yaml.syntax` / `json.syntax` | Import parse error. |
|
|
47
|
+
|
|
48
|
+
## 4. Debugging Workflow
|
|
49
|
+
|
|
50
|
+
1. Validate first.
|
|
51
|
+
2. Check diagnostic `path` to find the row and field.
|
|
52
|
+
3. Normalize the plan to inspect canonical tokens.
|
|
53
|
+
4. Run focused compose examples with small input.
|
|
54
|
+
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer Plan Schema Reference
|
|
3
|
+
type: contract
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-01
|
|
6
|
+
description: Public reference for Markdown Composer plan shape and row schemas.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer Plan Schema Reference
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| API reference | [./md_composer_reference_api.md](./md_composer_reference_api.md) |
|
|
16
|
+
| Compose anatomy | [../compose/md_composer_compose_anatomy.md](../compose/md_composer_compose_anatomy.md) |
|
|
17
|
+
| Transform anatomy | [../transform/md_composer_transform_anatomy.md](../transform/md_composer_transform_anatomy.md) |
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 1. Top-Level Shape
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
{
|
|
25
|
+
"version" => 1,
|
|
26
|
+
"output" => "markdown",
|
|
27
|
+
"compose" => [ ... ],
|
|
28
|
+
"transform" => [ ... ]
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
| Key | Required | Default |
|
|
33
|
+
|-----|----------|---------|
|
|
34
|
+
| `version` | no | `1` |
|
|
35
|
+
| `output` | no | `markdown` |
|
|
36
|
+
| `compose` | no | empty |
|
|
37
|
+
| `transform` | no | empty |
|
|
38
|
+
|
|
39
|
+
## 2. Compose Row Shape
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
{
|
|
43
|
+
"source" => "current",
|
|
44
|
+
"select" => "heading_2_section[first:1]",
|
|
45
|
+
"include" => "all",
|
|
46
|
+
"action" => "set",
|
|
47
|
+
"target" => "end",
|
|
48
|
+
"transforms" => []
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`transforms` is used by `modify` and `transform_buffer_target`.
|
|
53
|
+
|
|
54
|
+
## 3. Transform Row Shape
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
{
|
|
58
|
+
"scope" => "output",
|
|
59
|
+
"transform" => "replace_text",
|
|
60
|
+
"mode" => "literal",
|
|
61
|
+
"options" => { "from" => "Draft", "to" => "Final" }
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 4. Import And Export
|
|
66
|
+
|
|
67
|
+
| Need | API |
|
|
68
|
+
|------|-----|
|
|
69
|
+
| YAML to plan | `MarkdownComposer.parse_yaml(yaml)` |
|
|
70
|
+
| JSON to plan | `MarkdownComposer.parse_json(json)` |
|
|
71
|
+
| Plan to YAML | `MarkdownComposer.to_yaml(plan)` |
|
|
72
|
+
| Plan to JSON | `MarkdownComposer.to_json(plan)` |
|
|
73
|
+
| Rows to plan | `MarkdownComposer.parse_rows(rows)` |
|
|
74
|
+
| Plan to rows | `MarkdownComposer.to_rows(plan)` |
|
|
75
|
+
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Markdown Composer Registries Reference
|
|
3
|
+
type: contract
|
|
4
|
+
status: current
|
|
5
|
+
updated: 2026-06-01
|
|
6
|
+
description: Public reference for Markdown Composer registry families and metadata.
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Markdown Composer Registries Reference
|
|
10
|
+
|
|
11
|
+
### References
|
|
12
|
+
|
|
13
|
+
| What | Where |
|
|
14
|
+
|------|-------|
|
|
15
|
+
| Capabilities | [./md_composer_reference_capabilities.md](./md_composer_reference_capabilities.md) |
|
|
16
|
+
| Unit tokens | [./md_composer_unit_tokens.md](./md_composer_unit_tokens.md) |
|
|
17
|
+
| Take modifiers | [./md_composer_take.md](./md_composer_take.md) |
|
|
18
|
+
| Where conditions | [./md_composer_where.md](./md_composer_where.md) |
|
|
19
|
+
| Compose select | [../compose/md_composer_compose_select.md](../compose/md_composer_compose_select.md) |
|
|
20
|
+
| Transform families | [../transform/md_composer_transform_transforms.md](../transform/md_composer_transform_transforms.md) |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Purpose
|
|
25
|
+
|
|
26
|
+
Registries define canonical tokens, aliases, labels, tooltips, meanings, support metadata, and capability entries.
|
|
27
|
+
|
|
28
|
+
Public plans should store canonical tokens after normalization.
|
|
29
|
+
|
|
30
|
+
## 2. Registry Families
|
|
31
|
+
|
|
32
|
+
| Family | Used by |
|
|
33
|
+
|--------|---------|
|
|
34
|
+
| Sources | Compose `source` |
|
|
35
|
+
| Actions | Compose `action` |
|
|
36
|
+
| Targets | Compose `target` |
|
|
37
|
+
| Unit tokens | Select, include, target, and transform scope |
|
|
38
|
+
| Take | Bracketed take syntax |
|
|
39
|
+
| Where | Field/predicate/group filtering |
|
|
40
|
+
| Transforms | Transform family and mode metadata |
|
|
41
|
+
|
|
42
|
+
See [Unit Tokens](./md_composer_unit_tokens.md) for the full public unit-token table with aliases and per-context support.
|
|
43
|
+
See [Take Modifiers](./md_composer_take.md) for bracketed positional narrowing syntax.
|
|
44
|
+
See [Where Conditions](./md_composer_where.md) for the shared field/predicate syntax used by select, include, target, and scope.
|
|
45
|
+
|
|
46
|
+
## 3. Aliases
|
|
47
|
+
|
|
48
|
+
Common aliases:
|
|
49
|
+
|
|
50
|
+
| Alias | Canonical |
|
|
51
|
+
|-------|-----------|
|
|
52
|
+
| `h2_section` | `heading_2_section` |
|
|
53
|
+
| `h2` | `heading_2` |
|
|
54
|
+
| `p` | `paragraph` |
|
|
55
|
+
| `a` | `link` |
|
|
56
|
+
| `img` | `image` |
|
|
57
|
+
| `li` | `list_item` |
|
|
58
|
+
| `whole output` | `output` target position |
|
|
59
|
+
| `in place` | `in_place` target position |
|
|
60
|
+
|
|
61
|
+
## 4. Structured Data Tokens
|
|
62
|
+
|
|
63
|
+
`data_block` is a normal selectable structured-data block. `data_path` is include-only. `data_record` and `data_value` are transient derived output node types produced by `data_path(...)`; do not treat them as ordinary post-compose selectors in standalone Markdown output.
|