mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 14:06:14 +02:00
Ensure exported entries end in a newline for Markdown and YAML exporters (#908)
* [Markdown Exporter] [YAML Exporter] Ensure exported entires end in a newline Fixes #768, Fixes #881. If the exported entry does not have a final empty line, this will add one on export. Some Markdown parsers get picky about not having a empty line above a heading.... * fix black formatting issues * explicitly sort filenames to deal with inconsistent default file ordering on different OS's * Update .gitignore * Update test for typo fix Co-authored-by: Jonathan Wren <jonathan@nowandwren.com>
This commit is contained in:
parent
62ea1e2b23
commit
68ad5c0c1a
5 changed files with 52 additions and 1 deletions
|
@ -53,6 +53,10 @@ class MarkdownExporter(TextExporter):
|
|||
previous_line = line
|
||||
newbody = newbody + previous_line # add very last line
|
||||
|
||||
# make sure the export ends with a blank line
|
||||
if previous_line not in ["\r", "\n", "\r\n", "\n\r"]:
|
||||
newbody = newbody + os.linesep
|
||||
|
||||
if warn_on_heading_level is True:
|
||||
print(
|
||||
f"{WARNING_COLOR}WARNING{RESET_COLOR}: "
|
||||
|
|
|
@ -64,6 +64,10 @@ class YAMLExporter(TextExporter):
|
|||
previous_line = line
|
||||
newbody = newbody + previous_line # add very last line
|
||||
|
||||
# make sure the export ends with a blank line
|
||||
if previous_line not in ["\r", "\n", "\r\n", "\n\r"]:
|
||||
newbody = newbody + os.linesep
|
||||
|
||||
if warn_on_heading_level is True:
|
||||
print(
|
||||
"{}WARNING{}: Headings increased past H6 on export - {} {}".format(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue