Commit f4668131eed707c522f44eb320da462cb134ab9b

Authored by Andrey Karpikov
1 parent 297c0cf9

check new line

@@ -217,9 +217,7 @@ module Kanjai @@ -217,9 +217,7 @@ module Kanjai
217 elements.each do |item| 217 elements.each do |item|
218 case item[:name] 218 case item[:name]
219 when 'text' 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 when 'repeat' 221 when 'repeat'
224 repeat_id = item[:attributes]['id'] 222 repeat_id = item[:attributes]['id']
225 @repeat_type_index[repeat_id] ||= 0 223 @repeat_type_index[repeat_id] ||= 0
@@ -275,7 +273,7 @@ module Kanjai @@ -275,7 +273,7 @@ module Kanjai
275 end 273 end
276 elsif item[:name] == 'p' 274 elsif item[:name] == 'p'
277 if item[:children].count > 0 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 end 277 end
280 else 278 else
281 subparts.send(item[:name], attributes) do |next_subparts| 279 subparts.send(item[:name], attributes) do |next_subparts|
@@ -317,12 +315,15 @@ module Kanjai @@ -317,12 +315,15 @@ module Kanjai
317 end 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 new_text = text.dup 319 new_text = text.dup
322 if !hash_value.nil? and !text.nil? 320 if !hash_value.nil? and !text.nil?
323 hash_value.each do |key, value| 321 hash_value.each do |key, value|
324 if !key.nil? and !value.nil? 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 end 327 end
327 end 328 end
328 end 329 end
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.298" 2 + VERSION = "0.0.299"
3 end 3 end