redhat-developer / redhat-developer/vscode-yaml

Support YAML front matter in Markdown files

Open
#207 16 comments 47 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement upstream
Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

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:

{
    "editor.minimap.enabled": false,
    "yaml.format.enable": true,
    "yaml.format.proseWrap": "always",
    "yaml.schemas": {
        "./my_schema.json": "*.yml",
        "./my_schema.json": "*.md"
    },
    "git.autofetch": true
}

(2) Create a YAML file as test.yml:

title: "A Blog Post"
date: 2019-07-07
draft: true

(3) Confirm that the vscode-yaml applies the schema to test.yml.

(4a) Create a Markdown file test.md with the same YAML contents in as front matter:

title: "A Blog Post"
date: 2019-07-07
draft: true
---
This is content of my blog post, which will be processed as Markdown.

(4b) Add an initial --- and save as test_initial_delimiter.md:

---
title: "A Blog Post"
date: 2019-07-07
draft: true
---
This is content of my blog post, which will be processed as Markdown.

(5) Confirm that vscode-yaml does not validate the schema of the YAML in either markdown file.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with the schema mapping in settings.json and compare test.yml with test.md and test_initial_delimiter.md. Trace the Markdown front-matter handling and verify that the configured schema validates both delimiter variants without treating the Markdown body as YAML.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, typescript, yaml
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.