Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delimiters in YAML format #1150

Merged
merged 3 commits into from Jan 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion features/format.feature
Expand Up @@ -410,10 +410,12 @@ Feature: Custom formats
"""
And the content of file "2020-08-29_entry-the-first.md" in the cache should be
"""
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the example in #1065 meant the dashes here as a placeholder for content earlier in the file (not actual dashes).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, hey, these dashes actually part of the yaml spec. My mistake!

https://yaml.org/spec/1.2/spec.html#id2760395

Copy link
Contributor Author

@Seopril Seopril Jan 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the example was supposed to be actual dashes and dots based on Pandoc documentation that was linked in the ticket. https://pandoc.org/MANUAL.html#metadata-blocks

"A YAML metadata block is a valid YAML object, delimited by a line of three hyphens (---) at the top and a line of three hyphens (---) or three dots (...) at the bottom."

Didn't refresh and just saw your second comment. My bad

title: Entry the first.
date: 2020-08-29 11:11
starred: False
tags: tagone, ipsum, tagtwo
...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the example in #1065 meant the dots here as a placeholder for content later in the file (not actual dots).

Copy link
Member

@wren wren Jan 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, hey, these dots actually part of the yaml spec. My mistake!

https://yaml.org/spec/1.2/spec.html#id2760395


Lorem @ipsum dolor sit amet, consectetur adipiscing elit. Praesent malesuada
quis est ac dignissim. Aliquam dignissim rutrum pretium. Phasellus pellentesque
Expand Down Expand Up @@ -458,11 +460,13 @@ 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
"""
---
title: The third entry finally after weeks without writing.
date: 2020-09-24 09:14
starred: False
tags: tagone, tagthree
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing the body: | part of the description in #1065. This is the main part of the yaml exporter than needs fixing. The body key needs to be output (followed by : |), then the body of the entry should follow on the next line, and be indented evenly, and indented farther than the body key.


...

I'm so excited about emojis. 💯 🎶 💩

Donec semper pellentesque iaculis. Nullam cursus et justo sit amet venenatis.
Expand Down
5 changes: 3 additions & 2 deletions jrnl/plugins/yaml_exporter.py
Expand Up @@ -113,14 +113,15 @@ def export_entry(cls, entry, to_multifile=True):
# source directory is entry.journal.config['journal']
# 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}{end}\n{body}".format(
start="---",
date=date_str,
title=entry.title,
starred=entry.starred,
tags=", ".join([tag[1:] for tag in entry.tags]),
dayone=dayone_attributes,
body=newbody,
space="",
end="...",
)

@classmethod
Expand Down