Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply matching word pairs to underscore-methods #880

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/rdoc/markup/attribute_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,10 @@ def convert_attrs_matching_word_pairs(str, attrs, exclusive)
exclusive == exclusive?(bitmap)
}.keys
return if tags.empty?
all_tags = @matching_word_pairs.keys
tags = "[#{tags.join("")}](?!#{PROTECT_ATTR})"
all_tags = "[#{@matching_word_pairs.keys.join("")}](?!#{PROTECT_ATTR})"

re = /(^|\W|[#{all_tags.join("")}])([#{tags.join("")}])(\2*[#\\]?[\w:.\/\[\]-]+?\S?)\2(?!\2)([#{all_tags.join("")}]|\W|$)/
re = /(^|\W|#{all_tags})(#{tags})(\2*[#\\]?[\w:#{PROTECT_ATTR}.\/\[\]-]+?\S?)\2(?!\2)(#{all_tags}|\W|$)/

1 while str.gsub!(re) { |orig|
attr = @matching_word_pairs[$2]
Expand Down
2 changes: 2 additions & 0 deletions test/rdoc/test_rdoc_markup_attribute_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def test_basic

assert_equal(["cat and ", @em_on, "5", @em_off, " dogs"],
@am.flow("cat and _5_ dogs"))

assert_equal([@tt_on, "__id__", @tt_off], @am.flow("+__id__+"))
end

def test_bold
Expand Down