# # Author: Brandon Mathis # Based on the work of: Josediaz Gonzalez - https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb # require './_plugins/titlecase.rb' module Jekyll # Outputs a string with a given attribution as a quote # # {% blockquote Bobby Willis http://google.com/blah the search for bobby's mom %} # Wheeee! # {% endblockquote %} # ... #
## class Blockquote < Liquid::Block FullCiteWithTitle = /([\w\s]+)(https?:\/\/)(\S+\s)([\w\s]+)/i FullCite = /([\w\s]+)(https?:\/\/)(\S+)/i Author = /([\w\s]+)/ def initialize(tag_name, markup, tokens) @by = nil @source = nil @title = nil if markup =~ FullCiteWithTitle @by = $1 @source = $2 + $3 @title = $4.titlecase elsif markup =~ FullCite @by = $1 @source = $2 + $3 elsif markup =~ Author @by = $1 end super end def render(context) output = super author = "#{@by}" cite = "#{(@title || 'source')}" reply = if @by.nil? "Wheeee!
#
#{output.join.gsub(/\n\n/, '
')}
" elsif !@source.nil? "#{output.join.gsub(/\n\n/, '
')}
" else "#{output.join.gsub(/\n\n/, '
')}
" end "#{reply}" end end end Liquid::Template.register_tag('blockquote', Jekyll::Blockquote)