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

Conversation

Seopril
Copy link
Contributor

@Seopril Seopril commented Jan 6, 2021

This is an intended fix for issue #1065. The yaml export now functions as shown in the "Expected Behavior" described in that bug report.

Example Output:

---
title: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
date: 2021-01-05 11:26
starred: False
tags: 
...

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have tested this code locally.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.
  • All tests pass.

Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

Thank you for taking this one on!

I think there was a little confusion with the description in the ticket, so I left some clarifying comments inline.

@@ -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

@@ -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.

@Seopril
Copy link
Contributor Author

Seopril commented Jan 11, 2021

I've added in the body section for the YAML export and updated the feature tests accordingly.

Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

Thank you!

@wren wren merged commit 5c0a2d4 into jrnl-org:develop Jan 16, 2021
@wren wren added the bug Something isn't working label Jan 16, 2021
@wren wren changed the title Fix YAML export formatting(#1065) Fix YAML format bug Jan 16, 2021
@wren wren changed the title Fix YAML format bug Add delimiters in YAML format Jan 16, 2021
MinchinWeb pushed a commit to MinchinWeb/jrnl that referenced this pull request Sep 11, 2021
* Fix YAML export syntax
* Fix YAML body block indentation

(cherry picked from commit 5c0a2d4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants