Module: Commonmarker::Merge
- Extended by:
- Merge
- Included in:
- Merge
- Defined in:
- lib/commonmarker/merge.rb,
lib/commonmarker/merge/version.rb
Defined Under Namespace
Modules: Version
Constant Summary collapse
- PACKAGE_NAME =
"commonmarker-merge"- BACKEND_REFERENCE =
TreeHaver::BackendReference.new(id: "commonmarker", family: "native").freeze
- VERSION =
Version::VERSION
Class Method Summary collapse
- .available_markdown_backends ⇒ Object
- .markdown_backend_feature_profile(backend: nil) ⇒ Object
- .markdown_embedded_families(analysis) ⇒ Object
- .markdown_feature_profile ⇒ Object
- .markdown_plan_context(backend: nil) ⇒ Object
- .match_markdown_owners(template, destination) ⇒ Object
- .merge_markdown(template_source, destination_source, dialect, backend: nil) ⇒ Object
- .merge_markdown_with_reviewed_nested_outputs(template_source, destination_source, dialect, review_state, applied_children, backend: nil) ⇒ Object
- .merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(template_source, destination_source, dialect, replay_bundle, backend: nil) ⇒ Object
- .merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
- .merge_markdown_with_reviewed_nested_outputs_from_review_state(template_source, destination_source, dialect, review_state, backend: nil) ⇒ Object
- .merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
- .parse_markdown(source, dialect, backend: nil) ⇒ Object
- .unsupported_feature_result(message) ⇒ Object
Class Method Details
.available_markdown_backends ⇒ Object
18 19 20 |
# File 'lib/commonmarker/merge.rb', line 18 def available_markdown_backends [BACKEND_REFERENCE] end |
.markdown_backend_feature_profile(backend: nil) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/commonmarker/merge.rb', line 22 def markdown_backend_feature_profile(backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id markdown_feature_profile.merge(backend: BACKEND_REFERENCE.id, backend_ref: BACKEND_REFERENCE.to_h) end |
.markdown_embedded_families(analysis) ⇒ Object
141 142 143 |
# File 'lib/commonmarker/merge.rb', line 141 def (analysis) Markdown::Merge.(analysis) end |
.markdown_feature_profile ⇒ Object
14 15 16 |
# File 'lib/commonmarker/merge.rb', line 14 def markdown_feature_profile Markdown::Merge.markdown_feature_profile end |
.markdown_plan_context(backend: nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/commonmarker/merge.rb', line 29 def markdown_plan_context(backend: nil) profile = markdown_backend_feature_profile(backend: backend) return profile if profile[:ok] == false { family_profile: markdown_feature_profile, feature_profile: { backend: profile[:backend], supports_dialects: true, supported_policies: [] } } end |
.match_markdown_owners(template, destination) ⇒ Object
69 70 71 |
# File 'lib/commonmarker/merge.rb', line 69 def match_markdown_owners(template, destination) Markdown::Merge.match_markdown_owners(template, destination) end |
.merge_markdown(template_source, destination_source, dialect, backend: nil) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/commonmarker/merge.rb', line 73 def merge_markdown(template_source, destination_source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown(template_source, destination_source, dialect) end |
.merge_markdown_with_reviewed_nested_outputs(template_source, destination_source, dialect, review_state, applied_children, backend: nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/commonmarker/merge.rb', line 80 def merge_markdown_with_reviewed_nested_outputs(template_source, destination_source, dialect, review_state, applied_children, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown_with_reviewed_nested_outputs( template_source, destination_source, dialect, review_state, applied_children ) end |
.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(template_source, destination_source, dialect, replay_bundle, backend: nil) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/commonmarker/merge.rb', line 93 def merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(template_source, destination_source, dialect, replay_bundle, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle( template_source, destination_source, dialect, replay_bundle ) end |
.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/commonmarker/merge.rb', line 105 def merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(template_source, destination_source, dialect, envelope, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope( template_source, destination_source, dialect, envelope ) end |
.merge_markdown_with_reviewed_nested_outputs_from_review_state(template_source, destination_source, dialect, review_state, backend: nil) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/commonmarker/merge.rb', line 117 def merge_markdown_with_reviewed_nested_outputs_from_review_state(template_source, destination_source, dialect, review_state, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state( template_source, destination_source, dialect, review_state ) end |
.merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/commonmarker/merge.rb', line 129 def merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(template_source, destination_source, dialect, envelope, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope( template_source, destination_source, dialect, envelope ) end |
.parse_markdown(source, dialect, backend: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/commonmarker/merge.rb', line 43 def parse_markdown(source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s return unsupported_feature_result("Unsupported Markdown backend #{requested}.") unless requested == BACKEND_REFERENCE.id ::Commonmarker.parse(source) normalized = Markdown::Merge.normalize_source(source) { ok: true, diagnostics: [], analysis: { kind: "markdown", dialect: dialect, normalized_source: normalized, root_kind: "document", owners: Markdown::Merge.collect_markdown_owners(normalized) }, policies: [] } rescue StandardError => e { ok: false, diagnostics: [{ severity: "error", category: "parse_error", message: e. }], policies: [] } end |
.unsupported_feature_result(message) ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/commonmarker/merge.rb', line 145 def unsupported_feature_result() { ok: false, diagnostics: [{ severity: "error", category: "unsupported_feature", message: }], policies: [] } end |