fix: фикс креативов
This commit is contained in:
@@ -252,15 +252,32 @@ func normalizeHTMLTags(input string) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if isClosing {
|
if isClosing {
|
||||||
if len(stack) > 0 && stack[len(stack)-1] == tagName {
|
// Find the tag in stack
|
||||||
stack = stack[:len(stack)-1]
|
foundIndex := -1
|
||||||
out.WriteString(input[i : end+1])
|
for j := len(stack) - 1; j >= 0; j-- {
|
||||||
|
if stack[j] == tagName {
|
||||||
|
foundIndex = j
|
||||||
|
break
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
stack = append(stack, tagName)
|
|
||||||
out.WriteString(input[i : end+1])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if foundIndex >= 0 {
|
||||||
|
// Close all tags from top of stack down to foundIndex
|
||||||
|
for j := len(stack) - 1; j > foundIndex; j-- {
|
||||||
|
out.WriteString("</")
|
||||||
|
out.WriteString(stack[j])
|
||||||
|
out.WriteString(">")
|
||||||
|
}
|
||||||
|
// Close the found tag
|
||||||
|
out.WriteString(input[i : end+1])
|
||||||
|
// Remove closed tags from stack
|
||||||
|
stack = stack[:foundIndex]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
stack = append(stack, tagName)
|
||||||
|
out.WriteString(input[i : end+1])
|
||||||
|
}
|
||||||
|
|
||||||
i = end + 1
|
i = end + 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user