feat(markdown): support TOML (#3290)

master
Ika 2017-11-19 14:38:25 +08:00 committed by Lucas Azzola
parent 4b070c3a93
commit b6f126eb29
5 changed files with 25 additions and 1 deletions

View File

@ -22,7 +22,7 @@ const util = require("./util");
function parse(text /*, parsers, opts*/) {
const processor = unified()
.use(remarkParse, { footnotes: true, commonmark: true })
.use(remarkFrontmatter, ["yaml"])
.use(remarkFrontmatter, ["yaml", "toml"])
.use(restoreUnescapedCharacter(text))
.use(mergeContinuousTexts)
.use(transformInlineCode)

View File

@ -203,6 +203,8 @@ function genericPrint(path, options, print) {
}
case "yaml":
return concat(["---", hardline, node.value, hardline, "---"]);
case "toml":
return concat(["+++", hardline, node.value, hardline, "+++"]);
case "html": {
const parentNode = path.getParentNode();
return parentNode.type === "root" &&

View File

@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`simple.md 1`] = `
+++
date: '2017-10-10T22:49:47.369Z'
title: 'My Post Title'
categories: ['foo', 'bar']
+++
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+++
date: '2017-10-10T22:49:47.369Z'
title: 'My Post Title'
categories: ['foo', 'bar']
+++
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "markdown" });

View File

@ -0,0 +1,5 @@
+++
date: '2017-10-10T22:49:47.369Z'
title: 'My Post Title'
categories: ['foo', 'bar']
+++