Skip to content

Use Enumerable#chunk after drop Ruby 1.8 #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions lib/rdoc/markup/to_joined_paragraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,11 @@ def end_accepting # :nodoc:
# Converts the parts of +paragraph+ to a single entry.

def accept_paragraph paragraph
parts = []
string = false

paragraph.parts.each do |part|
if String === part then
if string then
string << part
else
parts << part
string = part
end
else
parts << part
string = false
end
end

parts = parts.map do |part|
if String === part then
part.rstrip
else
part
end
end

# TODO use Enumerable#chunk when Ruby 1.8 support is dropped
#parts = paragraph.parts.chunk do |part|
# String === part
#end.map do |string, chunk|
# string ? chunk.join.rstrip : chunk
#end.flatten
parts = paragraph.parts.chunk do |part|
String === part
end.map do |string, chunk|
string ? chunk.join.rstrip : chunk
end.flatten

paragraph.parts.replace parts
end
Expand Down