Skip to content

Commit 7c489e6

Browse files
committed
Removed runts from image galleries
Applied the "no runts" to the image gallery include. Require a minor fix to the plugin itself so it doesn't break when a null value is passed in.
1 parent 33539f0 commit 7c489e6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

_includes/image-gallery.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{% capture imageURL %}{{ page.image_base }}{{ item.file }}.png{% endcapture %}
66
{% capture imageURLRetina %}{{ page.image_base }}{{ item.file }}@2x.png{% endcapture %}
7-
{% capture captionText %}{{ item.caption | markdownify }}{% endcapture %}
7+
{% capture captionText %}{{ item.caption | no_runts | markdownify }}{% endcapture %}
88

99
{% include picture.html
1010
image = imageURL

_plugins/no_runts.rb

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
module Jekyll
22
module RuntFilter
33
def no_runts(title)
4-
if title.strip.count(" ") >= 2
5-
firstPart = title.split[0...-1].join(" ")
6-
lastOpen = firstPart.rindex("<")
4+
if(title)
5+
if title.strip.count(" ") >= 2
6+
firstPart = title.split[0...-1].join(" ")
7+
lastOpen = firstPart.rindex("<")
78

8-
if lastOpen
9-
title.strip
9+
if lastOpen
10+
title.strip
11+
else
12+
title.split[0...-1].join(" ") + "&nbsp;#{title.split[-1]}"
13+
end
1014
else
11-
title.split[0...-1].join(" ") + "&nbsp;#{title.split[-1]}"
15+
title.strip
1216
end
1317
else
14-
title.strip
18+
title
1519
end
1620
end
1721
end

0 commit comments

Comments
 (0)