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
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/touch_up.rb', line 18
def to_html
@origin.
gsub(%r@(\*([^\*]+)\*\s+)?([^\.\s]+\.[^\.\s]+[^\s]+[^\.\s])@) { |full, match|
text = $2
raw_link = Escape_Escape_Escape.decode_html($3)
link = (raw_link).first
if !link
full
else
append = raw_link.sub(link, NOTHING)
short_link = link
clean_short_link = Escape_Escape_Escape.html(short_link)
if !link['://']
link = 'http://' + link
end
begin
clean_link = Escape_Escape_Escape.href(link)
if text
"<a href=\"#{clean_link}\">#{text}</a>#{append}"
else
"<a href=\"#{clean_link}\">#{clean_short_link}</a>#{append}"
end
rescue Escape_Escape_Escape::Invalid_HREF
full
end
end
}.
gsub(/([\*\/\-\~]{1,2})([^\1\<\>]+)(\1)/) { |full, match|
case
when $1 == $3 && $1 == '/'
"<i>#{$2}</i>"
when $1 == '~~' && $3 == '~~'
"<del>#{$2}</del>"
when $1 == $3 && $1 == '*'
"<strong>#{$2}</strong>"
else
full
end
}
end
|