mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 12:25:30 +08:00
FIX: don't add diff classes more than once
This commit is contained in:
parent
a4a0b8e922
commit
001b0710c7
@ -184,8 +184,13 @@ class DiscourseDiff
|
|||||||
# add it right before the ">"
|
# add it right before the ">"
|
||||||
html_or_text.insert(index_of_next_chevron, " class=\"diff-#{klass}\"")
|
html_or_text.insert(index_of_next_chevron, " class=\"diff-#{klass}\"")
|
||||||
else
|
else
|
||||||
# we have a class, insert it at the beginning
|
# we have a class, insert it at the beginning if not already present
|
||||||
html_or_text.insert(index_of_class + "class=".length + 1, "diff-#{klass} ")
|
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} ")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
"<#{klass}>#{html_or_text}</#{klass}>"
|
"<#{klass}>#{html_or_text}</#{klass}>"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user