Created
March 11, 2013 12:30
-
-
Save wcombs/5133928 to your computer and use it in GitHub Desktop.
Octopress code_block link/title overlap fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9e5d5d6e045cd8cf1df3456005ea4c7746ae7939 Mon Sep 17 00:00:00 2001 | |
From: Will Combs <combsw@gmail.com> | |
Date: Mon, 11 Mar 2013 07:54:40 -0400 | |
Subject: [PATCH 1/1] Fixed code_block plugin title/link overlap issue | |
--- | |
.themes/classic/sass/partials/_syntax.scss | 10 +++++++--- | |
plugins/code_block.rb | 16 +++++++++++++--- | |
2 files changed, 20 insertions(+), 6 deletions(-) | |
diff --git a/.themes/classic/sass/partials/_syntax.scss b/.themes/classic/sass/partials/_syntax.scss | |
index 5465286..ea5f838 100644 | |
--- a/.themes/classic/sass/partials/_syntax.scss | |
+++ b/.themes/classic/sass/partials/_syntax.scss | |
@@ -225,7 +225,8 @@ figure.code { | |
figcaption { | |
position: relative; | |
@extend .code-title; | |
- a { @extend .download-source; } | |
+ a { position: relative; | |
+ @extend .download-source; } | |
} | |
.highlight { | |
margin-bottom: 0; | |
@@ -251,11 +252,14 @@ figure.code { | |
} | |
.download-source { | |
- position: absolute; right: .8em; | |
+ right: .8em; | |
@include hover-link; | |
color: #666 !important; | |
z-index: 1; | |
font-size: 13px; | |
text-shadow: #cbcccc 0 1px 0; | |
- padding-left: 3em; | |
+} | |
+ | |
+.figfooter { | |
+ border-radius: 0px 0px 5px 5px !important; | |
} | |
diff --git a/plugins/code_block.rb b/plugins/code_block.rb | |
index 660f73d..ca0de55 100644 | |
--- a/plugins/code_block.rb | |
+++ b/plugins/code_block.rb | |
@@ -54,6 +54,8 @@ module Jekyll | |
def initialize(tag_name, markup, tokens) | |
@title = nil | |
@caption = nil | |
+ @linkTitle = nil | |
+ @linkUrl = nil | |
@filetype = nil | |
@highlight = true | |
if markup =~ /\s*lang:(\w+)/i | |
@@ -62,7 +64,9 @@ module Jekyll | |
end | |
if markup =~ CaptionUrlTitle | |
@file = $1 | |
- @caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>#{$3 || 'link'}</a></figcaption>" | |
+ @linkUrl = $2 | |
+ @linkTitle = $3 | |
+ @caption = "<figcaption><span>#{$1}</span></figcaption>" | |
elsif markup =~ Caption | |
@file = $1 | |
@caption = "<figcaption><span>#{$1}</span></figcaption>\n" | |
@@ -79,10 +83,16 @@ module Jekyll | |
source = "<figure class='code'>" | |
source += @caption if @caption | |
if @filetype | |
- source += " #{highlight(code, @filetype)}</figure>" | |
+ source += " #{highlight(code, @filetype)}" | |
else | |
- source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'<'))}</figure>" | |
+ source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'<'))}" | |
end | |
+ if !@linkTitle.nil? | |
+ source += "<figcaption class='figfooter'><a href='#{@linkUrl}'>#{@linkTitle}</a></figcaption>" | |
+ elsif !@linkUrl.nil? | |
+ source += "<figcaption class='figfooter'><a href='#{@linkUrl}'>link</a></figcaption>" | |
+ end | |
+ source += "</figure>" | |
source = safe_wrap(source) | |
source = context['pygments_prefix'] + source if context['pygments_prefix'] | |
source = source + context['pygments_suffix'] if context['pygments_suffix'] | |
-- | |
1.7.10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment