add Utils.strip_heredoc

This commit is contained in:
Parker Moore 2016-01-20 11:46:18 -08:00
parent f8e8672148
commit 1ba23c32c6
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,12 @@ module Jekyll
SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
# Takes an indented string and removes the preceding spaces on each line
def strip_heredoc(str)
str.gsub(/^[ \t]{#{(str.scan(/^[ \t]*(?=\S)/).min || "").size}}/, "")
end
# Takes a slug and turns it into a simple title. # Takes a slug and turns it into a simple title.
def titleize_slug(slug) def titleize_slug(slug)