Skip to content

Commit e94579a

Browse files
authored
Merge pull request #507 from aycabta/support-multi-line-constant-body-with-escaped-nl
Supports multi-line constant body with escaped newline
2 parents ea5d6d8 + 44a89a5 commit e94579a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,8 @@ def parse_constant_body container, constant # :nodoc:
928928
end
929929
when TkCOLON2, TkCOLON3 then
930930
rhs_name << '::'
931+
when TkBACKSLASH then
932+
get_tk if TkNL === peek_tk
931933
when nil then
932934
break
933935
end

test/test_rdoc_parser_ruby.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,9 @@ class Foo
22862286
SIXTH_CONSTANT = #{sixth_constant}
22872287
22882288
SEVENTH_CONSTANT = proc { |i| begin i end }
2289+
2290+
EIGHTH_CONSTANT = "a" \\
2291+
"b"
22892292
end
22902293
EOF
22912294

@@ -2331,6 +2334,11 @@ class Foo
23312334
assert_equal 'SEVENTH_CONSTANT', constant.name
23322335
assert_equal "proc { |i| begin i end }", constant.value
23332336
assert_equal @top_level, constant.file
2337+
2338+
constant = constants[7]
2339+
assert_equal 'EIGHTH_CONSTANT', constant.name
2340+
assert_equal "\"a\" \\\n\"b\"", constant.value
2341+
assert_equal @top_level, constant.file
23342342
end
23352343

23362344
def test_parse_statements_identifier_attr

0 commit comments

Comments
 (0)