foambubble / foam Public
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
Parse frontmatter and use frontmatter.title as heading (fixes #174) #191
Conversation
| visit(tree, node => { | ||
| if (node.type === 'yaml') { | ||
| frontmatter = parseYAML(node.value as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using the yaml package for parsing the frontmatter. Is that okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only downside is that it's 27Kb minzipped, and theoretically foam-core could be used in a browser environment, so it adds a bit of chonk to the bundle.
I don't really see a good alternative right now, since I don't want to implement a partial yaml subset parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'd say it's probably ok for now, we might want to revisit for optimizations once as part of the browser release
@anku255 I was testing this and managed to break this when the frontmatter wasn't fully valid yaml:
foo: bar
baz
I'm not sure if related to invalid yaml, but after testing with an invalid header, the Janitor replaced the content of the file with a old, cached version of the document.
I didn't have time to test it in detail!
| visit(tree, node => { | ||
| if (node.type === 'yaml') { | ||
| frontmatter = parseYAML(node.value as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I'd say it's probably ok for now, we might want to revisit for optimizations once as part of the browser release
@jevakallio I don't think the invalid I think this problem is related to inconsistent The Janitor command works fine on a freshly loaded VS Code window but if you make changes to some files (be it dirty or nondirty), Janitor may produce unexpected results. To reproduce this you can try the following steps: -
---
title: Note Title
foo
----
---
title: Note Title
---
Do you have any idea why this might be happening? My initial understanding is that the The |
looking good to me, just left a couple of comments
Thanks @anku255 for the explanation. Seems like the root cause for this issue is already on master and needs to be addressed separately
Thank you for your approval. But don't merge it just yet. I will be doing the changes suggested by @riccardoferretti soon. |
hey @anku255 we ended up merging this, but feel free to make the changes on another branch, or also directly on |
Summary
fixes #174
This PR does the following things -
#or=heading.window.withProgress) while the Janitor runs.Test Plan
I have tested with the following types of markdown notes.
Input:
Output: Doesn't generate the heading and uses
frontmatter.titleasnote.title.Input:
inbox.mdOutput:
Input:
inbox.mdOutput: