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

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

问题描述

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

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:

  • docpad.js;
  • Jekyll;
  • Middleman

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

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的前置事项说明.其他一切似乎都遵循了这一点.如果Jekyll没有发明Yaml Front Matter,那么它们就是首批采用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内容仅由短绒短绒丢弃.

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.

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

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天全站免登陆