diff --git a/Commands/Blogsmith Typography Preview.tmCommand b/Commands/Blogsmith Typography Preview.tmCommand index 26cff8f..b699cad 100644 --- a/Commands/Blogsmith Typography Preview.tmCommand +++ b/Commands/Blogsmith Typography Preview.tmCommand @@ -28,7 +28,9 @@ end def strip_html(string,removals) iterations = string.scan(/<[^>]+>/).length while iterations > 0 - string.sub!(/(<[^>]+>)/,"%#{removals.length}%") + subnum = removals.length + subnum = "0" + subnum.to_s if subnum.to_s.length == 1 + string.sub!(/(<[^>]+>)/,"%#{subnum}%") removals += $1.to_a iterations -= 1 end @@ -67,7 +69,8 @@ def restore_replacements(string,removals) removals.each_with_index {|removal,x| x = "0" + x.to_s if x.to_s.length == 1 m = string.match(/%#{x}([^%]+)?%/) - if m[1].nil? + next if m.nil? + if m[1].nil? string.sub!(/%#{x}%/,removals[x.to_i]) else if removals[x.to_i] =~ /\[[^\]]+\]([\[\(][^\]\)]+[\]\)])/ diff --git a/Commands/Blogsmith Typography.tmCommand b/Commands/Blogsmith Typography.tmCommand index 55c9dd0..1203d5b 100644 --- a/Commands/Blogsmith Typography.tmCommand +++ b/Commands/Blogsmith Typography.tmCommand @@ -6,6 +6,9 @@ nop command #!/usr/bin/env ruby -wKU + +SUPPORT = ENV['TM_SUPPORT_PATH'] +require SUPPORT + '/lib/exit_codes' require 'erb' # CHANGE: 3/27/09 search for $32.25 with no trailing US, accounts for possible space ($32 US) @@ -22,7 +25,9 @@ end def strip_html(string,removals) iterations = string.scan(/<[^>]+>/).length while iterations > 0 - string.sub!(/(<[^>]+>)/,"%#{removals.length}%") + subnum = removals.length + subnum = "0" + subnum.to_s if subnum.to_s.length == 1 + string.sub!(/(<[^>]+>)/,"%#{subnum}%") removals += $1.to_a iterations -= 1 end @@ -61,7 +66,8 @@ def restore_replacements(string,removals) removals.each_with_index {|removal,x| x = "0" + x.to_s if x.to_s.length == 1 m = string.match(/%#{x}([^%]+)?%/) - if m[1].nil? + next if m.nil? + if m[1].nil? string.sub!(/%#{x}%/,removals[x.to_i]) else if removals[x.to_i] =~ /\[[^\]]+\]([\[\(][^\]\)]+[\]\)])/ diff --git a/Macros/Correct Typography and Show Changes.tmMacro b/Macros/Correct Typography and Show Changes 2.tmMacro similarity index 95% rename from Macros/Correct Typography and Show Changes.tmMacro rename to Macros/Correct Typography and Show Changes 2.tmMacro index 21304c6..72cf6c9 100644 --- a/Macros/Correct Typography and Show Changes.tmMacro +++ b/Macros/Correct Typography and Show Changes 2.tmMacro @@ -33,7 +33,9 @@ end def strip_html(string,removals) iterations = string.scan(/<[^>]+>/).length while iterations > 0 - string.sub!(/(<[^>]+>)/,"%#{removals.length}%") + subnum = removals.length + subnum = "0" + subnum.to_s if subnum.to_s.length == 1 + string.sub!(/(<[^>]+>)/,"%#{subnum}%") removals += $1.to_a iterations -= 1 end @@ -72,7 +74,8 @@ def restore_replacements(string,removals) removals.each_with_index {|removal,x| x = "0" + x.to_s if x.to_s.length == 1 m = string.match(/%#{x}([^%]+)?%/) - if m[1].nil? + next if m.nil? + if m[1].nil? string.sub!(/%#{x}%/,removals[x.to_i]) else if removals[x.to_i] =~ /\[[^\]]+\]([\[\(][^\]\)]+[\]\)])/ @@ -205,6 +208,9 @@ html_footer nop command #!/usr/bin/env ruby -wKU + +SUPPORT = ENV['TM_SUPPORT_PATH'] +require SUPPORT + '/lib/exit_codes' require 'erb' # CHANGE: 3/27/09 search for $32.25 with no trailing US, accounts for possible space ($32 US) @@ -221,7 +227,9 @@ end def strip_html(string,removals) iterations = string.scan(/<[^>]+>/).length while iterations > 0 - string.sub!(/(<[^>]+>)/,"%#{removals.length}%") + subnum = removals.length + subnum = "0" + subnum.to_s if subnum.to_s.length == 1 + string.sub!(/(<[^>]+>)/,"%#{subnum}%") removals += $1.to_a iterations -= 1 end @@ -260,7 +268,8 @@ def restore_replacements(string,removals) removals.each_with_index {|removal,x| x = "0" + x.to_s if x.to_s.length == 1 m = string.match(/%#{x}([^%]+)?%/) - if m[1].nil? + next if m.nil? + if m[1].nil? string.sub!(/%#{x}%/,removals[x.to_i]) else if removals[x.to_i] =~ /\[[^\]]+\]([\[\(][^\]\)]+[\]\)])/ @@ -351,6 +360,6 @@ print restore_replacements(newstring + string,removals) scope text.html,text.html.markdown,text.html.markdown.multimarkdown uuid - 8BA9BA89-00ED-47C5-A137-35E9C64A205C + 24AEA2EE-846A-4246-A326-7F2FC9727E97 diff --git a/info.plist b/info.plist index f5f201b..788f0e1 100644 --- a/info.plist +++ b/info.plist @@ -112,6 +112,7 @@ ordering 8BA9BA89-00ED-47C5-A137-35E9C64A205C + 24AEA2EE-846A-4246-A326-7F2FC9727E97 7D554CE8-6BD2-4D30-A8AC-13D434443102 925F2507-B49C-43A6-B521-53315894BD0A 363B0133-F480-495C-B68B-9122101D9DE1