Sha256: 951a735c262d7b8e64a80eadebb1b2afd3eeced4b9f8cf58fa5e0886f6b19f37

Contents?: true

Size: 1.88 KB

Versions: 14

Compression:

Stored size: 1.88 KB

Contents

#
# Author: Brandon Mathis
# Based on the semantic 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>
#
# {% pullquote left %} will create a left-aligned pullquote instead.
#
# Note: this plugin now creates pullquotes with the class of pullquote-right by default

module Jekyll

  class PullquoteTag < Liquid::Block
    def initialize(tag_name, markup, tokens)
      @align = (markup =~ /left/i) ? "left" : "right"
      super
    end

    def render(context)
      output = super
      if output =~ /\{"\s*(.+?)\s*"\}/m
        @quote = RubyPants.new($1).to_html
        "<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.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)

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
link-checker-0.7.2 spec/test-site/plugins/pullquote.rb
link-checker-0.7.1 spec/test-site/plugins/pullquote.rb
link-checker-0.6.0 spec/test-site/plugins/pullquote.rb
link-checker-0.5.2 spec/test-site/plugins/pullquote.rb
link-checker-0.5.1 spec/test-site/plugins/pullquote.rb
link-checker-0.5.0 spec/test-site/plugins/pullquote.rb
link-checker-0.4.0 spec/test-site/plugins/pullquote.rb
link-checker-0.3.1 spec/test-site/plugins/pullquote.rb
link-checker-0.3.0 spec/test-site/plugins/pullquote.rb
link-checker-0.2.0 spec/test-site/plugins/pullquote.rb
link-checker-0.1.2 spec/test-site/plugins/pullquote.rb
link-checker-0.1.1 spec/test-site/plugins/pullquote.rb
link-checker-0.1.0 spec/test-site/plugins/pullquote.rb
link-checker-0.0.0 spec/test-site/plugins/pullquote.rb