diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/backtick_code_block.rb | 2 | ||||
-rw-r--r-- | plugins/blockquote.rb | 4 | ||||
-rw-r--r-- | plugins/category_generator.rb | 16 | ||||
-rw-r--r-- | plugins/code_block.rb | 10 | ||||
-rw-r--r-- | plugins/gist_tag.rb | 4 | ||||
-rw-r--r-- | plugins/octopress_filters.rb | 8 | ||||
-rw-r--r-- | plugins/pullquote.rb | 6 |
7 files changed, 29 insertions, 21 deletions
diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb index 40e7900b..8e2c1141 100644 --- a/plugins/backtick_code_block.rb +++ b/plugins/backtick_code_block.rb @@ -2,7 +2,7 @@ require './plugins/pygments_code' module BacktickCodeBlock include HighlightCode - AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+)\s*(.+)?/i + AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i LangCaption = /([^\s]+)\s*(.+)?/i def render_code_block(input) @options = nil diff --git a/plugins/blockquote.rb b/plugins/blockquote.rb index 7fb8c261..62e7d143 100644 --- a/plugins/blockquote.rb +++ b/plugins/blockquote.rb @@ -46,7 +46,7 @@ module Jekyll end def render(context) - quote = paragraphize(super.map(&:strip).join) + quote = paragraphize(super) author = "<strong>#{@by.strip}</strong>" if @by if @source url = @source.match(/https?:\/\/(.+)/)[1].split('/') @@ -75,7 +75,7 @@ module Jekyll end def paragraphize(input) - "<p>#{input.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')}</p>" + "<p>#{input.lstrip.rstrip.gsub(/\n\n/, '</p><p>').gsub(/\n/, '<br/>')}</p>" end end end diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb index bb5fd329..77e06afb 100644 --- a/plugins/category_generator.rb +++ b/plugins/category_generator.rb @@ -141,10 +141,7 @@ module Jekyll # Returns string # def category_links(categories) - dir = @context.registers[:site].config['category_dir'] - categories = categories.sort!.map do |item| - "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>" - end + categories = categories.sort!.map { |c| category_link c } case categories.length when 0 @@ -156,6 +153,17 @@ module Jekyll end end + # Outputs a single category as an <a> link. + # + # +category+ is a category string to format as an <a> link + # + # Returns string + # + def category_link(category) + dir = @context.registers[:site].config['category_dir'] + "<a class='category' href='/#{dir}/#{category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{category}</a>" + end + # Outputs the post.date as formatted html, with hooks for CSS styling. # # +date+ is the date object to format as HTML. diff --git a/plugins/code_block.rb b/plugins/code_block.rb index e175d445..660f73d7 100644 --- a/plugins/code_block.rb +++ b/plugins/code_block.rb @@ -49,8 +49,7 @@ module Jekyll class CodeBlock < Liquid::Block include HighlightCode include TemplateWrapper - CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i - CaptionUrl = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i + CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i Caption = /(\S[\S\s]*)/ def initialize(tag_name, markup, tokens) @title = nil @@ -63,10 +62,7 @@ module Jekyll end if markup =~ CaptionUrlTitle @file = $1 - @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>" - elsif markup =~ CaptionUrl - @file = $1 - @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a></figcaption>" + @caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>#{$3 || 'link'}</a></figcaption>" elsif markup =~ Caption @file = $1 @caption = "<figcaption><span>#{$1}</span></figcaption>\n" @@ -79,7 +75,7 @@ module Jekyll def render(context) output = super - code = super.join + code = super source = "<figure class='code'>" source += @caption if @caption if @filetype diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index 74dd3b37..5f590e96 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -40,7 +40,9 @@ module Jekyll end def script_url_for(gist_id, filename) - "https://gist.github.com/#{gist_id}.js?file=#{filename}" + url = "https://gist.github.com/#{gist_id}.js" + url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty? + url end def get_gist_url_for(gist, file) diff --git a/plugins/octopress_filters.rb b/plugins/octopress_filters.rb index a5bb235c..091f75aa 100644 --- a/plugins/octopress_filters.rb +++ b/plugins/octopress_filters.rb @@ -24,10 +24,14 @@ module Jekyll class ContentFilters < PostFilter include OctopressFilters def pre_render(post) - post.content = pre_filter(post.content) + if post.ext.match('html|textile|markdown|md|haml|slim|xml') + post.content = pre_filter(post.content) + end end def post_render(post) - post.content = post_filter(post.content) + if post.ext.match('html|textile|markdown|md|haml|slim|xml') + post.content = post_filter(post.content) + end end end end diff --git a/plugins/pullquote.rb b/plugins/pullquote.rb index 2b59bad6..3c65e66e 100644 --- a/plugins/pullquote.rb +++ b/plugins/pullquote.rb @@ -32,11 +32,9 @@ module Jekyll def render(context) output = super - if output.join =~ /\{"\s*(.+)\s*"\}/ - #@quote = $1 + if output =~ /\{"\s*(.+?)\s*"\}/m @quote = RubyPants.new($1).to_html - #@quote = CGI.escape($1) - "<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.join.gsub(/\{"\s*|\s*"\}/, '')}</span>" + "<span class='pullquote-#{@align}' data-pullquote='#{@quote}'>#{output.gsub(/\{"\s*|\s*"\}/, '')}</span>" else return "Surround your pullquote like this {\" text to be quoted \"}" end |