@@ -147,13 +147,7 @@ def convert_attrs(str, attrs, exclusive = false)
147
147
def convert_attrs_matching_word_pairs ( str , attrs , exclusive )
148
148
# first do matching ones
149
149
tags = @matching_word_pairs . select { |start , bitmap |
150
- if exclusive && exclusive? ( bitmap )
151
- true
152
- elsif !exclusive && !exclusive? ( bitmap )
153
- true
154
- else
155
- false
156
- end
150
+ exclusive == exclusive? ( bitmap )
157
151
} . keys
158
152
return if tags . empty?
159
153
all_tags = @matching_word_pairs . keys
@@ -176,11 +170,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)
176
170
# then non-matching
177
171
unless @word_pair_map . empty? then
178
172
@word_pair_map . each do |regexp , attr |
179
- if !exclusive
180
- next if exclusive? ( attr )
181
- else
182
- next if !exclusive? ( attr )
183
- end
173
+ next unless exclusive == exclusive? ( attr )
184
174
1 while str . gsub! ( regexp ) { |orig |
185
175
updated = attrs . set_attrs ( $`. length + $1. length , $2. length , attr )
186
176
if updated
@@ -198,13 +188,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)
198
188
199
189
def convert_html ( str , attrs , exclusive = false )
200
190
tags = @html_tags . select { |start , bitmap |
201
- if exclusive && exclusive? ( bitmap )
202
- true
203
- elsif !exclusive && !exclusive? ( bitmap )
204
- true
205
- else
206
- false
207
- end
191
+ exclusive == exclusive? ( bitmap )
208
192
} . keys . join '|'
209
193
210
194
1 while str . gsub! ( /<(#{ tags } )>(.*?)<\/ \1 >/i ) { |orig |
@@ -221,11 +205,7 @@ def convert_html(str, attrs, exclusive = false)
221
205
222
206
def convert_regexp_handlings str , attrs , exclusive = false
223
207
@regexp_handlings . each do |regexp , attribute |
224
- if exclusive
225
- next if !exclusive? ( attribute )
226
- else
227
- next if exclusive? ( attribute )
228
- end
208
+ next unless exclusive == exclusive? ( attribute )
229
209
str . scan ( regexp ) do
230
210
capture = $~. size == 1 ? 0 : 1
231
211
0 commit comments