mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-22 05:58:31 +02:00
[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....
This commit is contained in:
parent
9215dc5692
commit
6b8c6f81ad
4 changed files with 49 additions and 1 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -42,12 +42,15 @@ obj
|
|||
# virtaulenv
|
||||
env/
|
||||
env*/
|
||||
venv*/
|
||||
|
||||
# PyCharm Project files
|
||||
.idea/
|
||||
|
||||
# export testing director
|
||||
# export testing directories
|
||||
exp/
|
||||
bug768/
|
||||
exported_journal/
|
||||
|
||||
_extras/
|
||||
*.sublime-*
|
||||
|
|
|
@ -122,3 +122,40 @@ Feature: Zapped bugs should stay dead.
|
|||
Then the output should contain "This thing happened yesterday"
|
||||
Then the output should contain "Adding an entry right now."
|
||||
Then the output should not contain "A future entry."
|
||||
|
||||
# See issues #768 and #881
|
||||
# the "deletion" journal is used because it doesn't have a newline at the
|
||||
# end of the last entry
|
||||
Scenario: Add a blank line to Markdown export is there isn't one already
|
||||
Given we use the config "deletion.yaml"
|
||||
When we run "jrnl --export markdown"
|
||||
Then the output should be
|
||||
"""
|
||||
# 2019
|
||||
|
||||
## October
|
||||
|
||||
### 2019-10-29 11:11 First entry.
|
||||
|
||||
|
||||
### 2019-10-29 11:11 Second entry.
|
||||
|
||||
|
||||
### 2019-10-29 11:13 Third entry.
|
||||
|
||||
"""
|
||||
|
||||
# See issues #768 and #881
|
||||
Scenario: Add a blank line to YAML export is there isn't one already
|
||||
Given we use the config "deletion.yaml"
|
||||
And we created a directory named "bug768"
|
||||
When we run "jrnl --export yaml -o bug768"
|
||||
Then "bug768" should contain the files ["2019-10-29_first-entry.md", "2019-10-29_second-entry.md", "2019-10-29_third-entry.md"]
|
||||
And the content of exported yaml "bug768/2019-10-29_third-entry.md" should be
|
||||
"""
|
||||
title: Third entry.
|
||||
date: 2019-10-29 11:13
|
||||
stared: False
|
||||
tags:
|
||||
|
||||
"""
|
||||
|
|
|
@ -54,6 +54,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}: "
|
||||
|
|
|
@ -66,6 +66,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
Reference in a new issue