Skip to content

Commit 24efb01

Browse files
committed
Gave TkEND_OF_SCRIPT#text a value
This allows __END__ to be shown in HTML verbatim blocks Conflicts: History.rdoc
1 parent 976d31f commit 24efb01

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

History.rdoc

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Fixed lexing of character syntax (<code>?x</code>). Reported by Xavier
77
Noria.
88
* Fixed tokenization of % when it is not followed by a $-string type
9+
* Fixed display of __END__ in documentation examples in HTML output
10+
911

1012
=== 3.12.1 / 2013-02-05
1113

lib/rdoc/ruby_lex.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def token
412412
def lex_init()
413413
@OP = IRB::SLex.new
414414
@OP.def_rules("\0", "\004", "\032") do |op, io|
415-
Token(TkEND_OF_SCRIPT)
415+
Token(TkEND_OF_SCRIPT, '')
416416
end
417417

418418
@OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io|
@@ -808,7 +808,8 @@ def lex_int2
808808

809809
@OP.def_rule("_") do
810810
if peek_match?(/_END__/) and @lex_state == EXPR_BEG then
811-
Token(TkEND_OF_SCRIPT)
811+
6.times { getc }
812+
Token(TkEND_OF_SCRIPT, '__END__')
812813
else
813814
ungetc
814815
identify_identifier

test/test_rdoc_ruby_lex.rb

+11
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ def test_class_tokenize
3030
assert_equal expected, tokens
3131
end
3232

33+
def test_class_tokenize___END__
34+
tokens = RDoc::RubyLex.tokenize '__END__', nil
35+
36+
expected = [
37+
@TK::TkEND_OF_SCRIPT.new(0, 1, 0, '__END__'),
38+
@TK::TkNL .new(7, 1, 7, "\n"),
39+
]
40+
41+
assert_equal expected, tokens
42+
end
43+
3344
def test_class_tokenize_character_literal
3445
tokens = RDoc::RubyLex.tokenize "?\\", nil
3546

0 commit comments

Comments
 (0)