11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/motion-markdown-it/rules_core/text_join.rb', line 11
def self.text_join(state)
blockTokens = state.tokens
(0...blockTokens.length).each do |j|
next if (blockTokens[j].type != 'inline')
tokens = blockTokens[j].children
max = tokens.length
(0...max).each do |curr|
if (tokens[curr].type == 'text_special')
tokens[curr].type = 'text'
end
end
last = 0
curr = 0
while curr < max
if (tokens[curr].type == 'text' &&
curr + 1 < max &&
tokens[curr + 1].type == 'text')
tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content
else
tokens[last] = tokens[curr] if (curr != last)
last += 1
end
curr += 1
end
if (curr != last)
tokens.pop(tokens.length - last)
end
end
end
|