2011-06-19 19:14:01 +00:00
|
|
|
#
|
|
|
|
# Author: Brandon Mathis
|
2011-10-11 22:59:25 +00:00
|
|
|
# Based on the semantic pullquote technique by Maykel Loomans at http://miekd.com/articles/pull-quotes-with-html5-and-css/
|
2011-06-19 19:14:01 +00:00
|
|
|
#
|
|
|
|
# Outputs a span with a data-pullquote attribute set from the marked pullquote. Example:
|
|
|
|
#
|
2011-12-11 22:20:04 +00:00
|
|
|
# {% pullquote %}
|
2011-06-19 19:14:01 +00: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 11:37:06 +00: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 19:14:01 +00:00
|
|
|
# </span>
|
|
|
|
# </p>
|
|
|
|
#
|
2011-10-16 11:37:06 +00: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 19:14:01 +00:00
|
|
|
|
|
|
|
module Jekyll
|
|
|
|
|
|
|
|
class PullquoteTag < Liquid::Block
|
|
|
|
def initialize(tag_name, markup, tokens)
|
2011-10-16 11:37:06 +00:00
|
|
|
@align = (markup =~ /left/i) ? "left" : "right"
|
2011-06-19 19:14:01 +00:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def render(context)
|
|
|
|
output = super
|
2012-05-24 15:28:32 +00:00
|
|
|
if output =~ /\{"\s*(.+?)\s*"\}/m
|
2011-12-11 22:20:04 +00:00
|
|
|
@quote = RubyPants.new($1).to_html
|
2012-05-24 15:28:32 +00:00
|
|
|
"<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.gsub(/\{"\s*|\s*"\}/, '')}</span>"
|
2011-06-19 19:14:01 +00:00
|
|
|
else
|
2011-07-22 21:45:26 +00:00
|
|
|
return "Surround your pullquote like this {\" text to be quoted \"}"
|
2011-06-19 19:14:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Liquid::Template.register_tag('pullquote', Jekyll::PullquoteTag)
|