aboutsummaryrefslogtreecommitdiff
path: root/plugins/blockquote.rb
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-22 11:47:23 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-22 11:48:45 -0400
commit967eeb46e8f9bb25a382c52f1f36de59b8f0d1cb (patch)
tree942289902b46db7744964bfa85c43c31ed3747ac /plugins/blockquote.rb
parentba0e5ef4a38a3c06b8bcf4af6518cd00665dacb2 (diff)
downloadmy_new_personal_website-967eeb46e8f9bb25a382c52f1f36de59b8f0d1cb.tar.xz
my_new_personal_website-967eeb46e8f9bb25a382c52f1f36de59b8f0d1cb.zip
blockquote plugin now allows for source attribution with out a link, see docs
Diffstat (limited to '')
-rw-r--r--plugins/blockquote.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/plugins/blockquote.rb b/plugins/blockquote.rb
index e6388db3..a0bf12cc 100644
--- a/plugins/blockquote.rb
+++ b/plugins/blockquote.rb
@@ -19,9 +19,9 @@ require './plugins/titlecase.rb'
module Jekyll
class Blockquote < Liquid::Block
- FullCiteWithTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i
- FullCite = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i
- Author = /(\S[\S\s]*)/
+ FullCiteWithTitle = /(\S.*)\s+(https?:\/\/)(\S+)\s+(.+)/i
+ FullCite = /(\S.*)\s+(https?:\/\/)(\S+)/i
+ Author = /(.+)/
def initialize(tag_name, markup, tokens)
@by = nil
@@ -35,7 +35,12 @@ module Jekyll
@by = $1
@source = $2 + $3
elsif markup =~ Author
- @by = $1
+ if $1 =~ /([^,]+),([^,]+)/
+ @by = $1
+ @title = $2.titlecase
+ else
+ @by = $1
+ end
end
super
end
@@ -54,15 +59,19 @@ module Jekyll
source = parts.join('/')
source << '/&hellip;' unless source == @source
end
- cite = "<cite><a href='#{@source}'>#{(@title || source)}</a></cite>"
- quote_only = if @by.nil?
+ if !@source.nil?
+ cite = "<cite><a href='#{@source}'>#{(@title || source)}</a></cite>"
+ elsif !@title.nil?
+ cite = "<cite>#{@title}</cite>"
+ end
+ blockquote = if @by.nil?
quote
- elsif !@source.nil?
+ elsif cite
"#{quote}<footer>#{author + cite}</footer>"
else
"#{quote}<footer>#{author}</footer>"
end
- "<blockquote>#{quote_only}</blockquote>"
+ "<blockquote>#{blockquote}</blockquote>"
end
def paragraphize(input)