coradoc-mirror 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a1079e6734d1795dd52788ca44ac74475590dbf6ccb9a576a5fcf4ef92f020d
4
- data.tar.gz: ab04156585e16f2b4fa61337e3a9eca6b0f758ea82db4233c38f4422686fe611
3
+ metadata.gz: 0d0dddcebf58649933def45133c70a5ed3caf8f1441d1a789b9ea95d49fa8d24
4
+ data.tar.gz: 6275f1315af45cb267762a26862bdcb1d2bb65e29fd4657cd411a98200b6c0f9
5
5
  SHA512:
6
- metadata.gz: d3e532a097d574ac76f76c3ba863ad82fefc8c4007572a30c7d4c4bcad66f14008236a0ef9e4aca550c4f55b91f5dbc75740afac67aa2bcc18bce5c9aae0f0b9
7
- data.tar.gz: 7bf8e4d4c71e20cb6cb1f71ef4a6e9c5cb1109a81c4fc1b5e85a2b462af197e3f5801827ceb30bce5ed7ce5f897ca3c2300d9fa27db699ee5a9eb239da9d4272
6
+ metadata.gz: 13c8d02108886f582cf93f501a9e503361c450c224f0105e255583200323bd4d170d3303b2250510922ee4dad0aa92b45a987caf690528098f77d90b18e2672a
7
+ data.tar.gz: 3eef4445a831dfce49faaa0e777ad4cd28fb54d9d7b71db640e45585ea557267f87b831031839da32077bf6886ae53f9d085e65200ac6aa2cc939c393f93df1d
@@ -123,12 +123,56 @@ module Coradoc
123
123
  end
124
124
 
125
125
  def build_simple_mark(element, context, mark_class)
126
+ # When the mark carries parsed children (Bug 16B — nested
127
+ # inline marks like `**bold \`code\`**`), walk the children
128
+ # and apply this mark to each text leaf. Inner mark elements
129
+ # get the outer mark added to their marks list, producing
130
+ # ProseMirror's flat text-node-with-marks shape.
131
+ if element.children&.any?
132
+ return flatten_marked_children(element.children, [mark_class.new], context)
133
+ end
134
+
126
135
  text = extract_inline_text(element)
127
136
  return nil if text.empty?
128
137
 
129
138
  context.text_node(text, marks: [mark_class.new])
130
139
  end
131
140
 
141
+ # Walk a list of children, attaching the active set of marks
142
+ # to each text leaf. When a child is itself an InlineElement
143
+ # with its own mark (e.g. CodeElement inside BoldElement),
144
+ # the inner mark is added to the active set and recursion
145
+ # proceeds into its children. Produces the conjunction of
146
+ # marks for each text run that ProseMirror expects:
147
+ # **a `b` c** → text("a ", [bold]), text("b", [bold, code]), text(" c", [bold])
148
+ def flatten_marked_children(children, active_marks, context)
149
+ result = []
150
+ children.each do |child|
151
+ case child
152
+ when CoreModel::TextContent
153
+ next if child.text.nil? || child.text.empty?
154
+
155
+ result << context.text_node(child.text, marks: active_marks.dup)
156
+ when CoreModel::InlineElement
157
+ inner_mark_class = SIMPLE_MARK_TYPES[child.class]
158
+ if inner_mark_class && child.children&.any?
159
+ combined = active_marks + [inner_mark_class.new]
160
+ result.concat(flatten_marked_children(child.children, combined, context))
161
+ elsif inner_mark_class
162
+ text = extract_inline_text(child)
163
+ next if text.empty?
164
+
165
+ combined = active_marks + [inner_mark_class.new]
166
+ result << context.text_node(text, marks: combined)
167
+ else
168
+ nested = dispatch_inline(child, context)
169
+ result << nested if nested
170
+ end
171
+ end
172
+ end
173
+ result
174
+ end
175
+
132
176
  def build_link_mark(element, context)
133
177
  text = extract_inline_text(element)
134
178
  text = element.target.to_s if text.empty? && element.target
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module Mirror
5
- VERSION = '0.1.8'
5
+ VERSION = '0.1.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-mirror
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.