Skip to content

Commit 9a59d9a

Browse files
committed
reverting span close logic
1 parent 0eaefbc commit 9a59d9a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

services/gitdiff/highlightdiff.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,17 @@ func (hcd *highlightCodeDiff) recoverOneDiff(diff *diffmatchpatch.Diff) {
201201
sb.WriteString(tokenToRecover)
202202
}
203203

204+
if len(tagStack) > 0 {
205+
// close all opening tags
206+
for i := len(tagStack) - 1; i >= 0; i-- {
207+
tagToClose := tagStack[i]
208+
// get the closing tag "</span>" from "<span class=...>" or "<span>"
209+
pos := strings.IndexAny(tagToClose, " >")
210+
if pos != -1 {
211+
sb.WriteString("</" + tagToClose[1:pos] + ">")
212+
} // else: impossible. every tag was pushed into the stack by the code above and is valid HTML opening tag
213+
}
214+
}
215+
204216
diff.Text = sb.String()
205217
}

0 commit comments

Comments
 (0)