aboutsummaryrefslogtreecommitdiff
path: root/plugins/pullquote.rb
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-19 09:06:54 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-19 09:06:54 -0400
commit17c59fb1d1bf3e0c05137af4b4bd09ae271a2d31 (patch)
treea4b3b5d43173f9b02ec4b6401cb6e14f6e716a35 /plugins/pullquote.rb
parent873a604e144c53cfc5465a790e43db5b7ebb429e (diff)
downloadmy_new_personal_website-17c59fb1d1bf3e0c05137af4b4bd09ae271a2d31.tar.xz
my_new_personal_website-17c59fb1d1bf3e0c05137af4b4bd09ae271a2d31.zip
Moved plugins to root directory. I'm ditching the idea of shipping plugins with themes until it's more obviously necessary. This way it's easier to merge and update plugins.
Diffstat (limited to 'plugins/pullquote.rb')
-rw-r--r--plugins/pullquote.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/pullquote.rb b/plugins/pullquote.rb
new file mode 100644
index 00000000..ff576fa0
--- /dev/null
+++ b/plugins/pullquote.rb
@@ -0,0 +1,40 @@
+#
+# Author: Brandon Mathis
+# Based on the sematic pullquote technique by Maykel Loomans at http://miekd.com/articles/pull-quotes-with-html5-and-css/
+#
+# Outputs a span with a data-pullquote attribute set from the marked pullquote. Example:
+#
+# {% pullquote %}
+# 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.
+# 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.
+# </span>
+# </p>
+#
+
+module Jekyll
+
+ class PullquoteTag < Liquid::Block
+ def initialize(tag_name, markup, tokens)
+ super
+ end
+
+ def render(context)
+ output = super
+ if output.join =~ /\{"\s*(.+)\s*"\}/
+ @quote = $1
+ "<span class='has-pullquote' data-pullquote='#{@quote}'>#{output.join.gsub(/\{"\s*|\s*"\}/, '')}</span>"
+ else
+ return "Surround your pullquote like this {! text to be quoted !}"
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('pullquote', Jekyll::PullquoteTag)