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.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +23 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +278 -0
  5. data/ROADMAP.md +80 -0
  6. data/docs/_md_composer_architecture.md +50 -0
  7. data/docs/_md_composer_cheatsheet.md +72 -0
  8. data/docs/_md_composer_concepts.md +64 -0
  9. data/docs/_md_composer_dev_guide.md +55 -0
  10. data/docs/_md_composer_getting_started.md +114 -0
  11. data/docs/_md_composer_readme.md +93 -0
  12. data/docs/_md_composer_user_guide.md +65 -0
  13. data/docs/ai/md_composer_ai_audit.md +35 -0
  14. data/docs/ai/md_composer_ai_canonical_docs.md +44 -0
  15. data/docs/ai/md_composer_ai_source_map.md +39 -0
  16. data/docs/compose/md_composer_compose_actions.md +338 -0
  17. data/docs/compose/md_composer_compose_anatomy.md +156 -0
  18. data/docs/compose/md_composer_compose_buffer.md +81 -0
  19. data/docs/compose/md_composer_compose_examples.md +31 -0
  20. data/docs/compose/md_composer_compose_include.md +136 -0
  21. data/docs/compose/md_composer_compose_select.md +198 -0
  22. data/docs/compose/md_composer_compose_sources.md +161 -0
  23. data/docs/compose/md_composer_compose_targets.md +194 -0
  24. data/docs/examples/md_composer_example_basic_compose.md +57 -0
  25. data/docs/examples/md_composer_example_buffer_target_actions.md +83 -0
  26. data/docs/examples/md_composer_example_fixtures.md +62 -0
  27. data/docs/examples/md_composer_example_html_output.md +50 -0
  28. data/docs/examples/md_composer_example_modify.md +77 -0
  29. data/docs/examples/md_composer_example_multi_row_compose.md +67 -0
  30. data/docs/examples/md_composer_example_ruby_plans.md +62 -0
  31. data/docs/examples/md_composer_example_structured_data.md +68 -0
  32. data/docs/examples/md_composer_example_transforms.md +68 -0
  33. data/docs/examples/md_composer_example_yaml_json_rows.md +56 -0
  34. data/docs/examples/md_composer_examples_readme.md +45 -0
  35. data/docs/examples/md_composer_runnable_examples.md +374 -0
  36. data/docs/examples/md_composer_source_ruby_dsl.md +88 -0
  37. data/docs/reference/md_composer_nested.md +170 -0
  38. data/docs/reference/md_composer_reference_api.md +71 -0
  39. data/docs/reference/md_composer_reference_capabilities.md +63 -0
  40. data/docs/reference/md_composer_reference_diagnostics.md +54 -0
  41. data/docs/reference/md_composer_reference_plan_schema.md +75 -0
  42. data/docs/reference/md_composer_reference_registries.md +63 -0
  43. data/docs/reference/md_composer_take.md +221 -0
  44. data/docs/reference/md_composer_unit_tokens.md +228 -0
  45. data/docs/reference/md_composer_where.md +227 -0
  46. data/docs/transform/md_composer_transform_anatomy.md +112 -0
  47. data/docs/transform/md_composer_transform_examples.md +30 -0
  48. data/docs/transform/md_composer_transform_modes.md +83 -0
  49. data/docs/transform/md_composer_transform_options.md +142 -0
  50. data/docs/transform/md_composer_transform_scope.md +97 -0
  51. data/docs/transform/md_composer_transform_transforms.md +99 -0
  52. data/examples/README.md +20 -0
  53. data/examples/advanced_composer.rb +207 -0
  54. data/examples/basic_compose.rb +24 -0
  55. data/examples/complex_composer.rb +235 -0
  56. data/examples/example_support.rb +18 -0
  57. data/examples/fixtures/current.md +179 -0
  58. data/examples/fixtures/faq.md +58 -0
  59. data/examples/fixtures/guide.md +62 -0
  60. data/examples/fixtures/site_intro.md +29 -0
  61. data/examples/fixtures/source.html +22 -0
  62. data/examples/html_input.rb +26 -0
  63. data/examples/output/advanced_composer.md +76 -0
  64. data/examples/output/basic_compose.md +25 -0
  65. data/examples/output/complex_composer.md +85 -0
  66. data/examples/output/html_input.md +4 -0
  67. data/examples/output/source_list_dsl.md +126 -0
  68. data/examples/output/standard_composer.md +46 -0
  69. data/examples/output/standard_sources_buffer.md +31 -0
  70. data/examples/output/yaml_plan.md +43 -0
  71. data/examples/plans/basic.yml +20 -0
  72. data/examples/source_list_dsl.rb +41 -0
  73. data/examples/standard_composer.rb +42 -0
  74. data/examples/standard_sources_buffer.rb +62 -0
  75. data/examples/yaml_plan.rb +17 -0
  76. data/lib/markdown_composer/capabilities.rb +223 -0
  77. data/lib/markdown_composer/composition_buffer.rb +378 -0
  78. data/lib/markdown_composer/data_path.rb +313 -0
  79. data/lib/markdown_composer/diagnostics.rb +63 -0
  80. data/lib/markdown_composer/document_index/html_parser.rb +84 -0
  81. data/lib/markdown_composer/document_index/markdown_parser.rb +338 -0
  82. data/lib/markdown_composer/document_index.rb +94 -0
  83. data/lib/markdown_composer/executor.rb +284 -0
  84. data/lib/markdown_composer/markdown_renderer.rb +105 -0
  85. data/lib/markdown_composer/plan.rb +436 -0
  86. data/lib/markdown_composer/plan_builder.rb +111 -0
  87. data/lib/markdown_composer/registries/action_entries.rb +26 -0
  88. data/lib/markdown_composer/registries/condition_entries.rb +58 -0
  89. data/lib/markdown_composer/registries/registry.rb +69 -0
  90. data/lib/markdown_composer/registries/source_entries.rb +18 -0
  91. data/lib/markdown_composer/registries/support_values.rb +23 -0
  92. data/lib/markdown_composer/registries/take_entries.rb +31 -0
  93. data/lib/markdown_composer/registries/take_registry.rb +18 -0
  94. data/lib/markdown_composer/registries/target_entries.rb +40 -0
  95. data/lib/markdown_composer/registries/unit_token_entries.rb +62 -0
  96. data/lib/markdown_composer/registries/where_registry.rb +84 -0
  97. data/lib/markdown_composer/registries.rb +46 -0
  98. data/lib/markdown_composer/result.rb +34 -0
  99. data/lib/markdown_composer/selection_resolver.rb +181 -0
  100. data/lib/markdown_composer/source.rb +57 -0
  101. data/lib/markdown_composer/source_list_builder.rb +47 -0
  102. data/lib/markdown_composer/take.rb +129 -0
  103. data/lib/markdown_composer/transform_options.rb +66 -0
  104. data/lib/markdown_composer/transform_runner/content_placement.rb +63 -0
  105. data/lib/markdown_composer/transform_runner/field_interpolator.rb +213 -0
  106. data/lib/markdown_composer/transform_runner/heading_numbering.rb +106 -0
  107. data/lib/markdown_composer/transform_runner/scope_resolver.rb +87 -0
  108. data/lib/markdown_composer/transform_runner.rb +264 -0
  109. data/lib/markdown_composer/transforms/default_entries.rb +31 -0
  110. data/lib/markdown_composer/transforms/registry.rb +11 -0
  111. data/lib/markdown_composer/validator.rb +378 -0
  112. data/lib/markdown_composer/value_object.rb +15 -0
  113. data/lib/markdown_composer/version.rb +5 -0
  114. data/lib/markdown_composer/where.rb +313 -0
  115. data/lib/markdown_composer.rb +114 -0
  116. metadata +260 -0
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: Markdown Composer Basic Compose Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Basic example for selecting one section from a Markdown source.
7
+ ---
8
+
9
+ # Markdown Composer Basic Compose Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Compose anatomy | [../compose/md_composer_compose_anatomy.md](../compose/md_composer_compose_anatomy.md) |
16
+ | Select | [../compose/md_composer_compose_select.md](../compose/md_composer_compose_select.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Select the `Overview` section from the shared current fixture and make it the whole output.
23
+
24
+ ## 2. Input
25
+
26
+ Use [../../examples/fixtures/current.md](../../examples/fixtures/current.md).
27
+
28
+ ## 3. Config
29
+
30
+ ```ruby
31
+ sources = MarkdownComposer.source_list do
32
+ current File.read("examples/fixtures/current.md")
33
+ end
34
+
35
+ plan = MarkdownComposer.plan do
36
+ from :current
37
+ select 'heading_2_section where title:equals("Overview")'
38
+ include "all"
39
+ set
40
+ end
41
+
42
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
43
+ ```
44
+
45
+ ## 4. Expected Output
46
+
47
+ ```markdown
48
+ ## Overview
49
+
50
+ This overview section is the normal starting point for Markdown Composer examples.
51
+ ```
52
+
53
+ ## 5. Why It Works
54
+
55
+ `heading_2_section` selects the heading and body. `where title:equals("Overview")` filters to the desired section. `set` replaces the buffer with that selected content.
56
+
57
+ Runnable version: [../../examples/basic_compose.rb](../../examples/basic_compose.rb).
@@ -0,0 +1,83 @@
1
+ ---
2
+ title: Markdown Composer Buffer Target Actions Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for remove_buffer_target and transform_buffer_target.
7
+ ---
8
+
9
+ # Markdown Composer Buffer Target Actions Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Actions | [../compose/md_composer_compose_actions.md](../compose/md_composer_compose_actions.md) |
16
+ | Targets | [../compose/md_composer_compose_targets.md](../compose/md_composer_compose_targets.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Create a buffer from shared fixtures, remove one temporary section, then transform existing buffer headings.
23
+
24
+ ## 2. Config
25
+
26
+ ```ruby
27
+ sources = MarkdownComposer.source_list do
28
+ current File.read("examples/fixtures/current.md")
29
+ inherited :site_intro, File.read("examples/fixtures/site_intro.md")
30
+ end
31
+
32
+ plan = MarkdownComposer.plan do
33
+ from :current
34
+ select 'heading_2_section where title:equals("Feature Matrix")'
35
+ include "heading_title"
36
+ include "paragraph[first:1]"
37
+ set
38
+
39
+ from({ type: "inherited", key: "site_intro" })
40
+ select 'heading_2_section where title:equals("Welcome")'
41
+ include "all"
42
+ append
43
+
44
+ from({
45
+ type: "inline",
46
+ markdown: "## Cleanup Marker\n\nRemove this temporary section."
47
+ })
48
+ select "heading_2_section"
49
+ include "all"
50
+ append
51
+
52
+ from :buffer
53
+ select 'heading_2_section where title:equals("Cleanup Marker")'
54
+ remove_buffer_target
55
+
56
+ transform_buffer_target(
57
+ 'heading_2 where title:equals("Welcome")',
58
+ transforms: [
59
+ { "transform" => "heading_levels", "mode" => "demote", "options" => { "by" => 1 } }
60
+ ]
61
+ )
62
+ end
63
+
64
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
65
+ ```
66
+
67
+ ## 3. Expected Output
68
+
69
+ ```markdown
70
+ ## Feature Matrix
71
+
72
+ The table below is intended for table selection and table-row experiments.
73
+
74
+ ### Welcome
75
+
76
+ This inherited introduction can be prepended to composed output.
77
+ ```
78
+
79
+ ## 4. Why It Works
80
+
81
+ `remove_buffer_target` and `transform_buffer_target` use `target` as the meaningful address. The selected source content is not inserted into the buffer by those actions.
82
+
83
+ Runnable versions: [../../examples/advanced_composer.rb](../../examples/advanced_composer.rb) and [../../examples/complex_composer.rb](../../examples/complex_composer.rb).
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: Markdown Composer Example Fixtures
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Map of the shared Markdown and HTML fixtures used by runnable Markdown Composer examples.
7
+ ---
8
+
9
+ # Markdown Composer Example Fixtures
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Runnable examples | [./md_composer_runnable_examples.md](./md_composer_runnable_examples.md) |
16
+ | Source guide | [../compose/md_composer_compose_sources.md](../compose/md_composer_compose_sources.md) |
17
+ | Include guide | [../compose/md_composer_compose_include.md](../compose/md_composer_compose_include.md) |
18
+
19
+ ---
20
+
21
+ ## 1. Fixture Directory
22
+
23
+ User-facing example fixtures live in [../../examples/fixtures](../../examples/fixtures). They are separate from `test/fixtures`, which are larger automated-test inputs.
24
+
25
+ ## 2. Fixture Map
26
+
27
+ | Fixture | Source role | Useful sections |
28
+ |---------|-------------|-----------------|
29
+ | [current.md](../../examples/fixtures/current.md) | Main `current` source. | `Overview`, `Feature Matrix`, `Operations`, `Diagrams And Math`, `Draft Notes`, `Appendix`. |
30
+ | [guide.md](../../examples/fixtures/guide.md) | Keyed `explicit :guide` source. | `Install`, `Configure`, `Validate`, `Publish`. |
31
+ | [faq.md](../../examples/fixtures/faq.md) | Keyed `explicit :faq` source. | `Can I use this outside Rails?`, `Can plans be YAML?`, `What source types exist?`, `Can I transform output?`. |
32
+ | [site_intro.md](../../examples/fixtures/site_intro.md) | Keyed `inherited :site_intro` source. | `Welcome`, `Navigation`, inherited audience/context text. |
33
+ | [source.html](../../examples/fixtures/source.html) | HTML source fixture. | HTML `Overview` content for best-effort HTML-to-Markdown examples. |
34
+
35
+ ## 3. Notable Current Source Sections
36
+
37
+ `current.md` is intentionally broad:
38
+
39
+ - `Feature Matrix` includes a first paragraph, link, table, H3 sections, fenced code, and nested H4 content.
40
+ - `Operations` includes runbook-style sections, ordered steps, fenced shell code, and monitoring content.
41
+ - `Diagrams And Math` includes Mermaid and math examples.
42
+ - `Appendix` includes source-type and copy-paste checklist material.
43
+
44
+ ## 4. Loading Fixtures
45
+
46
+ Use the source list DSL in runnable Ruby examples:
47
+
48
+ ```ruby
49
+ sources = MarkdownComposer.source_list do
50
+ current File.read("examples/fixtures/current.md")
51
+ explicit :guide, File.read("examples/fixtures/guide.md")
52
+ explicit :faq, File.read("examples/fixtures/faq.md")
53
+ inherited :site_intro, File.read("examples/fixtures/site_intro.md")
54
+ end
55
+ ```
56
+
57
+ The `key` in `explicit :guide` or `inherited :site_intro` is the key used by compose rows such as:
58
+
59
+ ```ruby
60
+ from({ type: "explicit", key: "guide" })
61
+ from({ type: "inherited", key: "site_intro" })
62
+ ```
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: Markdown Composer HTML Output Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for rendering Markdown Composer output as HTML.
7
+ ---
8
+
9
+ # Markdown Composer HTML Output Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Transform modes | [../transform/md_composer_transform_modes.md](../transform/md_composer_transform_modes.md) |
16
+ | API reference | [../reference/md_composer_reference_api.md](../reference/md_composer_reference_api.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Render selected Markdown to HTML and add link attributes to external links.
23
+
24
+ ## 2. Config
25
+
26
+ ```ruby
27
+ sources = MarkdownComposer.source_list do
28
+ current html: File.read("examples/fixtures/source.html"), preferred_format: :html
29
+ end
30
+
31
+ config = {
32
+ "compose" => [
33
+ { "select" => "all", "action" => "set" }
34
+ ],
35
+ "transform" => [
36
+ { "scope" => "output", "transform" => "links", "mode" => "nofollow" },
37
+ { "scope" => "output", "transform" => "links", "mode" => "target_blank" }
38
+ ],
39
+ "output" => "html"
40
+ }
41
+
42
+ result = MarkdownComposer.compose(sources: sources, config: config)
43
+ puts result.html
44
+ ```
45
+
46
+ ## 3. Important Caveat
47
+
48
+ HTML link attribute modes are top-level HTML-output post-processing. They apply to rendered external links and skip empty links and internal `#anchor` links. Row-level link attribute transforms do not update final HTML attributes.
49
+
50
+ For Markdown output from the HTML fixture, see [../../examples/html_input.rb](../../examples/html_input.rb).
@@ -0,0 +1,77 @@
1
+ ---
2
+ title: Markdown Composer Modify Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for using the modify action to transform selected source content while composing.
7
+ ---
8
+
9
+ # Markdown Composer Modify Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Actions | [../compose/md_composer_compose_actions.md](../compose/md_composer_compose_actions.md) |
16
+ | Transform anatomy | [../transform/md_composer_transform_anatomy.md](../transform/md_composer_transform_anatomy.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Select a section from the shared current fixture, transform selected content while composing, and append the transformed fragment.
23
+
24
+ ## 2. Config
25
+
26
+ ```ruby
27
+ sources = MarkdownComposer.source_list do
28
+ current File.read("examples/fixtures/current.md")
29
+ end
30
+
31
+ plan = MarkdownComposer.plan do
32
+ from :current
33
+ select 'heading_2_section where title:equals("Feature Matrix")'
34
+ include "heading_title"
35
+ include "paragraph[first:1]"
36
+ set
37
+
38
+ from :current
39
+ select 'heading_3_section where title:equals("Dashboard")'
40
+ include "all"
41
+ modify "end", transforms: [
42
+ {
43
+ "scope" => "heading_3, paragraph",
44
+ "transform" => "replace_text",
45
+ "mode" => "literal",
46
+ "options" => {
47
+ "from" => "Dashboard",
48
+ "to" => "Dashboard Snapshot"
49
+ }
50
+ }
51
+ ]
52
+ end
53
+
54
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
55
+ ```
56
+
57
+ ## 3. Expected Output
58
+
59
+ ```markdown
60
+ ## Feature Matrix
61
+
62
+ The table below is intended for table selection and table-row experiments.
63
+
64
+ ### Dashboard Snapshot
65
+
66
+ Dashboard Snapshot cards should keep this heading and paragraph when selected.
67
+ ```
68
+
69
+ ## 4. Why It Works
70
+
71
+ `modify` creates a temporary fragment from selected source content, runs nested transforms against that fragment, then places the transformed fragment at the target.
72
+
73
+ ## 5. Variation: In Place
74
+
75
+ To rewrite existing buffer content inline, use a later row with `source: "buffer"` and `target: "in_place"`.
76
+
77
+ Runnable versions: [../../examples/advanced_composer.rb](../../examples/advanced_composer.rb) and [../../examples/complex_composer.rb](../../examples/complex_composer.rb).
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: Markdown Composer Multi-Row Compose Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for building output from multiple compose rows.
7
+ ---
8
+
9
+ # Markdown Composer Multi-Row Compose Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Compose anatomy | [../compose/md_composer_compose_anatomy.md](../compose/md_composer_compose_anatomy.md) |
16
+ | Buffer | [../compose/md_composer_compose_buffer.md](../compose/md_composer_compose_buffer.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Build a new document from multiple sections in the shared current fixture and remove draft-only content from the buffer.
23
+
24
+ ## 2. Config
25
+
26
+ ```ruby
27
+ sources = MarkdownComposer.source_list do
28
+ current File.read("examples/fixtures/current.md")
29
+ end
30
+
31
+ plan = MarkdownComposer.plan do
32
+ from :current
33
+ select 'heading_2_section where title:equals("Overview")'
34
+ include "all"
35
+ set
36
+
37
+ from :current
38
+ select 'heading_2_section where title:equals("Feature Matrix")'
39
+ include "heading_title"
40
+ include "paragraph[first:1]"
41
+ append
42
+
43
+ from :buffer
44
+ select 'paragraph where text:contains("draft")'
45
+ remove_buffer_target
46
+ end
47
+
48
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
49
+ ```
50
+
51
+ ## 3. Expected Output
52
+
53
+ ```markdown
54
+ ## Overview
55
+
56
+ This overview section is the normal starting point for Markdown Composer examples.
57
+
58
+ ## Feature Matrix
59
+
60
+ The table below is intended for table selection and table-row experiments.
61
+ ```
62
+
63
+ ## 4. Why It Works
64
+
65
+ The first row creates the buffer. The second appends another section. The third uses `source: "buffer"` and a target selector to remove the draft paragraph from composed output.
66
+
67
+ Runnable versions: [../../examples/source_list_dsl.rb](../../examples/source_list_dsl.rb) and [../../examples/standard_sources_buffer.rb](../../examples/standard_sources_buffer.rb).
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: Markdown Composer Ruby Plans Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for authoring Markdown Composer plans with Ruby DSL and structured hashes.
7
+ ---
8
+
9
+ # Markdown Composer Ruby Plans Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Plan schema | [../reference/md_composer_reference_plan_schema.md](../reference/md_composer_reference_plan_schema.md) |
16
+ | API reference | [../reference/md_composer_reference_api.md](../reference/md_composer_reference_api.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Block DSL
21
+
22
+ ```ruby
23
+ sources = MarkdownComposer.source_list do
24
+ current File.read("examples/fixtures/current.md")
25
+ end
26
+
27
+ plan = MarkdownComposer.plan do
28
+ from :current
29
+ select 'heading_2_section where title:equals("Overview")'
30
+ include "all"
31
+ set
32
+ end
33
+
34
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
35
+ ```
36
+
37
+ Use the DSL for hand-authored Ruby code and tests.
38
+
39
+ ## 2. Structured Hash
40
+
41
+ ```ruby
42
+ sources = MarkdownComposer.source_list do
43
+ current File.read("examples/fixtures/current.md")
44
+ end
45
+
46
+ config = {
47
+ "compose" => [
48
+ {
49
+ "source" => "current",
50
+ "select" => 'heading_2_section where title:equals("Overview")',
51
+ "include" => "all",
52
+ "action" => "set"
53
+ }
54
+ ]
55
+ }
56
+
57
+ result = MarkdownComposer.compose(sources: sources, config: config)
58
+ ```
59
+
60
+ Use structured hashes for storage, APIs, GUI builders, YAML, JSON, and row import/export.
61
+
62
+ For source-list syntax, see [Source Ruby DSL](./md_composer_source_ruby_dsl.md). Runnable versions: [../../examples/basic_compose.rb](../../examples/basic_compose.rb) and [../../examples/source_list_dsl.rb](../../examples/source_list_dsl.rb).
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: Markdown Composer Structured Data Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for selecting YAML or JSON data blocks and extracting values with data_path.
7
+ ---
8
+
9
+ # Markdown Composer Structured Data Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Include | [../compose/md_composer_compose_include.md](../compose/md_composer_compose_include.md) |
16
+ | Targets | [../compose/md_composer_compose_targets.md](../compose/md_composer_compose_targets.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Extract selected values from a YAML data block.
23
+
24
+ The shared fixtures focus on Markdown, HTML, tables, code, Mermaid, math, and source composition. This structured-data example stays self-contained because the fixture set does not include a YAML data block.
25
+
26
+ ## 2. Input
27
+
28
+ ````markdown
29
+ ```yaml
30
+ fields:
31
+ - type: dropdown
32
+ label: Plan
33
+ - type: text
34
+ label: Name
35
+ ```
36
+ ````
37
+
38
+ ## 3. Config
39
+
40
+ ```ruby
41
+ sources = [
42
+ {
43
+ "key" => "current",
44
+ "type" => "current",
45
+ "markdown" => "```yaml\nfields:\n - type: dropdown\n label: Plan\n - type: text\n label: Name\n```\n"
46
+ }
47
+ ]
48
+
49
+ config = {
50
+ "compose" => [
51
+ {
52
+ "select" => "data_block where format:equals(\"yaml\")",
53
+ "include" => "data_path(\"fields[type=dropdown].label\")",
54
+ "action" => "set"
55
+ }
56
+ ]
57
+ }
58
+ ```
59
+
60
+ ## 4. Expected Output
61
+
62
+ ```markdown
63
+ Plan
64
+ ```
65
+
66
+ ## 5. Data Record And Data Value Note
67
+
68
+ `data_path(...)` creates transient derived nodes called `data_record` or `data_value` depending on the extracted value. In ordinary Markdown output they serialize to Markdown text, so target the serialized text unless a host adapter preserves structured nodes.
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: Markdown Composer Transform Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for top-level transform rows.
7
+ ---
8
+
9
+ # Markdown Composer Transform Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Transform anatomy | [../transform/md_composer_transform_anatomy.md](../transform/md_composer_transform_anatomy.md) |
16
+ | Options | [../transform/md_composer_transform_options.md](../transform/md_composer_transform_options.md) |
17
+
18
+ ---
19
+
20
+ ## 1. Goal
21
+
22
+ Compose selected sections from the shared current fixture, rename a heading, promote heading levels, and insert a generated Summary section.
23
+
24
+ ## 2. Config
25
+
26
+ ```ruby
27
+ sources = MarkdownComposer.source_list do
28
+ current File.read("examples/fixtures/current.md")
29
+ end
30
+
31
+ plan = MarkdownComposer.plan do
32
+ from :current
33
+ select 'h2_section where title:equals("Feature Matrix")'
34
+ include "heading_title"
35
+ include "paragraph[first:1]"
36
+ set
37
+
38
+ transform "heading_2", "replace_text", "literal", {
39
+ "from" => "Feature Matrix",
40
+ "to" => "Feature Matrix Summary"
41
+ }
42
+
43
+ transform "heading", "heading_levels", "promote", {
44
+ "by" => 1
45
+ }
46
+
47
+ transform "paragraph[first:1]", "insert_after", "insert", {
48
+ "content" => "\n## Summary\n\nGenerated summary text.",
49
+ "as" => "paragraph"
50
+ }
51
+ end
52
+
53
+ result = MarkdownComposer.compose(sources: sources, plan: plan)
54
+ ```
55
+
56
+ ## 3. Expected Output
57
+
58
+ ```markdown
59
+ # Feature Matrix Summary
60
+
61
+ The table below is intended for table selection and table-row experiments.
62
+
63
+ ## Summary
64
+
65
+ Generated summary text.
66
+ ```
67
+
68
+ Runnable versions: [../../examples/standard_composer.rb](../../examples/standard_composer.rb) and [../../examples/complex_composer.rb](../../examples/complex_composer.rb).
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Markdown Composer YAML JSON Rows Example
3
+ type: examples
4
+ status: current
5
+ updated: 2026-06-07
6
+ description: Example for YAML, JSON, and row import/export with Markdown Composer.
7
+ ---
8
+
9
+ # Markdown Composer YAML JSON Rows Example
10
+
11
+ ### References
12
+
13
+ | What | Where |
14
+ |------|-------|
15
+ | Plan schema | [../reference/md_composer_reference_plan_schema.md](../reference/md_composer_reference_plan_schema.md) |
16
+ | Diagnostics | [../reference/md_composer_reference_diagnostics.md](../reference/md_composer_reference_diagnostics.md) |
17
+
18
+ ---
19
+
20
+ ## 1. YAML Config
21
+
22
+ ```yaml
23
+ output: markdown
24
+ compose:
25
+ - source: current
26
+ select: heading_2_section where title:equals("Overview")
27
+ include: all
28
+ action: set
29
+ ```
30
+
31
+ ```ruby
32
+ sources = MarkdownComposer.source_list do
33
+ current File.read("examples/fixtures/current.md")
34
+ end
35
+
36
+ config = MarkdownComposer.parse_yaml(yaml_string)
37
+ result = MarkdownComposer.compose(sources: sources, config: config)
38
+ ```
39
+
40
+ ## 2. JSON Config
41
+
42
+ ```ruby
43
+ json = MarkdownComposer.to_json(config)
44
+ config = MarkdownComposer.parse_json(json)
45
+ ```
46
+
47
+ ## 3. Rows
48
+
49
+ ```ruby
50
+ rows = MarkdownComposer.to_rows(MarkdownComposer::Plan.new(config))
51
+ plan = MarkdownComposer.parse_rows(rows)
52
+ ```
53
+
54
+ Rows are useful for table-like UIs and import/export workflows.
55
+
56
+ Runnable version: [../../examples/yaml_plan.rb](../../examples/yaml_plan.rb). YAML file: [../../examples/plans/basic.yml](../../examples/plans/basic.yml).