1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/rdoc] Simplify attribute exclusiveness conditions

https://github.com/ruby/rdoc/commit/45e33c4b85
This commit is contained in:
Nobuyoshi Nakada 2021-12-08 23:54:19 +09:00 committed by git
parent ec6d1cf28f
commit 8013250136

View file

@ -147,13 +147,7 @@ class RDoc::Markup::AttributeManager
def convert_attrs_matching_word_pairs(str, attrs, exclusive)
# first do matching ones
tags = @matching_word_pairs.select { |start, bitmap|
if exclusive && exclusive?(bitmap)
true
elsif !exclusive && !exclusive?(bitmap)
true
else
false
end
exclusive == exclusive?(bitmap)
}.keys
return if tags.empty?
all_tags = @matching_word_pairs.keys
@ -176,11 +170,7 @@ class RDoc::Markup::AttributeManager
# then non-matching
unless @word_pair_map.empty? then
@word_pair_map.each do |regexp, attr|
if !exclusive
next if exclusive?(attr)
else
next if !exclusive?(attr)
end
next unless exclusive == exclusive?(attr)
1 while str.gsub!(regexp) { |orig|
updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
if updated
@ -198,13 +188,7 @@ class RDoc::Markup::AttributeManager
def convert_html(str, attrs, exclusive = false)
tags = @html_tags.select { |start, bitmap|
if exclusive && exclusive?(bitmap)
true
elsif !exclusive && !exclusive?(bitmap)
true
else
false
end
exclusive == exclusive?(bitmap)
}.keys.join '|'
1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
@ -221,11 +205,7 @@ class RDoc::Markup::AttributeManager
def convert_regexp_handlings str, attrs, exclusive = false
@regexp_handlings.each do |regexp, attribute|
if exclusive
next if !exclusive?(attribute)
else
next if exclusive?(attribute)
end
next unless exclusive == exclusive?(attribute)
str.scan(regexp) do
capture = $~.size == 1 ? 0 : 1