[ruby/rdoc] Simplify attribute exclusiveness conditions
https://github.com/ruby/rdoc/commit/45e33c4b85
This commit is contained in:
parent
ec6d1cf28f
commit
8013250136
@ -147,13 +147,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
def convert_attrs_matching_word_pairs(str, attrs, exclusive)
|
def convert_attrs_matching_word_pairs(str, attrs, exclusive)
|
||||||
# first do matching ones
|
# first do matching ones
|
||||||
tags = @matching_word_pairs.select { |start, bitmap|
|
tags = @matching_word_pairs.select { |start, bitmap|
|
||||||
if exclusive && exclusive?(bitmap)
|
exclusive == exclusive?(bitmap)
|
||||||
true
|
|
||||||
elsif !exclusive && !exclusive?(bitmap)
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
}.keys
|
}.keys
|
||||||
return if tags.empty?
|
return if tags.empty?
|
||||||
all_tags = @matching_word_pairs.keys
|
all_tags = @matching_word_pairs.keys
|
||||||
@ -176,11 +170,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
# then non-matching
|
# then non-matching
|
||||||
unless @word_pair_map.empty? then
|
unless @word_pair_map.empty? then
|
||||||
@word_pair_map.each do |regexp, attr|
|
@word_pair_map.each do |regexp, attr|
|
||||||
if !exclusive
|
next unless exclusive == exclusive?(attr)
|
||||||
next if exclusive?(attr)
|
|
||||||
else
|
|
||||||
next if !exclusive?(attr)
|
|
||||||
end
|
|
||||||
1 while str.gsub!(regexp) { |orig|
|
1 while str.gsub!(regexp) { |orig|
|
||||||
updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
|
updated = attrs.set_attrs($`.length + $1.length, $2.length, attr)
|
||||||
if updated
|
if updated
|
||||||
@ -198,13 +188,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
|
|
||||||
def convert_html(str, attrs, exclusive = false)
|
def convert_html(str, attrs, exclusive = false)
|
||||||
tags = @html_tags.select { |start, bitmap|
|
tags = @html_tags.select { |start, bitmap|
|
||||||
if exclusive && exclusive?(bitmap)
|
exclusive == exclusive?(bitmap)
|
||||||
true
|
|
||||||
elsif !exclusive && !exclusive?(bitmap)
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
}.keys.join '|'
|
}.keys.join '|'
|
||||||
|
|
||||||
1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
|
1 while str.gsub!(/<(#{tags})>(.*?)<\/\1>/i) { |orig|
|
||||||
@ -221,11 +205,7 @@ class RDoc::Markup::AttributeManager
|
|||||||
|
|
||||||
def convert_regexp_handlings str, attrs, exclusive = false
|
def convert_regexp_handlings str, attrs, exclusive = false
|
||||||
@regexp_handlings.each do |regexp, attribute|
|
@regexp_handlings.each do |regexp, attribute|
|
||||||
if exclusive
|
next unless exclusive == exclusive?(attribute)
|
||||||
next if !exclusive?(attribute)
|
|
||||||
else
|
|
||||||
next if exclusive?(attribute)
|
|
||||||
end
|
|
||||||
str.scan(regexp) do
|
str.scan(regexp) do
|
||||||
capture = $~.size == 1 ? 0 : 1
|
capture = $~.size == 1 ? 0 : 1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user