I've got some code which is essentially:
> wikicode = mwp.parse(self.page.get())
> for node in wikicode.filter_templates(recursive=False, matches=title):
> wikicode.remove(node)
> self.page.text = str(wikicode)
> self.page.save()
which works, but it leaves an extra blank line behind where the template used to be. This is intended to be run on [[:en:Template talk:Did you know/Approved]], i.e. one template per line.
What's the best way to get rid of the blank lines? I'm trying to avoid just running a regex replacement on the raw text because that's fragile, but maybe theres really no good alternative here?