mdutils
mdutils copied to clipboard
blank lines at the beginning of a file
Describe the bug There may be one or more blank lines at the beginning of the file. There is not any functional reason for this and the behavior may cause other unintended side-effects.
To Reproduce Steps to reproduce the behavior:
- Create a new markdown doc. There will a blank line at the beginning of the doc:
[nav] In [18]: md = MdUtils(file_name='Example')
...: md.new_header(level=1, title='Example Header')
Out[18]: '\n# Example Header\n'
Expected behavior No blank lines at the beginning of the file.
Desktop (please complete the following information):
- OS: MacOS
- Version: 13.4
Additional context It looks like most every operation that adds new markdown content intentionally has a newline at the beginning of the string. For example:
return "\n" + "#" * level.value + " " + title + header_id + "\n"
Additionally with the create_md_file function it looks like there may be more that one blank line added if you don't specify anything for title or have a table of contents:
md_file.rewrite_all_file(
data=self.title
+ self.table_of_contents
+ self.file_data_text
+ self.reference.get_references_as_markdown()