Skip to content

Commit 45e33c4

Browse files
committed
Simplify attribute exclusiveness conditions
1 parent 63fac51 commit 45e33c4

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

lib/rdoc/markup/attribute_manager.rb

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,7 @@ def convert_attrs(str, attrs, exclusive = false)
147147
def convert_attrs_matching_word_pairs(str, attrs, exclusive)
148148
# first do matching ones
149149
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)
157151
}.keys
158152
return if tags.empty?
159153
all_tags = @matching_word_pairs.keys
@@ -176,11 +170,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)
176170
# then non-matching
177171
unless @word_pair_map.empty? then
178172
@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)
184174
1 while str.gsub!(regexp) { |orig|
185175
updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
186176
if updated
@@ -198,13 +188,7 @@ def convert_attrs_word_pair_map(str, attrs, exclusive)
198188

199189
def convert_html(str, attrs, exclusive = false)
200190
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)
208192
}.keys.join '|'
209193

210194
1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
@@ -221,11 +205,7 @@ def convert_html(str, attrs, exclusive = false)
221205

222206
def convert_regexp_handlings str, attrs, exclusive = false
223207
@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)
229209
str.scan(regexp) do
230210
capture = $~.size == 1 ? 0 : 1
231211

0 commit comments

Comments
 (0)