From 8013250136b61e0ae5a8d27a4ec73936cd7647eb Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 8 Dec 2021 23:54:19 +0900 Subject: [ruby/rdoc] Simplify attribute exclusiveness conditions https://github.com/ruby/rdoc/commit/45e33c4b85 --- lib/rdoc/markup/attribute_manager.rb | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'lib') diff --git a/lib/rdoc/markup/attribute_manager.rb b/lib/rdoc/markup/attribute_manager.rb index 50764510f3..6843e6c3d0 100644 --- a/lib/rdoc/markup/attribute_manager.rb +++ b/lib/rdoc/markup/attribute_manager.rb @@ -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 -- cgit v1.2.3