Skip to content

Commit

Permalink
Fix regex bug in _contrib/updatetx.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
saivann committed Nov 5, 2014
1 parent 9a34a96 commit 1b6d736
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions _contrib/updatetx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def prompt(*args)
next if file == '.' or file == '..'
contents = File.read(dir + '/' + file)
# Drop HTML code applied to current language only ( until next {% when / else / endcase %} statement )
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!.*?{% endcase %})(?!.*?{% else %}).)*?{% when", Regexp::MULTILINE),'{% when')
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!.*?{% endcase %}).)*?{% else %}", Regexp::MULTILINE),'{% else %}')
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %})(?!.*?{% else %}).)*?{% when", Regexp::MULTILINE),'{% when')
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %}).)*?{% else %}", Regexp::MULTILINE),'{% else %}')
contents.gsub!(Regexp.new("{% when '" + lang + "' %}.*?{% endcase %}", Regexp::MULTILINE),'{% endcase %}')
# Drop complete {% case / endcase %} statements when not used by any language anymore
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% when ).)*?){% else %}(.*?){% endcase %}", Regexp::MULTILINE),'\1 \3')
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% endcase %})(?!{% when ).)*?){% else %}(.*?){% endcase %}", Regexp::MULTILINE),'\1 \3')
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% when ).)*?){% endcase %}", Regexp::MULTILINE),'\1')
# Drop language in statements applied to many languages ( e.g. {% when 'ar' or 'fr' .. %} )
contents.gsub!(Regexp.new("{% when '" + lang + "' or (.*?) %}"),'{% when \1 %}')
Expand Down

0 comments on commit 1b6d736

Please sign in to comment.