是否有 YAML 前端标准/验证器? [英] Is there a YAML front matter standard / validator?

查看:14
本文介绍了是否有 YAML 前端标准/验证器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 YAML front matter 作为通用数据管理器的元数据持有者,例如:

I would like to use YAML front matter as a metadata holder for a general purpose data manager, e.g.:

---
layout: "user"
title: "Mario Brega"
slug: "mario-brega"
skills:
  - fire
  - water
  - leaf
---

# Here I will be using Markdown

yes I will, _I swear_

它被许多静态生成器用作:

It is used by many static generators as:

问题:是否有一个标准?一些我可以轻松验证的工具,例如同意所有字符串值都应该用引号括起来,布尔值不应该,等等.

Question: is there a standard for that? Some tools that I can easily validate against, that for instance agree that all string values should be wrapped in quotes, that booleans should not, and so on.

将 YAML 前端问题映射到 JSON 模式 将是一大优势.

Mapping the YAML front matter to a JSON schema would be a big plus.

推荐答案

最接近标准的是 Jekyll's前题说明.其他一切似乎都遵循这一点.如果 Jekyll 没有发明 Yaml Front Matter,那么他们是最早使用它的著名项目之一.

The closest thing to a standard would be Jekyll's Front Matter description. Everything else seems to follow that. If Jekyll didn't invent Yaml Front Matter, they were one of the first notable projects to feature it.

YAML Lint linter 已经能够验证我扔给它的每个文件的 YAML 组件.根据 YAML 规范,三个连字符 --- 分隔文件;一个 YAML 文件可以包含许多 YAML 文档.连字符后的 Markdown 内容会被 linter 简单地删除.

The YAML Lint linter has been able to verify the YAML components of every file I've thrown at it. According to the YAML spec, three-hyphens --- delimits documents; a single YAML file can contain many YAML documents. The Markdown content after the hyphen is simply dropped by the linter.

YAML 非常宽松和宽容(大部分情况下).引用所有字符串不会受到伤害,但您可能不需要打扰.

YAML is very loose and forgiving (mostly). Quoting all your strings won't hurt, but you probably don't need to bother.

对某种基准 Markdown 标准的渴望导致了 CommonMark 项目.

The desire for some sort of baseline Markdown standard is what led to the CommonMark project.

因此,虽然没有正式的规范,但已经出现了一种最佳实践模式.坚持这种模式会产生一些令人惊讶的可移植性和多功能数据文件.

So, while there is no formal specification, a pattern of best practices has emerged. Sticking to that pattern results in some surprisingly portable and versatile data files.

这篇关于是否有 YAML 前端标准/验证器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆