Browse code

Titles in code plugins can have slashes in them. Closes #892

Brandon Mathis authored on 26/12/2012 at 23:18:29
Showing 3 changed files
... ...
@@ -2,7 +2,7 @@ require './plugins/pygments_code'
2 2
 
3 3
 module BacktickCodeBlock
4 4
   include HighlightCode
5
-  AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+|\/\S+)\s*(.+)?/i
5
+  AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
6 6
   LangCaption = /([^\s]+)\s*(.+)?/i
7 7
   def render_code_block(input)
8 8
     @options = nil
... ...
@@ -49,8 +49,8 @@ module Jekyll
49 49
   class CodeBlock < Liquid::Block
50 50
     include HighlightCode
51 51
     include TemplateWrapper
52
-    CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i
53
-    CaptionUrl = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i
52
+    CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
53
+    CaptionUrl = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)/i
54 54
     Caption = /(\S[\S\s]*)/
55 55
     def initialize(tag_name, markup, tokens)
56 56
       @title = nil
... ...
@@ -63,10 +63,10 @@ module Jekyll
63 63
       end
64 64
       if markup =~ CaptionUrlTitle
65 65
         @file = $1
66
-        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
66
+        @caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>#{$3}</a></figcaption>"
67 67
       elsif markup =~ CaptionUrl
68 68
         @file = $1
69
-        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a></figcaption>"
69
+        @caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>link</a></figcaption>"
70 70
       elsif markup =~ Caption
71 71
         @file = $1
72 72
         @caption = "<figcaption><span>#{$1}</span></figcaption>\n"
73 73
new file mode 100644
74 74
Binary files /dev/null and b/source/images/icon-sdc231d6676.png differ