markly-merge 1.0.0 → 7.0.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/markly/merge/version.rb +3 -4
- data/lib/markly/merge.rb +485 -99
- data/lib/markly-merge.rb +1 -4
- data.tar.gz.sig +0 -0
- metadata +26 -284
- metadata.gz.sig +0 -0
- data/CHANGELOG.md +0 -87
- data/CITATION.cff +0 -20
- data/CODE_OF_CONDUCT.md +0 -134
- data/CONTRIBUTING.md +0 -227
- data/FUNDING.md +0 -74
- data/LICENSE.txt +0 -21
- data/README.md +0 -815
- data/REEK +0 -0
- data/RUBOCOP.md +0 -71
- data/SECURITY.md +0 -21
- data/lib/markly/merge/backend.rb +0 -422
- data/lib/markly/merge/debug_logger.rb +0 -26
- data/lib/markly/merge/file_analysis.rb +0 -53
- data/lib/markly/merge/freeze_node.rb +0 -32
- data/lib/markly/merge/smart_merger.rb +0 -159
- data/sig/markly/merge.rbs +0 -106
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2bc0c8d4bb0e436eae32e17d678a6c07f90ba5ae1d5f3c7aa8e50e2404b017bd
|
|
4
|
+
data.tar.gz: 38861c64bf98a31c6d675923b0ca661678bd58e5d593730e3c8d9ae9a700ae32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b378f15866f81c77510c908ef06c46698de471a2cca6c6d4f74b30e0490e623638fed9f5ecf67b8462bdd138e6a44c92e1e9b022f8ac76bf9f4459c14ea403ef
|
|
7
|
+
data.tar.gz: 3ab96bb04c38cceebe97b83dd758275334558ce7b6f42fbfaee896606edd7beb425e6ba961a1b4277a854087aaea378de3fc6db67a5200a1fa661dafbf0d6e15
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/markly/merge/version.rb
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Markly
|
|
4
4
|
module Merge
|
|
5
|
-
# Version information for Markly::Merge
|
|
6
5
|
module Version
|
|
7
|
-
|
|
8
|
-
VERSION = "1.0.0"
|
|
6
|
+
VERSION = "7.0.0"
|
|
9
7
|
end
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
VERSION = Version::VERSION
|
|
11
10
|
end
|
|
12
11
|
end
|
data/lib/markly/merge.rb
CHANGED
|
@@ -1,110 +1,496 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
require "markdown-merge"
|
|
4
4
|
require "markly"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
module Markly
|
|
7
|
+
module Merge
|
|
8
|
+
extend self
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
PACKAGE_NAME = "markly-merge"
|
|
11
|
+
BACKEND_REFERENCE = TreeHaver::BackendReference.new(id: "markly", family: "native").freeze
|
|
12
|
+
TreeHaver::BackendRegistry.register(BACKEND_REFERENCE)
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
def markdown_feature_profile
|
|
15
|
+
Markdown::Merge.markdown_feature_profile
|
|
16
|
+
end
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
# Markly::Merge provides intelligent merging of Markdown files by:
|
|
19
|
-
# - Parsing Markdown into AST using Markly (cmark-gfm) via tree_haver
|
|
20
|
-
# - Matching structural elements (headings, paragraphs, lists, etc.) between files
|
|
21
|
-
# - Preserving frozen sections marked with HTML comments
|
|
22
|
-
# - Resolving conflicts based on configurable preferences
|
|
23
|
-
#
|
|
24
|
-
# This is a thin wrapper around Markdown::Merge that:
|
|
25
|
-
# - Provides hard dependency on the markly gem
|
|
26
|
-
# - Sets markly-specific defaults (freeze token, inner_merge_code_blocks)
|
|
27
|
-
# - Exposes markly-specific options (flags, extensions)
|
|
28
|
-
# - Maintains API compatibility for existing users
|
|
29
|
-
#
|
|
30
|
-
# @example Basic merge
|
|
31
|
-
# merger = Markly::Merge::SmartMerger.new(template, destination)
|
|
32
|
-
# result = merger.merge
|
|
33
|
-
# puts result.content if result.success?
|
|
34
|
-
#
|
|
35
|
-
# @example With freeze blocks
|
|
36
|
-
# # In your Markdown file:
|
|
37
|
-
# # <!-- markly-merge:freeze -->
|
|
38
|
-
# # ## Custom Section
|
|
39
|
-
# # This content is preserved during merges.
|
|
40
|
-
# # <!-- markly-merge:unfreeze -->
|
|
41
|
-
#
|
|
42
|
-
# @see SmartMerger Main entry point for merging
|
|
43
|
-
# @see Markdown::Merge::SmartMerger Underlying implementation
|
|
44
|
-
module Merge
|
|
45
|
-
# Base error class for Markly::Merge
|
|
46
|
-
# Inherits from Markdown::Merge::Error for consistency across merge gems.
|
|
47
|
-
class Error < Markdown::Merge::Error; end
|
|
48
|
-
|
|
49
|
-
# Raised when a Markdown file has parsing errors.
|
|
50
|
-
# Inherits from Markdown::Merge::ParseError for consistency across merge gems.
|
|
51
|
-
class ParseError < Markdown::Merge::ParseError; end
|
|
52
|
-
|
|
53
|
-
# Raised when the template file has syntax errors.
|
|
54
|
-
class TemplateParseError < ParseError; end
|
|
55
|
-
|
|
56
|
-
# Raised when the destination file has syntax errors.
|
|
57
|
-
class DestinationParseError < ParseError; end
|
|
58
|
-
|
|
59
|
-
# Default freeze token for markly-merge
|
|
60
|
-
# @return [String]
|
|
61
|
-
DEFAULT_FREEZE_TOKEN = "markly-merge"
|
|
62
|
-
|
|
63
|
-
# Default inner_merge_code_blocks setting for markly-merge
|
|
64
|
-
# @return [Boolean]
|
|
65
|
-
DEFAULT_INNER_MERGE_CODE_BLOCKS = true
|
|
66
|
-
|
|
67
|
-
# Re-export shared classes from markdown-merge
|
|
68
|
-
# Re-export shared classes from markdown-merge
|
|
69
|
-
FileAligner = Markdown::Merge::FileAligner
|
|
70
|
-
ConflictResolver = Markdown::Merge::ConflictResolver
|
|
71
|
-
MergeResult = Markdown::Merge::MergeResult
|
|
72
|
-
TableMatchAlgorithm = Markdown::Merge::TableMatchAlgorithm
|
|
73
|
-
TableMatchRefiner = Markdown::Merge::TableMatchRefiner
|
|
74
|
-
CodeBlockMerger = Markdown::Merge::CodeBlockMerger
|
|
75
|
-
NodeTypeNormalizer = Markdown::Merge::NodeTypeNormalizer
|
|
76
|
-
|
|
77
|
-
autoload :DebugLogger, "markly/merge/debug_logger"
|
|
78
|
-
autoload :FreezeNode, "markly/merge/freeze_node"
|
|
79
|
-
autoload :FileAnalysis, "markly/merge/file_analysis"
|
|
80
|
-
autoload :SmartMerger, "markly/merge/smart_merger"
|
|
81
|
-
autoload :Backend, "markly/merge/backend"
|
|
82
|
-
|
|
83
|
-
# Eagerly load and register backend when this module is loaded
|
|
84
|
-
# This ensures the backend is available for tree_haver before any parsing happens
|
|
85
|
-
class << self
|
|
86
|
-
def ensure_backend_loaded!
|
|
87
|
-
Backend # Access constant to trigger autoload
|
|
88
|
-
end
|
|
18
|
+
def available_markdown_backends
|
|
19
|
+
[BACKEND_REFERENCE]
|
|
89
20
|
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
21
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
22
|
+
def markdown_backend_feature_profile(backend: nil)
|
|
23
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
24
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
25
|
+
|
|
26
|
+
markdown_feature_profile.merge(backend: BACKEND_REFERENCE.id, backend_ref: BACKEND_REFERENCE.to_h)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def markdown_plan_context(backend: nil)
|
|
30
|
+
profile = markdown_backend_feature_profile(backend: backend)
|
|
31
|
+
return profile if profile[:ok] == false
|
|
32
|
+
|
|
33
|
+
{
|
|
34
|
+
family_profile: markdown_feature_profile,
|
|
35
|
+
feature_profile: {
|
|
36
|
+
backend: profile[:backend],
|
|
37
|
+
supports_dialects: true,
|
|
38
|
+
supported_policies: []
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def markdown_structured_edit_provider_profile
|
|
44
|
+
{
|
|
45
|
+
package: PACKAGE_NAME,
|
|
46
|
+
backend: BACKEND_REFERENCE.id,
|
|
47
|
+
structured_edit_profile: {
|
|
48
|
+
family: "markdown",
|
|
49
|
+
structure_profile: Ast::Merge.structured_edit_structure_profile(
|
|
50
|
+
owner_scope: "heading_sections",
|
|
51
|
+
owner_selector: "heading_sections",
|
|
52
|
+
owner_selector_family: "section_branch",
|
|
53
|
+
known_owner_selector: true,
|
|
54
|
+
supported_comment_regions: [],
|
|
55
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
56
|
+
),
|
|
57
|
+
selection_profile: Ast::Merge.structured_edit_selection_profile(
|
|
58
|
+
owner_scope: "heading_sections",
|
|
59
|
+
owner_selector: "heading_sections",
|
|
60
|
+
owner_selector_family: "section_branch",
|
|
61
|
+
selector_kind: "heading_section",
|
|
62
|
+
selection_intent: "section_branch",
|
|
63
|
+
selection_intent_family: "section_branch",
|
|
64
|
+
known_selection_intent: true,
|
|
65
|
+
comment_region: nil,
|
|
66
|
+
include_trailing_gap: false,
|
|
67
|
+
comment_anchored: false,
|
|
68
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
69
|
+
),
|
|
70
|
+
match_profile: Ast::Merge.structured_edit_match_profile(
|
|
71
|
+
start_boundary: "owner_start",
|
|
72
|
+
start_boundary_family: "structural_owner",
|
|
73
|
+
known_start_boundary: true,
|
|
74
|
+
end_boundary: "owner_end",
|
|
75
|
+
end_boundary_family: "structural_owner",
|
|
76
|
+
known_end_boundary: true,
|
|
77
|
+
payload_kind: "section_branch",
|
|
78
|
+
payload_family: "section_branch",
|
|
79
|
+
known_payload_kind: true,
|
|
80
|
+
comment_anchored: false,
|
|
81
|
+
trailing_gap_extended: false,
|
|
82
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def markdown_structured_edit_request_projection
|
|
89
|
+
{
|
|
90
|
+
package: PACKAGE_NAME,
|
|
91
|
+
backend: BACKEND_REFERENCE.id,
|
|
92
|
+
structured_edit_request: Ast::Merge.structured_edit_request(
|
|
93
|
+
operation_kind: "replace",
|
|
94
|
+
content: "# Title\n\n## Synopsis\n\nOld synopsis.\n\n## Install\n\nInstall text.\n",
|
|
95
|
+
source_label: "README.md",
|
|
96
|
+
target_selector: "Synopsis@2",
|
|
97
|
+
target_selector_family: "section_branch",
|
|
98
|
+
target_selection: Ast::Merge.structured_edit_target_selection(
|
|
99
|
+
selector_kind: "heading_section",
|
|
100
|
+
selection_intent: "section_branch",
|
|
101
|
+
selection_intent_family: "section_branch",
|
|
102
|
+
known_selection_intent: true,
|
|
103
|
+
comment_region: nil,
|
|
104
|
+
include_trailing_gap: false,
|
|
105
|
+
comment_anchored: false,
|
|
106
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
107
|
+
),
|
|
108
|
+
target_match: Ast::Merge.structured_edit_target_match(
|
|
109
|
+
start_boundary: "owner_start",
|
|
110
|
+
start_boundary_family: "structural_owner",
|
|
111
|
+
known_start_boundary: true,
|
|
112
|
+
end_boundary: "owner_end",
|
|
113
|
+
end_boundary_family: "structural_owner",
|
|
114
|
+
known_end_boundary: true,
|
|
115
|
+
payload_kind: "section_branch",
|
|
116
|
+
payload_family: "section_branch",
|
|
117
|
+
known_payload_kind: true,
|
|
118
|
+
comment_anchored: false,
|
|
119
|
+
trailing_gap_extended: false,
|
|
120
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
121
|
+
),
|
|
122
|
+
payload_text: "## Synopsis\n\nNew synopsis.\n",
|
|
123
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def markdown_structured_edit_result_projection
|
|
129
|
+
{
|
|
130
|
+
package: PACKAGE_NAME,
|
|
131
|
+
backend: BACKEND_REFERENCE.id,
|
|
132
|
+
structured_edit_result: Ast::Merge.structured_edit_result(
|
|
133
|
+
operation_kind: "replace",
|
|
134
|
+
updated_content: "# Title\n\n## Synopsis\n\nNew synopsis.\n\n## Install\n\nInstall text.\n",
|
|
135
|
+
changed: true,
|
|
136
|
+
captured_text: "## Synopsis\n\nOld synopsis.\n",
|
|
137
|
+
match_count: 1,
|
|
138
|
+
operation_profile: Ast::Merge.structured_edit_operation_profile(
|
|
139
|
+
operation_kind: "replace",
|
|
140
|
+
operation_family: "rewrite",
|
|
141
|
+
known_operation_kind: true,
|
|
142
|
+
source_requirement: "required",
|
|
143
|
+
destination_requirement: "none",
|
|
144
|
+
replacement_source: "explicit_text",
|
|
145
|
+
captures_source_text: true,
|
|
146
|
+
supports_if_missing: false,
|
|
147
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
148
|
+
),
|
|
149
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def markdown_structured_edit_application_projection
|
|
155
|
+
{
|
|
156
|
+
package: PACKAGE_NAME,
|
|
157
|
+
backend: BACKEND_REFERENCE.id,
|
|
158
|
+
structured_edit_application: Ast::Merge.structured_edit_application(
|
|
159
|
+
request: markdown_structured_edit_request_projection[:structured_edit_request],
|
|
160
|
+
result: markdown_structured_edit_result_projection[:structured_edit_result],
|
|
161
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def markdown_structured_edit_execution_report_projection
|
|
167
|
+
{
|
|
168
|
+
package: PACKAGE_NAME,
|
|
169
|
+
backend: BACKEND_REFERENCE.id,
|
|
170
|
+
structured_edit_execution_report: Ast::Merge.structured_edit_execution_report(
|
|
171
|
+
application: markdown_structured_edit_application_projection[:structured_edit_application],
|
|
172
|
+
provider_family: "markdown",
|
|
173
|
+
provider_backend: BACKEND_REFERENCE.id,
|
|
174
|
+
diagnostics: [],
|
|
175
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def markdown_structured_edit_batch_request_projection
|
|
181
|
+
content = "# Title\n\n## Synopsis\n\nOld synopsis.\n\n## Usage\n\nExisting text.\n\n## Deprecated\n\nDeprecated text.\n"
|
|
182
|
+
{
|
|
183
|
+
package: PACKAGE_NAME,
|
|
184
|
+
backend: BACKEND_REFERENCE.id,
|
|
185
|
+
structured_edit_batch_request: Ast::Merge.structured_edit_batch_request(
|
|
186
|
+
requests: [
|
|
187
|
+
Ast::Merge.structured_edit_request(
|
|
188
|
+
operation_kind: "replace",
|
|
189
|
+
content: content,
|
|
190
|
+
source_label: "README.md",
|
|
191
|
+
target_selector: "Synopsis@2",
|
|
192
|
+
target_selector_family: "section_branch",
|
|
193
|
+
payload_text: "## Synopsis\n\nNew synopsis.\n",
|
|
194
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
195
|
+
),
|
|
196
|
+
Ast::Merge.structured_edit_request(
|
|
197
|
+
operation_kind: "insert",
|
|
198
|
+
content: content,
|
|
199
|
+
source_label: "source",
|
|
200
|
+
destination_selector: "/heading/usage",
|
|
201
|
+
destination_selector_family: "section_branch",
|
|
202
|
+
payload_text: "### Managed Usage\n\nInserted usage text.\n",
|
|
203
|
+
if_missing: "append",
|
|
204
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
205
|
+
),
|
|
206
|
+
Ast::Merge.structured_edit_request(
|
|
207
|
+
operation_kind: "delete",
|
|
208
|
+
content: content,
|
|
209
|
+
source_label: "README.md",
|
|
210
|
+
target_selector: "Deprecated@2",
|
|
211
|
+
target_selector_family: "section_branch",
|
|
212
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
213
|
+
)
|
|
214
|
+
],
|
|
215
|
+
metadata: { batch_label: "markdown_markly_triad", source: "legacy_crispr_reference" }
|
|
216
|
+
)
|
|
217
|
+
}
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def markdown_structured_edit_batch_report_projection
|
|
221
|
+
content = "# Title\n\n## Synopsis\n\nOld synopsis.\n\n## Usage\n\nExisting text.\n\n## Deprecated\n\nDeprecated text.\n"
|
|
222
|
+
{
|
|
223
|
+
package: PACKAGE_NAME,
|
|
224
|
+
backend: BACKEND_REFERENCE.id,
|
|
225
|
+
structured_edit_batch_report: Ast::Merge.structured_edit_batch_report(
|
|
226
|
+
reports: [
|
|
227
|
+
Ast::Merge.structured_edit_execution_report(
|
|
228
|
+
application: Ast::Merge.structured_edit_application(
|
|
229
|
+
request: Ast::Merge.structured_edit_request(
|
|
230
|
+
operation_kind: "replace",
|
|
231
|
+
content: content,
|
|
232
|
+
source_label: "README.md",
|
|
233
|
+
target_selector: "Synopsis@2",
|
|
234
|
+
target_selector_family: "section_branch",
|
|
235
|
+
payload_text: "## Synopsis\n\nNew synopsis.\n",
|
|
236
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
237
|
+
),
|
|
238
|
+
result: Ast::Merge.structured_edit_result(
|
|
239
|
+
operation_kind: "replace",
|
|
240
|
+
updated_content: "# Title\n\n## Synopsis\n\nNew synopsis.\n\n## Usage\n\nExisting text.\n\n## Deprecated\n\nDeprecated text.\n",
|
|
241
|
+
changed: true,
|
|
242
|
+
captured_text: "## Synopsis\n\nOld synopsis.\n",
|
|
243
|
+
match_count: 1,
|
|
244
|
+
operation_profile: Ast::Merge.structured_edit_operation_profile(
|
|
245
|
+
operation_kind: "replace",
|
|
246
|
+
operation_family: "rewrite",
|
|
247
|
+
known_operation_kind: true,
|
|
248
|
+
source_requirement: "required",
|
|
249
|
+
destination_requirement: "none",
|
|
250
|
+
replacement_source: "explicit_text",
|
|
251
|
+
captures_source_text: true,
|
|
252
|
+
supports_if_missing: false,
|
|
253
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
254
|
+
),
|
|
255
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
256
|
+
),
|
|
257
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
258
|
+
),
|
|
259
|
+
provider_family: "markdown",
|
|
260
|
+
provider_backend: BACKEND_REFERENCE.id,
|
|
261
|
+
diagnostics: [],
|
|
262
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
263
|
+
),
|
|
264
|
+
Ast::Merge.structured_edit_execution_report(
|
|
265
|
+
application: Ast::Merge.structured_edit_application(
|
|
266
|
+
request: Ast::Merge.structured_edit_request(
|
|
267
|
+
operation_kind: "insert",
|
|
268
|
+
content: content,
|
|
269
|
+
source_label: "source",
|
|
270
|
+
destination_selector: "/heading/usage",
|
|
271
|
+
destination_selector_family: "section_branch",
|
|
272
|
+
payload_text: "### Managed Usage\n\nInserted usage text.\n",
|
|
273
|
+
if_missing: "append",
|
|
274
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
275
|
+
),
|
|
276
|
+
result: Ast::Merge.structured_edit_result(
|
|
277
|
+
operation_kind: "insert",
|
|
278
|
+
updated_content: "# Title\n\n## Synopsis\n\nOld synopsis.\n\n## Usage\n\nExisting text.\n### Managed Usage\n\nInserted usage text.\n\n## Deprecated\n\nDeprecated text.\n",
|
|
279
|
+
changed: true,
|
|
280
|
+
operation_profile: Ast::Merge.structured_edit_operation_profile(
|
|
281
|
+
operation_kind: "insert",
|
|
282
|
+
operation_family: "insertion",
|
|
283
|
+
known_operation_kind: true,
|
|
284
|
+
source_requirement: "none",
|
|
285
|
+
destination_requirement: "optional",
|
|
286
|
+
replacement_source: "explicit_text",
|
|
287
|
+
captures_source_text: false,
|
|
288
|
+
supports_if_missing: true,
|
|
289
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
290
|
+
),
|
|
291
|
+
destination_profile: Ast::Merge.structured_edit_destination_profile(
|
|
292
|
+
resolution_kind: "append_fallback",
|
|
293
|
+
resolution_source: "none",
|
|
294
|
+
anchor_boundary: "none",
|
|
295
|
+
resolution_family: "append",
|
|
296
|
+
resolution_source_family: "implicit",
|
|
297
|
+
anchor_boundary_family: "none",
|
|
298
|
+
known_resolution_kind: true,
|
|
299
|
+
known_resolution_source: true,
|
|
300
|
+
known_anchor_boundary: true,
|
|
301
|
+
used_if_missing: true,
|
|
302
|
+
metadata: { family: "shared", source: "legacy_crispr_reference" }
|
|
303
|
+
),
|
|
304
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
305
|
+
),
|
|
306
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
307
|
+
),
|
|
308
|
+
provider_family: "markdown",
|
|
309
|
+
provider_backend: BACKEND_REFERENCE.id,
|
|
310
|
+
diagnostics: [],
|
|
311
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
312
|
+
),
|
|
313
|
+
Ast::Merge.structured_edit_execution_report(
|
|
314
|
+
application: Ast::Merge.structured_edit_application(
|
|
315
|
+
request: Ast::Merge.structured_edit_request(
|
|
316
|
+
operation_kind: "delete",
|
|
317
|
+
content: content,
|
|
318
|
+
source_label: "README.md",
|
|
319
|
+
target_selector: "Deprecated@2",
|
|
320
|
+
target_selector_family: "section_branch",
|
|
321
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
322
|
+
),
|
|
323
|
+
result: Ast::Merge.structured_edit_result(
|
|
324
|
+
operation_kind: "delete",
|
|
325
|
+
updated_content: "# Title\n\n## Synopsis\n\nOld synopsis.\n\n## Usage\n\nExisting text.\n",
|
|
326
|
+
changed: true,
|
|
327
|
+
captured_text: "## Deprecated\n\nDeprecated text.\n",
|
|
328
|
+
match_count: 1,
|
|
329
|
+
operation_profile: Ast::Merge.structured_edit_operation_profile(
|
|
330
|
+
operation_kind: "delete",
|
|
331
|
+
operation_family: "removal",
|
|
332
|
+
known_operation_kind: true,
|
|
333
|
+
source_requirement: "required",
|
|
334
|
+
destination_requirement: "none",
|
|
335
|
+
replacement_source: "none",
|
|
336
|
+
captures_source_text: true,
|
|
337
|
+
supports_if_missing: false,
|
|
338
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
339
|
+
),
|
|
340
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
341
|
+
),
|
|
342
|
+
metadata: { family: "markdown", provider: BACKEND_REFERENCE.id, source: "legacy_crispr_reference" }
|
|
343
|
+
),
|
|
344
|
+
provider_family: "markdown",
|
|
345
|
+
provider_backend: BACKEND_REFERENCE.id,
|
|
346
|
+
diagnostics: [],
|
|
347
|
+
metadata: { source: "legacy_crispr_reference" }
|
|
348
|
+
)
|
|
349
|
+
],
|
|
350
|
+
diagnostics: [
|
|
351
|
+
{
|
|
352
|
+
severity: "info",
|
|
353
|
+
category: "assumed_default",
|
|
354
|
+
message: "markdown batch preserved request ordering."
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
metadata: { batch_label: "markdown_markly_triad", source: "legacy_crispr_reference" }
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def parse_markdown(source, dialect, backend: nil)
|
|
363
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
364
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
107
365
|
|
|
108
|
-
Markly::
|
|
109
|
-
|
|
366
|
+
::Markly.parse(source, flags: ::Markly::DEFAULT, extensions: [:table])
|
|
367
|
+
normalized = Markdown::Merge.normalize_source(source)
|
|
368
|
+
{
|
|
369
|
+
ok: true,
|
|
370
|
+
diagnostics: [],
|
|
371
|
+
analysis: {
|
|
372
|
+
kind: "markdown",
|
|
373
|
+
dialect: dialect,
|
|
374
|
+
normalized_source: normalized,
|
|
375
|
+
root_kind: "document",
|
|
376
|
+
owners: Markdown::Merge.collect_markdown_owners(normalized)
|
|
377
|
+
},
|
|
378
|
+
policies: []
|
|
379
|
+
}
|
|
380
|
+
rescue StandardError => e
|
|
381
|
+
{
|
|
382
|
+
ok: false,
|
|
383
|
+
diagnostics: [{ severity: "error", category: "parse_error", message: e.message }],
|
|
384
|
+
policies: []
|
|
385
|
+
}
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def match_markdown_owners(template, destination)
|
|
389
|
+
Markdown::Merge.match_markdown_owners(template, destination)
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def merge_markdown(template_source, destination_source, dialect, backend: nil)
|
|
393
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
394
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
395
|
+
|
|
396
|
+
Markdown::Merge.merge_markdown(template_source, destination_source, dialect)
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def merge_markdown_with_reviewed_nested_outputs(template_source, destination_source, dialect, review_state, applied_children, backend: nil)
|
|
400
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
401
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
402
|
+
|
|
403
|
+
Markdown::Merge.merge_markdown_with_reviewed_nested_outputs(
|
|
404
|
+
template_source,
|
|
405
|
+
destination_source,
|
|
406
|
+
dialect,
|
|
407
|
+
review_state,
|
|
408
|
+
applied_children
|
|
409
|
+
)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
def merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(template_source, destination_source, dialect, replay_bundle, backend: nil)
|
|
413
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
414
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
415
|
+
|
|
416
|
+
Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(
|
|
417
|
+
template_source,
|
|
418
|
+
destination_source,
|
|
419
|
+
dialect,
|
|
420
|
+
replay_bundle
|
|
421
|
+
)
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(template_source, destination_source, dialect, envelope, backend: nil)
|
|
425
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
426
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
427
|
+
|
|
428
|
+
Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(
|
|
429
|
+
template_source,
|
|
430
|
+
destination_source,
|
|
431
|
+
dialect,
|
|
432
|
+
envelope
|
|
433
|
+
)
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
def merge_markdown_with_reviewed_nested_outputs_from_review_state(template_source, destination_source, dialect, review_state, backend: nil)
|
|
437
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
438
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
439
|
+
|
|
440
|
+
Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state(
|
|
441
|
+
template_source,
|
|
442
|
+
destination_source,
|
|
443
|
+
dialect,
|
|
444
|
+
review_state
|
|
445
|
+
)
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(template_source, destination_source, dialect, envelope, backend: nil)
|
|
449
|
+
requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s
|
|
450
|
+
return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id
|
|
451
|
+
|
|
452
|
+
Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(
|
|
453
|
+
template_source,
|
|
454
|
+
destination_source,
|
|
455
|
+
dialect,
|
|
456
|
+
envelope
|
|
457
|
+
)
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
def markdown_embedded_families(analysis)
|
|
461
|
+
Markdown::Merge.markdown_embedded_families(analysis)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
def unsupported_feature_result(message)
|
|
465
|
+
{
|
|
466
|
+
ok: false,
|
|
467
|
+
diagnostics: [{ severity: "error", category: "unsupported_feature", message: message }],
|
|
468
|
+
policies: []
|
|
469
|
+
}
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
module_function(
|
|
473
|
+
:markdown_feature_profile,
|
|
474
|
+
:available_markdown_backends,
|
|
475
|
+
:markdown_backend_feature_profile,
|
|
476
|
+
:markdown_plan_context,
|
|
477
|
+
:markdown_structured_edit_provider_profile,
|
|
478
|
+
:markdown_structured_edit_request_projection,
|
|
479
|
+
:markdown_structured_edit_result_projection,
|
|
480
|
+
:markdown_structured_edit_application_projection,
|
|
481
|
+
:markdown_structured_edit_execution_report_projection,
|
|
482
|
+
:markdown_structured_edit_batch_request_projection,
|
|
483
|
+
:markdown_structured_edit_batch_report_projection,
|
|
484
|
+
:parse_markdown,
|
|
485
|
+
:match_markdown_owners,
|
|
486
|
+
:merge_markdown,
|
|
487
|
+
:merge_markdown_with_reviewed_nested_outputs,
|
|
488
|
+
:merge_markdown_with_reviewed_nested_outputs_from_replay_bundle,
|
|
489
|
+
:merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope,
|
|
490
|
+
:merge_markdown_with_reviewed_nested_outputs_from_review_state,
|
|
491
|
+
:merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope,
|
|
492
|
+
:markdown_embedded_families,
|
|
493
|
+
:unsupported_feature_result
|
|
494
|
+
)
|
|
495
|
+
end
|
|
110
496
|
end
|
data/lib/markly-merge.rb
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
# See: https://github.com/fxn/zeitwerk#for_gem_extension
|
|
5
|
-
# Hook for other libraries to load this library (e.g. via bundler)
|
|
6
|
-
require "markly/merge"
|
|
3
|
+
require_relative "markly/merge"
|
data.tar.gz.sig
CHANGED
|
Binary file
|