| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package App::Asciio::Markup ; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require Exporter ; |
|
5
|
|
|
|
|
|
|
@ISA = qw(Exporter) ; |
|
6
|
|
|
|
|
|
|
@EXPORT = qw( |
|
7
|
|
|
|
|
|
|
$USE_MARKUP_CLASS |
|
8
|
|
|
|
|
|
|
) ; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$|++ ; |
|
11
|
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
30
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
160
|
|
|
13
|
4
|
|
|
4
|
|
55
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
292
|
|
|
14
|
4
|
|
|
4
|
|
28
|
use utf8; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
51
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
177
|
use App::Asciio::String ; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
1601
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our ($USE_MARKUP_CLASS) ; |
|
20
|
|
|
|
|
|
|
$USE_MARKUP_CLASS = App::Asciio::Markup->new() ; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
|
25
|
4
|
|
|
4
|
0
|
9
|
my $class = shift ; |
|
26
|
4
|
|
|
|
|
8
|
my $self = {} ; |
|
27
|
4
|
|
|
|
|
11
|
bless $self, $class ; |
|
28
|
4
|
|
|
|
|
11
|
return $self ; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub use_markup |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
0
|
|
|
0
|
0
|
0
|
my ($use_it) = @_ ; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
0
|
if($use_it eq 'zimwiki') |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
0
|
|
|
|
|
0
|
$USE_MARKUP_CLASS = App::Asciio::Zimwiki->new() ; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
$USE_MARKUP_CLASS = App::Asciio::Markup->new() ; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
48
|
|
|
|
|
|
|
|
|
49
|
1169
|
|
|
1169
|
0
|
2103
|
sub delete_markup_characters { my ($self, $string) = @_ ; return $string ; } |
|
|
1169
|
|
|
|
|
2393
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
0
|
0
|
|
sub get_markup_coordinates { ; } |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get_markup_characters_array |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
0
|
|
|
0
|
0
|
|
my ($self, $markup_coordinate, @lines) = @_ ; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return (@lines) ; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub ui_show_markup_characters |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
0
|
|
|
0
|
0
|
|
my ($self, $layout, $font_size, $line) = @_ ; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$layout->set_text($line) ; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
74
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
package App::Asciio::Zimwiki ; |
|
77
|
4
|
|
|
4
|
|
34
|
use base qw/App::Asciio::Markup/ ; |
|
|
4
|
|
|
|
|
21
|
|
|
|
4
|
|
|
|
|
592
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
4
|
|
|
4
|
|
3341
|
use Memoize ; |
|
|
4
|
|
|
|
|
13212
|
|
|
|
4
|
|
|
|
|
6536
|
|
|
80
|
|
|
|
|
|
|
memoize('convert_markup_string') ; |
|
81
|
|
|
|
|
|
|
memoize('del_markup_characters') ; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub is_markup_string |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
0
|
|
|
my ($string) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
0
|
|
|
|
return ( $string =~ /(<[bius]>)+([^<]+)(<\/[bius]>)+/ |
|
90
|
|
|
|
|
|
|
|| $string =~ /([^<]+)<\/span>/) ; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub del_markup_characters |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
my ($string) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$string =~ s/|<\/span>|<\/?[bius]>//g ; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
return $string; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub delete_markup_characters |
|
107
|
|
|
|
|
|
|
{ |
|
108
|
0
|
|
|
0
|
|
|
my ($self, $string) = @_; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return del_markup_characters($string); |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
114
|
|
|
|
|
|
|
sub get_markup_coordinates |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
0
|
|
|
0
|
|
|
my ($self, $element_x, $strip_line, $strip_x, $y) = @_ ; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
my %markup_coordinate ; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
if(is_markup_string($strip_line)) |
|
121
|
|
|
|
|
|
|
{ |
|
122
|
0
|
|
|
|
|
|
my $ori_x = 0; |
|
123
|
0
|
|
|
|
|
|
while($strip_line =~ /(<\/?[bius]>)+|<\/span>|/g) |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
0
|
|
|
|
|
|
my $sub_str = substr($strip_line, 0, pos($strip_line)); |
|
126
|
0
|
|
|
|
|
|
$ori_x = $element_x + $strip_x + App::Asciio::String::unicode_length($sub_str) ; |
|
127
|
0
|
|
|
|
|
|
my $fit_str = $&; |
|
128
|
0
|
|
|
|
|
|
$fit_str =~ s/<\/?b>/\*\*/g; |
|
129
|
0
|
|
|
|
|
|
$fit_str =~ s/<\/?u>/__/g; |
|
130
|
0
|
|
|
|
|
|
$fit_str =~ s/<\/?i>/\/\//g; |
|
131
|
0
|
|
|
|
|
|
$fit_str =~ s/<\/?s>/~~/g; |
|
132
|
|
|
|
|
|
|
# link [[link|link description]] |
|
133
|
0
|
0
|
|
|
|
|
if($fit_str =~ //) |
|
134
|
|
|
|
|
|
|
{ |
|
135
|
0
|
|
|
|
|
|
$fit_str =~ s//$1/g; |
|
136
|
0
|
|
|
|
|
|
$fit_str = '[[' . $fit_str . '|'; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
0
|
0
|
|
|
|
|
if($fit_str =~ /<\/span>/) |
|
139
|
|
|
|
|
|
|
{ |
|
140
|
0
|
|
|
|
|
|
$fit_str = ']]'; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
0
|
0
|
0
|
|
|
|
$markup_coordinate{$y . '-' . $ori_x} = $fit_str if($ori_x >= 0 && $y >=0); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
|
|
|
|
|
return %markup_coordinate ; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
151
|
|
|
|
|
|
|
sub get_markup_characters_array |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
0
|
|
|
0
|
|
|
my ($self, $markup_coordinate, @lines) = @_ ; |
|
154
|
0
|
|
|
|
|
|
my (@new_lines, $new_col) ; |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
for my $row (0 .. $#lines) |
|
157
|
|
|
|
|
|
|
{ |
|
158
|
0
|
|
|
|
|
|
$new_col = 0; |
|
159
|
0
|
|
|
|
|
|
for my $col (0 .. ($#{$lines[$row]} + 2)) |
|
|
0
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
{ |
|
161
|
0
|
0
|
|
|
|
|
if(exists($markup_coordinate->{$row . '-' . $col})) |
|
162
|
|
|
|
|
|
|
{ |
|
163
|
0
|
|
|
|
|
|
for my $single_char (split '', $markup_coordinate->{$row . '-' . $col}) |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
|
|
|
$new_lines[$row][$new_col] = [$single_char]; |
|
166
|
|
|
|
|
|
|
# single char |
|
167
|
0
|
|
|
|
|
|
$new_col += App::Asciio::String::unicode_length($single_char); |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
} |
|
170
|
0
|
0
|
|
|
|
|
$new_lines[$row][$new_col] = $lines[$row][$col] if(defined($lines[$row][$col])); |
|
171
|
0
|
|
|
|
|
|
$new_col += 1; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
} |
|
174
|
0
|
|
|
|
|
|
return(@new_lines); |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
178
|
|
|
|
|
|
|
#~ link fomart: something |
|
179
|
|
|
|
|
|
|
#~ convert to: something |
|
180
|
|
|
|
|
|
|
#~ bold fomart: something |
|
181
|
|
|
|
|
|
|
#~ convert to: something |
|
182
|
|
|
|
|
|
|
#~ the above just for display,not really change |
|
183
|
|
|
|
|
|
|
# :TODO: At present, some font sizes cannot be aligned even if they are reduced by 1. The specific rules have not yet been clarified. Currently, we only solve the problem under certain font sizes. |
|
184
|
|
|
|
|
|
|
sub convert_markup_string |
|
185
|
|
|
|
|
|
|
{ |
|
186
|
|
|
|
|
|
|
my ($font_size, $string) = @_ ; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $use_markup_formart = 0 ; |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
if(is_markup_string($string)) |
|
191
|
|
|
|
|
|
|
{ |
|
192
|
|
|
|
|
|
|
$use_markup_formart = 1 ; |
|
193
|
|
|
|
|
|
|
$string =~ s/([^<]+)<\/span>/$1<\/span>/g; |
|
194
|
|
|
|
|
|
|
# convert bold fonts to precise size control |
|
195
|
|
|
|
|
|
|
$font_size -= 1 ; |
|
196
|
|
|
|
|
|
|
$string =~ s/()((<[ius]>)*)([^<]+)((<\/[ius]>)*)(<\/b>)/$2$4$5<\/span>/g ; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
return ($use_markup_formart, $string) ; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub ui_show_markup_characters |
|
205
|
|
|
|
|
|
|
{ |
|
206
|
0
|
|
|
0
|
|
|
my ($self, $layout, $font_size, $line) = @_ ; |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
my ($use_mark_up, $markup_line) = convert_markup_string($font_size, $line) ; |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
0
|
|
|
|
|
if($use_mark_up) |
|
211
|
|
|
|
|
|
|
{ |
|
212
|
0
|
|
|
|
|
|
$layout->set_markup($markup_line) ; |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
else |
|
215
|
|
|
|
|
|
|
{ |
|
216
|
0
|
|
|
|
|
|
$layout->set_text($line) ; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1 ; |
|
224
|
|
|
|
|
|
|
|