【发布时间】:2016-08-25 05:35:24
【问题描述】:
在 ruby 中有什么方法可以编辑 Markdown 文件顶部的 YAML Frontmatter,就像 Jekyll 和 Middleman 中使用的那样?
类似:
def update_yaml
#magic that changes A: 1 to A: 2 in Frontmatter block
end
然后我的降价文件将从
---
A: 1
---
# Title
Words. More words. This is the words part of the file.
到
---
A: 2
---
# Title
Words. More words. This is the words part of the file.
似乎唯一的选择是解析整个文件,然后重写整个文件,只更改所需的部分,但我希望有更好的东西。
【问题讨论】:
标签: ruby yaml jekyll middleman yaml-front-matter