Commit f4668131eed707c522f44eb320da462cb134ab9b

Authored by Andrey Karpikov
1 parent 297c0cf9

check new line

... ... @@ -217,9 +217,7 @@ module Kanjai
217 217 elements.each do |item|
218 218 case item[:name]
219 219 when 'text'
220   - p '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
221   - p subparts.parent.name
222   - subparts << self.replace_text_marker(item[:source], hash_value)
  220 + subparts << self.replace_text_marker(subparts.parent.name, item[:source], hash_value)
223 221 when 'repeat'
224 222 repeat_id = item[:attributes]['id']
225 223 @repeat_type_index[repeat_id] ||= 0
... ... @@ -275,7 +273,7 @@ module Kanjai
275 273 end
276 274 elsif item[:name] == 'p'
277 275 if item[:children].count > 0
278   - subparts.p(attributes, self.replace_text_marker(item[:children][0][:source], hash_value).html_safe)
  276 + subparts.p(attributes, self.replace_text_marker('p', item[:children][0][:source], hash_value).html_safe)
279 277 end
280 278 else
281 279 subparts.send(item[:name], attributes) do |next_subparts|
... ... @@ -317,12 +315,15 @@ module Kanjai
317 315 end
318 316
319 317
320   - def self.replace_text_marker(text, hash_value)
  318 + def self.replace_text_marker(parent_node_name, text, hash_value)
321 319 new_text = text.dup
322 320 if !hash_value.nil? and !text.nil?
323 321 hash_value.each do |key, value|
324 322 if !key.nil? and !value.nil?
325   - new_text.gsub!(key, value.gsub(/\r\n/, "#newline#"))
  323 + work_value = value
  324 + work_value.gsub!(/\r\n/, "#newline#") if !['code', 'pre'].include?(parent_node_name)
  325 +
  326 + new_text.gsub!(key, work_value)
326 327 end
327 328 end
328 329 end
... ...
1 1 module Kanjai
2   - VERSION = "0.0.298"
  2 + VERSION = "0.0.299"
3 3 end
... ...