Browse code

added <div> wrappers to code blocks because rdiscount stupidly wraps <figure> tags with paragraphs. Grr.

Brandon Mathis authored on 19/07/2011 at 22:00:56
Showing 2 changed files
... ...
@@ -45,10 +45,10 @@ module Jekyll
45 45
       @highlight = true
46 46
       if markup =~ CaptionUrlTitle
47 47
         @file = $1
48
-        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a</figcaption>"
48
+        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
49 49
       elsif markup =~ CaptionUrl
50 50
         @file = $1
51
-        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a</figcaption>"
51
+        @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a></figcaption>"
52 52
       elsif markup =~ Caption
53 53
         @file = $1
54 54
         @caption = "<figcaption><span>#{$1}</span></figcaption>\n"
... ...
@@ -62,12 +62,12 @@ module Jekyll
62 62
     def render(context)
63 63
       output = super
64 64
       code = super.join
65
-      source = "<figure role=code>\n"
65
+      source = "<div><figure role=code>"
66 66
       source += @caption if @caption
67 67
       if @filetype
68
-        source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}\n</figure>"
68
+        source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>"
69 69
       else
70
-        source += "<pre><code>" + code.gsub!(/</,'&lt;') + "</code></pre>\n</figure>"
70
+        source += "<pre><code>" + code.gsub!(/</,'&lt;') + "</code></pre></figure></div>"
71 71
       end
72 72
       partial = Liquid::Template.parse(source)
73 73
       context.stack do
... ...
@@ -40,8 +40,8 @@ module Jekyll
40 40
         code = file.read
41 41
         file_type = file.extname
42 42
         url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
43
-        source = "<figure role=code><figcaption><span>#{file.basename}</span> <a href='#{url}'>download</a></figcaption>\n"
44
-        source += "{% highlight #{file_type} %}\n" + code + "\n{% endhighlight %}</figure>"
43
+        source = "<div><figure role=code><figcaption><span>#{file.basename}</span> <a href='#{url}'>download</a></figcaption>\n"
44
+        source += "{% highlight #{file_type} %}\n" + code + "\n{% endhighlight %}</figure></div>"
45 45
         partial = Liquid::Template.parse(source)
46 46
         context.stack do
47 47
           partial.render(context)