Skip to content

Commit 75eee66

Browse files
committed
Fix blockquote with word in verbatim
1 parent 2cdba4a commit 75eee66

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

lib/rdoc/markup/parser.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ def build_verbatim margin
289289
line << data
290290
when :BLOCKQUOTE then
291291
line << '>>>'
292+
peek_type, _, peek_column = peek_token
293+
if peek_type != :NEWLINE and peek_column
294+
line << ' ' * (peek_column - column - 3)
295+
end
292296
else # *LIST_TOKENS
293297
list_marker = case type
294298
when :BULLET then data
@@ -374,11 +378,8 @@ def parse parent, indent = 0
374378
unget
375379
parse_text parent, indent
376380
when :BLOCKQUOTE then
377-
type, _, column = get
378-
if type == :NEWLINE
379-
type, _, column = get
380-
end
381-
unget if type
381+
nil while (type, = get; type) and type != :NEWLINE
382+
_, _, column, = peek_token
382383
bq = RDoc::Markup::BlockQuote.new
383384
p :blockquote_start => [data, column] if @debug
384385
parse bq, column
@@ -546,7 +547,10 @@ def tokenize input
546547
[:NOTE, @s[1], *pos]
547548
# >>> followed by end of line => :BLOCKQUOTE
548549
when @s.scan(/>>> *(\w+)?$/) then
549-
[:BLOCKQUOTE, @s[1], *pos]
550+
if word = @s[1]
551+
@s.unscan(word)
552+
end
553+
[:BLOCKQUOTE, word, *pos]
550554
# anything else: :TEXT
551555
else
552556
@s.scan(/(.*?)( )?\r?$/)

test/rdoc/test_rdoc_markup_to_html.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,15 @@ def test_block_quote_in_verbatim
821821
EXPECTED
822822

823823
assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
824+
825+
str = "BlockQuote\n >>> word\n"
826+
827+
expected = <<-EXPECTED
828+
<p>BlockQuote</p>
829+
<pre>&gt;&gt;&gt; word</pre>
830+
EXPECTED
831+
832+
assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
824833
end
825834

826835
def test_parseable_eh

0 commit comments

Comments
 (0)