2011-06-19 15:14:01 -04:00
|
|
|
#
|
|
|
|
# Author: Brandon Mathis
|
2011-10-11 18:59:25 -04:00
|
|
|
# Based on the semantic pullquote technique by Maykel Loomans at http://miekd.com/articles/pull-quotes-with-html5-and-css/
|
2011-06-19 15:14:01 -04:00
|
|
|
#
|
|
|
|
# Outputs a span with a data-pullquote attribute set from the marked pullquote. Example:
|
|
|
|
#
|
2011-12-11 17:20:04 -05:00
|
|
|
# {% pullquote %}
|
2011-06-19 15:14:01 -04:00
|
|
|
# When writing longform posts, I find it helpful to include pullquotes, which help those scanning a post discern whether or not a post is helpful.
|
|
|
|
# It is important to note, {" pullquotes are merely visual in presentation and should not appear twice in the text. "} That is why it is prefered
|
|
|
|
# to use a CSS only technique for styling pullquotes.
|
|
|
|
# {% endpullquote %}
|
|
|
|
# ...will output...
|
|
|
|
# <p>
|
|
|
|
# <span data-pullquote="pullquotes are merely visual in presentation and should not appear twice in the text.">
|
|
|
|
# When writing longform posts, I find it helpful to include pullquotes, which help those scanning a post discern whether or not a post is helpful.
|
2011-10-16 07:37:06 -04:00
|
|
|
# It is important to note, pullquotes are merely visual in presentation and should not appear twice in the text. This is why a CSS only approach
|
|
|
|
# for styling pullquotes is prefered.
|
2011-06-19 15:14:01 -04:00
|
|
|
# </span>
|
|
|
|
# </p>
|
|
|
|
#
|
2011-10-16 07:37:06 -04:00
|
|
|
# {% pullquote left %} will create a left-aligned pullquote instead.
|
|
|
|
#
|
|
|
|
# Note: this plugin now creates pullquotes with the class of pullquote-right by default
|
2011-06-19 15:14:01 -04:00
|
|
|
|
|
|
|
module Jekyll
|
|
|
|
|
|
|
|
class PullquoteTag < Liquid::Block
|
|
|
|
def initialize(tag_name, markup, tokens)
|
2011-10-16 07:37:06 -04:00
|
|
|
@align = (markup =~ /left/i) ? "left" : "right"
|
2011-06-19 15:14:01 -04:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def render(context)
|
|
|
|
output = super
|
2012-05-22 17:30:27 -04:00
|
|
|
if output =~ /\{"\s*(.+?)\s*"\}/m
|
2011-12-11 17:20:04 -05:00
|
|
|
@quote = RubyPants.new($1).to_html
|
2012-05-22 17:30:27 -04:00
|
|
|
"<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.gsub(/\{"\s*|\s*"\}/, '')}</span>"
|
2011-06-19 15:14:01 -04:00
|
|
|
else
|
2011-07-22 17:45:26 -04:00
|
|
|
return "Surround your pullquote like this {\" text to be quoted \"}"
|
2011-06-19 15:14:01 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Liquid::Template.register_tag('pullquote', Jekyll::PullquoteTag)
|