Skip to content
Open
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
1 change: 0 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Rouge/NoBuildingAlternationPatternInRegexp:
- 'lib/rouge/lexers/bicep.rb'
- 'lib/rouge/lexers/cfscript.rb'
- 'lib/rouge/lexers/cmhg.rb'
- 'lib/rouge/lexers/console.rb'
- 'lib/rouge/lexers/crystal.rb'
- 'lib/rouge/lexers/csharp.rb'
- 'lib/rouge/lexers/d.rb'
Expand Down
6 changes: 5 additions & 1 deletion lib/rouge/lexers/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def comment_regex

def end_chars
@end_chars ||= if @prompt.any?
@prompt.reject { |c| c.empty? }
@prompt.reject { |c| c.empty? }.uniq.first(20)
elsif allow_comments?
%w($ > ;)
else
Expand Down Expand Up @@ -173,9 +173,13 @@ def prompt_prefix_regex
end

def prompt_regex
# [jneen] these characters can come from user input. They are escaped here,
# and we limit the user to 20.
#rubocop:disable Rouge/NoBuildingAlternationPatternInRegexp
@prompt_regex ||= begin
/^#{prompt_prefix_regex}(?:#{end_chars.map { |c| Regexp.escape(c) }.join('|')})/
end
#rubocop:enable Rouge/NoBuildingAlternationPatternInRegexp
end

def stream_tokens(input, &output)
Expand Down