diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-07-17 17:23:41 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-07-17 17:23:41 -0400 |
commit | 6a6de74aade2d4c083a49751c7d08964ce46395b (patch) | |
tree | 527f7ed0bfb6853422ee91262f2565f79eb3851b /.themes | |
parent | a93c9599508533aac14392f69af9a97639b1c7e0 (diff) | |
download | my_new_personal_website-6a6de74aade2d4c083a49751c7d08964ce46395b.tar.xz my_new_personal_website-6a6de74aade2d4c083a49751c7d08964ce46395b.zip |
improved regular expressions in blockquote plugin
Diffstat (limited to '.themes')
-rw-r--r-- | .themes/classic/plugins/blockquote.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/.themes/classic/plugins/blockquote.rb b/.themes/classic/plugins/blockquote.rb index d85fde5c..d292ce8e 100644 --- a/.themes/classic/plugins/blockquote.rb +++ b/.themes/classic/plugins/blockquote.rb @@ -1,17 +1,17 @@ # # Author: Brandon Mathis -# Based on the work of: Josediaz Gonzalez - https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb +# A full rewrite based on the work of: Josediaz Gonzalez - https://github.com/josegonzalez/josediazgonzalez.com/blob/master/_plugins/blockquote.rb # # Outputs a string with a given attribution as a quote # -# {% blockquote Bobby Willis http://google.com/blah the search for bobby's mom %} +# {% blockquote Bobby Willis http://google.com/search?q=pants the search for bobby's pants %} # Wheeee! # {% endblockquote %} # ... # <blockquote> # <p>Wheeee!</p> # <footer> -# <strong>Bobby Willis</strong><cite><a href="http://google.com/blah">The Search For Bobby's Mom</a> +# <strong>Bobby Willis</strong><cite><a href="http://google.com/search?q=pants">The Search For Bobby's Pants</a> # </blockquote> # require './plugins/titlecase.rb' @@ -19,9 +19,9 @@ require './plugins/titlecase.rb' module Jekyll class Blockquote < Liquid::Block - FullCiteWithTitle = /([\w\s]+)(https?:\/\/)(\S+\s)([\w\s]+)/i - FullCite = /([\w\s]+)(https?:\/\/)(\S+)/i - Author = /([\w\s]+)/ + FullCiteWithTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i + FullCite = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i + Author = /(\S[\S\s]*)/ def initialize(tag_name, markup, tokens) @by = nil @@ -55,14 +55,14 @@ module Jekyll source << '/…' unless source == @source end cite = "<cite><a href='#{@source}'>#{(@title || source)}</a></cite>" - reply = if @by.nil? + result = if @by.nil? output elsif !@source.nil? "#{output}<footer>#{author + cite}</footer>" else "#{output}<footer>#{author}</footer>" end - "<blockquote>#{reply}</blockquote>" + "<blockquote>#{result}</blockquote>" end def paragraphize(input) |