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

YAML Front Matter support in Markdown #169

Closed
jackmaney opened this issue Dec 30, 2014 · 12 comments
Closed

YAML Front Matter support in Markdown #169

jackmaney opened this issue Dec 30, 2014 · 12 comments
Assignees
Labels

Comments

@jackmaney
Copy link

So, I have the following markdown with YAML front matter (for use with Jekyll):


---
title: This is a title!

---

stuff

more stuff

When I beautify this, the front matter disappears:

stuff

more stuff

Adding GitHub Markdown to the disabled languages prevents the front matter from being eaten. However, it would be nice to have the beautification work.

Thank you for your time.

@Glavin001 Glavin001 self-assigned this Dec 31, 2014
@Glavin001 Glavin001 added the bug label Dec 31, 2014
@Glavin001
Copy link
Owner

There are currently no beautifiers (that I have found) that support YAML Front Matter.
Possible solutions: detect that the file contents begins with YAML Front Matter, and if so, remove it from contents, beautify contents, and then prepend the YAML front matter to the post-beautified contents. This should work well.
No ETA on this functionality right now. Thanks for making this issue!

@Glavin001 Glavin001 added this to the v1.0.0 milestone Jan 1, 2015
Glavin001 added a commit that referenced this issue Jan 2, 2015
Test is disabled so that Travis CI still marks as successful.
@Glavin001
Copy link
Owner

  • Add package option for enabling YAML Front Matter
    • I doubt this will add too much of a performance hit to the Markdown beautifier, so let's make this setting default to True so future users will not be shocked when it does not work out-of-the-box.
  • If YAML Front Matter is enabled, on Markdown beautification,
    • first process with https://github.com/dworthen/js-yaml-front-matter and then take the __content and pass that to the Markdown beautifier
    • take the result of Markdown beautifier of __content and concat the YAML Front Matter to the top and return that result

@Glavin001
Copy link
Owner

I started working on this however I realize now that the cli-beautify base class is not very customizable and does not meet the requirements I have for this feature. I think completing #164 should come first as it will force me to redesign how CLI-beautifiers are handled and now I can start brainstorming an improved API for supporting existing and adding more CLI-beautifiers in the future.

@Glavin001 Glavin001 modified the milestones: My Christmas List, v1.0.0 Jan 2, 2015
@Glavin001
Copy link
Owner

I will definitely update this after #164, however it is at least working now and you can use it while I develop out #164.

Before

---

title: This is a title!

name: Derek Worthen
age: young
contact:
email: email@domain.com
address: some location
pets:
- cat
- dog
- bat
match: !!js/regexp /pattern/gim
run: !!js/function function() { }



---

- item
-  item
-   item

1. one
2.  two
2.   three

After

---
title: "This is a title!"
name: Derek Worthen
age: young
contact: null
email: "email@domain.com"
address: some location
pets:
  - cat
  - dog
  - bat
match: !<tag:yaml.org,2002:js/regexp> /pattern/gmi
run: !<tag:yaml.org,2002:js/function> "function () {\n   \n}"
---

-   item
-   item
-   item

1.  one
2.  two
3.  three

Hope that looks good to you!

@Glavin001 Glavin001 added feature and removed bug labels Jan 2, 2015
@Glavin001 Glavin001 changed the title YAML Front Matter is Eaten by Beautifier YAML Front Matter support in Markdown Jan 2, 2015
@Glavin001
Copy link
Owner

The build is failing for release v0.20.0.
See https://travis-ci.org/Glavin001/atom-beautify/builds/45655633
I think this is because of dworthen/js-yaml-front-matter#2
Until that issue has been resolved, I may have to disable / remove this feature. @jackmaney could you please update and check for yourself if it is working? Thanks.

@Glavin001 Glavin001 reopened this Jan 2, 2015
@Glavin001
Copy link
Owner

Fortunately it looks like the YAML Front Matter library wraps js-yaml, so I can remove js-yaml and use yaml-front-matter instead.

@Glavin001
Copy link
Owner

Published to v0.20.1! Enjoy 😃

@jackmaney
Copy link
Author

Awesome. Thank you so much! :D

@jackmaney
Copy link
Author

Just updated to v0.20.1, and I'm seeing this:

Before

---

title: This is a title!

name: Derek Worthen
age: young
contact:
email: email@domain.com
address: some location
pets:
- cat
- dog
- bat
match: !!js/regexp /pattern/gim
run: !!js/function function() { }



---

- item
-  item
-   item

1. one
2.  two
2.   three

After

------------------------------------------------------------------------

title: This is a title!

name: Derek Worthen age: young contact: email: email@domain.com address:
some location pets: - cat - dog - bat match: !!js/regexp /pattern/gim
run: !!js/function function() { }

------------------------------------------------------------------------

-   item
-   item
-   item

1.  one
2.  two
3.  three

@jackmaney
Copy link
Author

Hmmm, strangely enough, the same exact before and after in the opening comment is still occurring:

Before

---
title: This is a title!
---

stuff

more stuff

After

stuff

more stuff

@Glavin001
Copy link
Owner

That's very strange. Travis CI already OKed the unit test for the more complex case. I'll have to take another look once I'm home. 


Sent from Mailbox

On Fri, Jan 2, 2015 at 5:17 AM, Jack Maney notifications@github.com
wrote:

Hmmm, strangely enough, the same exact before and after in the opening comment is still occurring:

Before

---
title: This is a title!
---
stuff
more stuff

After

stuff
more stuff

Reply to this email directly or view it on GitHub:
#169 (comment)

@Glavin001
Copy link
Owner

I'm home now. I am still receiving correct results for both of those tests. @jackmaney, could you run command Window: Reload and / or uninstall and reinstall Atom Beautify?

Glavin001 added a commit that referenced this issue Jan 3, 2015
My local pandoc was not the same as Travis CI's
and so my beautifications were always different and tests would not
match. I used `brew install pandoc` and am now in sync at v1.13.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants