Skip to content

Commit

Permalink
Merge pull request #909 from nobu/blockquote-in-verbatim
Browse files Browse the repository at this point in the history
Fix blockquote with word in verbatim
  • Loading branch information
nobu committed Jul 30, 2022
2 parents dde1860 + 75eee66 commit 00555cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rdoc/markup/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ def build_verbatim margin
line << data
when :BLOCKQUOTE then
line << '>>>'
peek_type, _, peek_column = peek_token
if peek_type != :NEWLINE and peek_column
line << ' ' * (peek_column - column - 3)
end
else # *LIST_TOKENS
list_marker = case type
when :BULLET then data
Expand Down Expand Up @@ -374,11 +378,8 @@ def parse parent, indent = 0
unget
parse_text parent, indent
when :BLOCKQUOTE then
type, _, column = get
if type == :NEWLINE
type, _, column = get
end
unget if type
nil while (type, = get; type) and type != :NEWLINE
_, _, column, = peek_token
bq = RDoc::Markup::BlockQuote.new
p :blockquote_start => [data, column] if @debug
parse bq, column
Expand Down Expand Up @@ -546,7 +547,10 @@ def tokenize input
[:NOTE, @s[1], *pos]
# >>> followed by end of line => :BLOCKQUOTE
when @s.scan(/>>> *(\w+)?$/) then
[:BLOCKQUOTE, @s[1], *pos]
if word = @s[1]
@s.unscan(word)
end
[:BLOCKQUOTE, word, *pos]
# anything else: :TEXT
else
@s.scan(/(.*?)( )?\r?$/)
Expand Down
9 changes: 9 additions & 0 deletions test/rdoc/test_rdoc_markup_to_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,15 @@ def test_block_quote_in_verbatim
EXPECTED

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

def test_parseable_eh
Expand Down

0 comments on commit 00555cb

Please sign in to comment.