-
Notifications
You must be signed in to change notification settings - Fork 222
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
Support YAML front matter in Markdown files #207
Comments
@JPinkney Don't know how far you are along with this and I haven't looked over this projects source but one way this can be achieved with a basic LS.
Given that frontmatter can only be applied at the start of documents you won't need to recalculate offset positioning or even put much effort into the parsing side of things. |
I haven't been able to implement this yet (and probably won't have the time for quite a while). That sounds like a good plan though 👍 |
I might take a stab at it. I require YAML Intellisense in an LS I'm developing for Jekyll and can probably port it over to this project once stable. |
I think this should be implemented on the markdown extension to request forward front-matter language requests to vscode-yaml. |
Hello, any update on this particular topic ? I've resorted on work-arounds for now, as I can't live without YAML Schemas and Markdown editing: Thanks a lot ! |
To all: It's not correct to assume all fenced blocks (
While unfamiliar with the use cases driving your statement above, your frustration may be misplaced by waiting on a feature not yet supported. Conversely, have you considered Dendron? With a dynamic taxonomy, driven by folders and file naming, each "class" of markdown file can have a YAML (JSON) schema enforced by configuration of this VSCode extension. Although there's Youtube content, I recommend you start your review here. |
Thank you @julrichkieffer , I didn't know about the specs thing, as I it never occurred to me to have anything other than YAML before fences in an MD file. [EDIT] Dendron looks pretty cool, with some solid concepts, but it doesn't support JSON Schema :p It uses its own vocabulary, so no porting on regular frontend + further AJV validation is possible |
For those who are familiar with https://github.com/JulianCataldo/remark-lint-frontmatter-schema It's far less powerful than |
@julrichkieffer would it be possible to support explicit schemas in markdown fences? For example it may be incorrect to outright target any fenced block, however if the block matches; <!-- no content above -->
---
# yaml-language-server: $schema=pathHere
someYaml: here
---
<!-- rest of md file --> Then a) it's definitely frontmatter, and b) the author of the file wants to validate this yaml with the given schema. I'm not at all familiar with this projects inner magic, but it's probably possible to do the following when a markdown file is loaded;
Wouldn't this would be compatible with markdown's specification? |
Any news on this issue and especially on WillsterJohnson's suggestion quoted above? We're using YAML front-matter extensively for a complex content management system, where Markdown files can have different (large) sets of metadata, and this would be a huge improvement to our workflow. |
+1 |
Summary
vscode-yaml
should apply schema validation to YAML front matter in markdown files.Description
YAML is often prepended to markdown files to provide structured metadata. This "front matter" pattern is commonly implemented by static site generators, including Hugo, Gatsby, Jekyll and Nikola. YAML Front Matter precedes all Markdown content. The file may or may not start with
---
.VScode recognizes YAML front matter in markdown files and formats it appropriately as long as there is not an initial
---
(implemented here).vscode-yaml
does not recognize YAML front matter, even when extension references are configured correctly.vscode-yaml
does support multiple YAML files delimited by---
, see #43. This works with or without an initial---
.Reproduction
(1) Configure
settings.json
to use the same schema for YAML and Markdown files:(2) Create a YAML file as
test.yml
:(3) Confirm that the
vscode-yaml
applies the schema totest.yml
.(4a) Create a Markdown file
test.md
with the same YAML contents in as front matter:(4b) Add an initial
---
and save astest_initial_delimiter.md
:(5) Confirm that
vscode-yaml
does not validate the schema of the YAML in either markdown file.The text was updated successfully, but these errors were encountered: