The solution for this may be related to Bug 61049:
If you add a caption to an image, and you press return in the text area box at the end (perhaps several times), then the caption includes those pointless blank lines, which makes for ugly wikitext when the page is saved.
See https://en.wikipedia.org/w/index.php?title=Sugar_candy&diff=613063549&oldid=611921250
Version: unspecified
Severity: enhancement