Module: Kramdown::Merge
- Defined in:
- lib/kramdown/merge.rb,
lib/kramdown/merge/backend.rb,
lib/kramdown/merge/version.rb,
sig/kramdown/merge.rbs
Defined Under Namespace
Constant Summary collapse
- PACKAGE_NAME =
'kramdown-merge'- BACKEND_REFERENCE =
TreeHaver::BackendReference.new(id: 'kramdown', family: 'native').freeze
- VERSION =
Current gem version exposed at the traditional constant location.
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
19 20 21 |
# File 'lib/kramdown/merge.rb', line 19 def available_markdown_backends [BACKEND_REFERENCE] end |
.markdown_backend_feature_profile(backend: nil) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/kramdown/merge.rb', line 23 def markdown_backend_feature_profile(backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end markdown_feature_profile.merge(backend: BACKEND_REFERENCE.id, backend_ref: BACKEND_REFERENCE.to_h) end |
.markdown_embedded_families(analysis) ⇒ Object
170 171 172 |
# File 'lib/kramdown/merge.rb', line 170 def (analysis) Markdown::Merge.(analysis) end |
.markdown_feature_profile ⇒ Object
15 16 17 |
# File 'lib/kramdown/merge.rb', line 15 def markdown_feature_profile Markdown::Merge.markdown_feature_profile end |
.markdown_plan_context(backend: nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kramdown/merge.rb', line 32 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
76 77 78 |
# File 'lib/kramdown/merge.rb', line 76 def match_markdown_owners(template, destination) Markdown::Merge.match_markdown_owners(template, destination) end |
.merge_markdown(template_source, destination_source, dialect, backend: nil) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/kramdown/merge.rb', line 80 def merge_markdown(template_source, destination_source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown(template_source, destination_source, dialect, backend: BACKEND_REFERENCE.id) end |
.merge_markdown_with_reviewed_nested_outputs(template_source, destination_source, dialect, review_state, applied_children, backend: nil) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kramdown/merge.rb', line 89 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 unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown_with_reviewed_nested_outputs( template_source, destination_source, dialect, review_state, applied_children, backend: BACKEND_REFERENCE.id ) end |
.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle(template_source, destination_source, dialect, replay_bundle, backend: nil) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/kramdown/merge.rb', line 106 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 unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle( template_source, destination_source, dialect, replay_bundle, backend: BACKEND_REFERENCE.id ) end |
.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/kramdown/merge.rb', line 122 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 unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_replay_bundle_envelope( template_source, destination_source, dialect, envelope, backend: BACKEND_REFERENCE.id ) end |
.merge_markdown_with_reviewed_nested_outputs_from_review_state(template_source, destination_source, dialect, review_state, backend: nil) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/kramdown/merge.rb', line 138 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 unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state( template_source, destination_source, dialect, review_state, backend: BACKEND_REFERENCE.id ) end |
.merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope(template_source, destination_source, dialect, envelope, backend: nil) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/kramdown/merge.rb', line 154 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 unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end Markdown::Merge.merge_markdown_with_reviewed_nested_outputs_from_review_state_envelope( template_source, destination_source, dialect, envelope, backend: BACKEND_REFERENCE.id ) end |
.parse_markdown(source, dialect, backend: nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/kramdown/merge.rb', line 46 def parse_markdown(source, dialect, backend: nil) requested = backend.to_s.empty? ? BACKEND_REFERENCE.id : backend.to_s unless requested == BACKEND_REFERENCE.id return unsupported_feature_result("Unsupported Markdown backend #{requested}.") end return unsupported_feature_result("Unsupported Markdown dialect #{dialect}.") unless dialect == 'markdown' TreeHaver.with_backend(BACKEND_REFERENCE.id) { TreeHaver.parser_for(:markdown).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
174 175 176 177 178 179 180 |
# File 'lib/kramdown/merge.rb', line 174 def unsupported_feature_result() { ok: false, diagnostics: [{ severity: 'error', category: 'unsupported_feature', message: }], policies: [] } end |