Skip to content

Commit ed91c4b

Browse files
handle symbols declared with %s
1 parent 401ad94 commit ed91c4b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rdoc/parser/ripper_state_lex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def get_squashed_tk
368368
private def get_symbol_tk(tk)
369369
is_symbol = true
370370
symbol_tk = Token.new(tk.line_no, tk.char_no, :on_symbol)
371-
if ":'" == tk[:text] or ':"' == tk[:text]
371+
if ":'" == tk[:text] or ':"' == tk[:text] or tk[:text].start_with?('%s')
372372
tk1 = get_string_tk(tk)
373373
symbol_tk[:text] = tk1[:text]
374374
symbol_tk[:state] = tk1[:state]

test/rdoc/test_rdoc_parser_ruby.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,6 +3205,14 @@ def test_parse_symbol_in_arg
32053205
assert_nil @parser.parse_symbol_in_arg
32063206
end
32073207

3208+
def test_parse_percent_symbol
3209+
content = '%s[foo bar]'
3210+
util_parser content
3211+
tk = @parser.get_tk
3212+
assert_equal :on_symbol, tk[:kind]
3213+
assert_equal content, tk[:text]
3214+
end
3215+
32083216
def test_parse_statements_alias_method
32093217
content = <<-CONTENT
32103218
class A

0 commit comments

Comments
 (0)