A platform for community discussion. Free, open, simple.
FIX: don't add diff classes more than once
Régis Hanol001b0710c743
diff --git a/lib/discourse_diff.rb b/lib/discourse_diff.rbindex c1971ed7108..89d293e4319 100644--- a/lib/discourse_diff.rb+++ b/lib/discourse_diff.rb@@ -184,8 +184,13 @@ class DiscourseDiff# add it right before the ">"html_or_text.insert(index_of_next_chevron, " class=\"diff-#{klass}\"")else- # we have a class, insert it at the beginning- html_or_text.insert(index_of_class + "class=".length + 1, "diff-#{klass} ")+ # we have a class, insert it at the beginning if not already present+ classes = html_or_text[/class=(["'])([^\1]*)\1/, 2]+ if classes.include?("diff-#{klass}")+ html_or_text+ else+ html_or_text.insert(index_of_class + "class=".length + 1, "diff-#{klass} ")+ endendelse"<#{klass}>#{html_or_text}</#{klass}>"