-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
irb lexer: recognize the SIMPLE prompt (#1943)
* irb lexer: recognize the SIMPLE prompt Added support for IRB's `:SIMPLE` prompt (`>>`), plus some tests for it and the two other supported prompts (IRB's `:STANDARD` and Pry's default). * Update lib/rouge/lexers/irb.rb Avoid picking output as prompt + support for multi-line prompts. Courtesy of @tancnle. Co-authored-by: Tan Le <[email protected]> --------- Co-authored-by: Tan Le <[email protected]>
- Loading branch information
1 parent
5c052c2
commit a5c5f1b
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- # | ||
# frozen_string_literal: true | ||
|
||
describe Rouge::Lexers::IRBLexer do | ||
let(:subject) { Rouge::Lexers::IRBLexer.new } | ||
let(:klass) { Rouge::Lexers::IRBLexer } | ||
|
||
include Support::Lexing | ||
|
||
it "parses IRB's :DEFAULT prompt" do | ||
assert_tokens_equal 'irb(main):001:0> self', | ||
['Generic.Prompt', 'irb(main):001:0>'], | ||
['Text.Whitespace', ' '], | ||
['Name.Builtin', 'self'] | ||
end | ||
|
||
it "parses IRB's :SIMPLE prompt" do | ||
assert_tokens_equal '>> self', | ||
['Generic.Prompt', '>>'], | ||
['Text.Whitespace', ' '], | ||
['Name.Builtin', 'self'] | ||
end | ||
|
||
it "parses Pry's default prompt" do | ||
assert_tokens_equal 'pry(main)> self', | ||
['Generic.Prompt', 'pry(main)>'], | ||
['Text.Whitespace', ' '], | ||
['Name.Builtin', 'self'] | ||
end | ||
end |