summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-12-08 23:54:19 +0900
committergit <svn-admin@ruby-lang.org>2022-02-09 22:22:46 +0900
commit8013250136b61e0ae5a8d27a4ec73936cd7647eb (patch)
tree188795e26cd24338ef659ccfa3eda768d591eaf0 /lib
parentec6d1cf28fc333fa360ab786c3852b95475932b2 (diff)
[ruby/rdoc] Simplify attribute exclusiveness conditions
https://github.com/ruby/rdoc/commit/45e33c4b85
Diffstat (limited to 'lib')
-rw-r--r--lib/rdoc/markup/attribute_manager.rb28
1 files changed, 4 insertions, 24 deletions
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