def ensure_newline(self, n):
        assert n >= 0
        text = self._output.getvalue().rstrip('\n')
        if not text:
            return
        self._output = StringIO()
        self._output.write(text)
        self._output.write('\n' * n)
        text = self._output.getvalue()
        assert text[-n-1] != '\n'
        assert text[-n:] == '\n' * n

    # Block methods
    # -------------------------------------------------------------------------
Make sure there are 'n' line breaks at the end.
dataset/ETHPy150Open rossant/ipymd/ipymd/lib/markdown.py/MarkdownWriter.ensure_newline