Skip to content

Commit 130bd3d

Browse files
authored
Merge pull request #473 from aycabta/fix-for-nl-after-backslash
Fix for "\n" after backslash escape
2 parents daf4867 + 4733565 commit 130bd3d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,11 @@ def lex_int2
837837

838838
@OP.def_rule('\\') do
839839
|op, io|
840-
if getc == "\n"
840+
if peek(0) == "\n"
841841
@space_seen = true
842842
@continue = true
843-
Token(TkSPACE)
844-
else
845-
ungetc
846-
Token("\\")
847843
end
844+
Token("\\")
848845
end
849846

850847
@OP.def_rule('%') do

test/test_rdoc_markup_to_html.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,22 @@ def test_accept_verbatim_parseable_error
451451
assert_equal expected, @to.res.join
452452
end
453453

454+
def test_accept_verbatim_nl_after_backslash
455+
verb = @RM::Verbatim.new("a = 1 if first_flag_var and \\\n", " this_is_flag_var\n")
456+
457+
@to.start_accepting
458+
@to.accept_verbatim verb
459+
460+
expected = <<-EXPECTED
461+
462+
<pre class="ruby"><span class="ruby-identifier">a</span> = <span class="ruby-value">1</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">first_flag_var</span> <span class="ruby-keyword">and</span> \\
463+
<span class="ruby-identifier">this_is_flag_var</span>
464+
</pre>
465+
EXPECTED
466+
467+
assert_equal expected, @to.res.join
468+
end
469+
454470
def test_accept_verbatim_pipe
455471
@options.pipe = true
456472

0 commit comments

Comments
 (0)