mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-28 13:36:14 +02:00
* Fix YAML export syntax * Fix YAML body block indentation
This commit is contained in:
parent
61f8406412
commit
5c0a2d4c4e
2 changed files with 41 additions and 31 deletions
|
@ -410,11 +410,12 @@ Feature: Custom formats
|
||||||
"""
|
"""
|
||||||
And the content of file "2020-08-29_entry-the-first.md" in the cache should be
|
And the content of file "2020-08-29_entry-the-first.md" in the cache should be
|
||||||
"""
|
"""
|
||||||
|
---
|
||||||
title: Entry the first.
|
title: Entry the first.
|
||||||
date: 2020-08-29 11:11
|
date: 2020-08-29 11:11
|
||||||
starred: False
|
starred: False
|
||||||
tags: tagone, ipsum, tagtwo
|
tags: tagone, ipsum, tagtwo
|
||||||
|
body: |
|
||||||
Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
|
||||||
quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque
|
quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque
|
||||||
augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
augue et venenatis facilisis. Suspendisse potenti. Sed dignissim sed nisl eu
|
||||||
|
@ -433,6 +434,7 @@ Feature: Custom formats
|
||||||
velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
velit scelerisque fringilla. Phasellus pharetra justo et nulla fringilla, ac
|
||||||
porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
porta sapien accumsan. Class aptent taciti sociosqu ad litora torquent per
|
||||||
conubia nostra, per inceptos himenaeos.
|
conubia nostra, per inceptos himenaeos.
|
||||||
|
...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
|
@ -458,11 +460,12 @@ Feature: Custom formats
|
||||||
"""
|
"""
|
||||||
And the content of file "2020-09-24_the-third-entry-finally-after-weeks-without-writing.md" in the cache should be
|
And the content of file "2020-09-24_the-third-entry-finally-after-weeks-without-writing.md" in the cache should be
|
||||||
"""
|
"""
|
||||||
|
---
|
||||||
title: The third entry finally after weeks without writing.
|
title: The third entry finally after weeks without writing.
|
||||||
date: 2020-09-24 09:14
|
date: 2020-09-24 09:14
|
||||||
starred: False
|
starred: False
|
||||||
tags: tagone, tagthree
|
tags: tagone, tagthree
|
||||||
|
body: |
|
||||||
I'm so excited about emojis. 💯 🎶 💩
|
I'm so excited about emojis. 💯 🎶 💩
|
||||||
|
|
||||||
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
|
||||||
|
@ -473,6 +476,7 @@ Feature: Custom formats
|
||||||
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
vulputate. Sed mauris urna, consectetur in justo eu, volutpat accumsan justo.
|
||||||
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
Phasellus aliquam lacus placerat convallis vestibulum. Curabitur maximus at
|
||||||
ante eget fringilla. @tagthree and also @tagone
|
ante eget fringilla. @tagthree and also @tagone
|
||||||
|
...
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Examples: configs
|
Examples: configs
|
||||||
|
|
|
@ -75,6 +75,11 @@ class YAMLExporter(TextExporter):
|
||||||
if previous_line not in ["\r", "\n", "\r\n", "\n\r"]:
|
if previous_line not in ["\r", "\n", "\r\n", "\n\r"]:
|
||||||
newbody = newbody + os.linesep
|
newbody = newbody + os.linesep
|
||||||
|
|
||||||
|
# set indentation for YAML body block
|
||||||
|
spacebody = "\t"
|
||||||
|
for line in newbody.splitlines(True):
|
||||||
|
spacebody = spacebody + "\t" + line
|
||||||
|
|
||||||
if warn_on_heading_level is True:
|
if warn_on_heading_level is True:
|
||||||
print(
|
print(
|
||||||
"{}WARNING{}: Headings increased past H6 on export - {} {}".format(
|
"{}WARNING{}: Headings increased past H6 on export - {} {}".format(
|
||||||
|
@ -113,14 +118,15 @@ class YAMLExporter(TextExporter):
|
||||||
# source directory is entry.journal.config['journal']
|
# source directory is entry.journal.config['journal']
|
||||||
# output directory is...?
|
# output directory is...?
|
||||||
|
|
||||||
return "title: {title}\ndate: {date}\nstarred: {starred}\ntags: {tags}\n{dayone} {body} {space}".format(
|
return "{start}\ntitle: {title}\ndate: {date}\nstarred: {starred}\ntags: {tags}\n{dayone}body: |{body}{end}".format(
|
||||||
|
start="---",
|
||||||
date=date_str,
|
date=date_str,
|
||||||
title=entry.title,
|
title=entry.title,
|
||||||
starred=entry.starred,
|
starred=entry.starred,
|
||||||
tags=", ".join([tag[1:] for tag in entry.tags]),
|
tags=", ".join([tag[1:] for tag in entry.tags]),
|
||||||
dayone=dayone_attributes,
|
dayone=dayone_attributes,
|
||||||
body=newbody,
|
body=spacebody,
|
||||||
space="",
|
end="...",
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue