[ruby/rdoc] Fix blockquote with word in verbatim

https://github.com/ruby/rdoc/commit/75eee668a5
This commit is contained in:
Nobuyoshi Nakada 2022-07-30 01:18:04 +09:00 committed by git
parent 0e85586ecc
commit af265d73fb
2 changed files with 19 additions and 6 deletions

View File

@ -289,6 +289,10 @@ class RDoc::Markup::Parser
line << data line << data
when :BLOCKQUOTE then when :BLOCKQUOTE then
line << '>>>' line << '>>>'
peek_type, _, peek_column = peek_token
if peek_type != :NEWLINE and peek_column
line << ' ' * (peek_column - column - 3)
end
else # *LIST_TOKENS else # *LIST_TOKENS
list_marker = case type list_marker = case type
when :BULLET then data when :BULLET then data
@ -374,11 +378,8 @@ class RDoc::Markup::Parser
unget unget
parse_text parent, indent parse_text parent, indent
when :BLOCKQUOTE then when :BLOCKQUOTE then
type, _, column = get nil while (type, = get; type) and type != :NEWLINE
if type == :NEWLINE _, _, column, = peek_token
type, _, column = get
end
unget if type
bq = RDoc::Markup::BlockQuote.new bq = RDoc::Markup::BlockQuote.new
p :blockquote_start => [data, column] if @debug p :blockquote_start => [data, column] if @debug
parse bq, column parse bq, column
@ -546,7 +547,10 @@ class RDoc::Markup::Parser
[:NOTE, @s[1], *pos] [:NOTE, @s[1], *pos]
# >>> followed by end of line => :BLOCKQUOTE # >>> followed by end of line => :BLOCKQUOTE
when @s.scan(/>>> *(\w+)?$/) then when @s.scan(/>>> *(\w+)?$/) then
[:BLOCKQUOTE, @s[1], *pos] if word = @s[1]
@s.unscan(word)
end
[:BLOCKQUOTE, word, *pos]
# anything else: :TEXT # anything else: :TEXT
else else
@s.scan(/(.*?)( )?\r?$/) @s.scan(/(.*?)( )?\r?$/)

View File

@ -821,6 +821,15 @@ EXPECTED
EXPECTED EXPECTED
assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "") assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
str = "BlockQuote\n >>> word\n"
expected = <<-EXPECTED
<p>BlockQuote</p>
<pre>&gt;&gt;&gt; word</pre>
EXPECTED
assert_equal expected, @m.convert(str, @to).gsub(/^\n/, "")
end end
def test_parseable_eh def test_parseable_eh