Skip to content

Commit eddd10c

Browse files
authored
Fix Ruby 3.4 regex warning: remove duplicated range in character class (#1640)
# Description Replace `[\W<]` with `\W` in regex lookahead since `<` is already [included](https://ruby-doc.org/3.4.1/Regexp.html#class-Regexp-label-Shorthand+Character+Classes) in `\W`. This resolves the 'character class has duplicated range' warning in Ruby 3.4. Fixes #1609 Warnings are [disabled](https://github.com/lsegal/yard/blob/34796c5bfc0ce69a5fea1b38d96435fc4f5b7a75/spec/spec_helper.rb#L188) in specs, so I am unable to easily write an effective test. # Completed Tasks - [x] I have read the [Contributing Guide][contrib]. - [x] The pull request is complete (implemented / written). - [x] Git commits have been cleaned up (squash WIP / revert commits). - [ ] I wrote tests and ran `bundle exec rake` locally (if code is attached to PR). [contrib]: https://github.com/lsegal/yard/blob/main/CONTRIBUTING.md
2 parents f2556b9 + 90d7687 commit eddd10c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/yard/templates/helpers/html_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def html_syntax_highlight_plain(source)
228228
# @return [String] HTML with linkified references
229229
def resolve_links(text)
230230
code_tags = 0
231-
text.gsub(%r{<(/)?(pre|code|tt)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+</|$)}m) do |str|
231+
text.gsub(%r{<(/)?(pre|code|tt)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=\W|.+</|$)}m) do |str|
232232
closed = $1
233233
tag = $2
234234
escape = $3

0 commit comments

Comments
 (0)