Skip to content

Commit

Permalink
get procedure for default excerpt separator for both cases site and p…
Browse files Browse the repository at this point in the history
…age was

moved to the post's specific method :excerpt_separator.
  • Loading branch information
majioa committed Jan 10, 2015
1 parent 54d0bf4 commit a0f2b5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/jekyll/excerpt.rb
Expand Up @@ -105,10 +105,7 @@ def inspect
#
# Returns excerpt String
def extract_excerpt(post_content)
separator = !post.excerpt_separator.empty? &&
post.excerpt_separator ||
site.config['excerpt_separator']
head, _, tail = post_content.to_s.partition(separator)
head, _, tail = post_content.to_s.partition(post.excerpt_separator)

"" << head << "\n\n" << tail.scan(/^\[[^\]]+\]:.+$/).join("\n")
end
Expand Down
7 changes: 4 additions & 3 deletions lib/jekyll/post.rb
Expand Up @@ -119,11 +119,12 @@ def title
data.fetch('title') { titleized_slug }
end

# Public: the Post excerpt_separator, from the YAML Front-Matter or empty string
# Public: the Post excerpt_separator, from the YAML Front-Matter or site default
# excerpt_separator value
#
# Returns the post excerpt_separator
def excerpt_separator
data.fetch('excerpt_separator') { "" }
data.fetch('excerpt_separator') { site.config['excerpt_separator'].to_s }
end

# Turns the post slug into a suitable title
Expand Down Expand Up @@ -315,7 +316,7 @@ def extract_excerpt
end

def generate_excerpt?
!site.config['excerpt_separator'].to_s.empty? || !excerpt_separator.empty?
!excerpt_separator.empty?
end
end
end

0 comments on commit a0f2b5f

Please sign in to comment.