diff --git a/_plugins/tabs.rb b/_plugins/tabs.rb
index adc273de945..cea844897f7 100644
--- a/_plugins/tabs.rb
+++ b/_plugins/tabs.rb
@@ -1,3 +1,5 @@
+require 'digest/md5'
+
module Tags
class TabsBlock < Liquid::Block
def initialize(tag_name, tabonly = 'false', tokens)
@@ -13,12 +15,15 @@ def render(context)
tabslist = '
' + "\n"
if tabs.length > 0
tabs.each_with_index do |tab, ind|
+ tabslug = tab[0].gsub(/[^0-9a-z]/i, '')
+ tabslug = Digest::MD5.hexdigest(tab[0]) if tabslug.empty?
+
# scan returns array of results, only care about first match
- tabslist += ' - ' + tab[0] + '
' + "\n"
+ tabslist += '">' + tab[0] + '' + "\n"
end
end
tabslist += '
' + "\n"
@@ -48,7 +53,8 @@ def render(context)
content = indentation ? super.gsub(/^#{' |\t' * indentation}/, '') : super
content = converter.convert(content)
content = content.strip # Strip again to avoid "\n"
- tabslug = @tab.gsub(' ', '-')
+ tabslug = @tab.gsub(/[^0-9a-z]/i, '')
+ tabslug = Digest::MD5.hexdigest(@tab) if tabslug.empty?
'' + content + "
"
end
@@ -66,15 +72,17 @@ def initialize(tag_name, tabonly = 'false', tokens)
def render(context)
tabs = super.scan(/data\-sub\_tab=\"(.*?)\"/)
tabslist = '' + "\n"
-
if tabs.length > 0
tabs.each_with_index do |tab, ind|
+ tabslug = tab[0].gsub(/[^0-9a-z]/i, '')
+ tabslug = Digest::MD5.hexdigest(tab[0]) if tabslug.empty?
+
# scan returns array of results, only care about first match
- tabslist += ' - ' + tab[0] + '
' + "\n"
+ tabslist += '">' + tab[0] + '' + "\n"
end
end
tabslist += '
' + "\n"
@@ -104,7 +112,8 @@ def render(context)
content = indentation ? super.gsub(/^#{' |\t' * indentation}/, '') : super
content = converter.convert(content)
content = content.strip # Strip again to avoid "\n"
- tabslug = @tab.gsub(' ', '-')
+ tabslug = @tab.gsub(/[^0-9a-z]/i, '')
+ tabslug = Digest::MD5.hexdigest(@tab) if tabslug.empty?
'' + content + "
"
end