Sha256: 99cabed121617c1c894db0804bfe144e437c1dcaa784b357e827a021e90a8459
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
require 'jekyll_plugin_support' require 'jekyll_plugin_helper' require_relative 'jekyll_quote/version' # @author Copyright 2022 Michael Slinn # @license SPDX-License-Identifier: Apache-2.0 module QuoteModule PLUGIN_NAME = 'quote'.freeze end module Jekyll # Usage: {% quote [break] [by] [cite='Joe Blow'] [noprep] [url='https://blabla.com'] %}Bla bla.{% endquote %} # Output looks like: # <div class='quote'> # Bla bla. # <br><br> <span style='font-style:normal;'> – From Source cite.</span> # </div> class Quote < JekyllSupport::JekyllBlock attr_accessor :cite, :url include JekyllQuoteVersion def render_impl(text) @helper.gem_file __FILE__ # This enables plugin attribution @break = @helper.parameter_specified? 'break' # enforced by CSS if a list ends the body @by = @helper.parameter_specified? 'by' @cite = @helper.parameter_specified? 'cite' @noprep = @helper.parameter_specified? 'noprep' @url = @helper.parameter_specified? 'url' preposition = 'From' preposition = 'By' if @by preposition = '' if @noprep if @cite quote_attribution = if @url && !@url.empty? "<a href='#{@url}' rel='nofollow' target='_blank'>#{@cite}</a>" else "#{@cite}\n" end tag = @break ? 'div' : 'span' quote_attribution = "<#{tag} class='quoteAttribution'> – #{preposition} #{quote_attribution}</#{tag}>\n" text = "<div class='quoteText clearfix'>#{text}</div>" if @break end <<~END_HERE <div class='quote'> #{text}#{quote_attribution} #{@helper.attribute if @helper.attribution} </div> END_HERE end JekyllPluginHelper.register(self, QuoteModule::PLUGIN_NAME) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll_quote-0.4.0 | lib/jekyll_quote.rb |