feat(markdown): support TOML (#3290)
parent
4b070c3a93
commit
b6f126eb29
|
@ -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)
|
||||
|
|
|
@ -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" &&
|
||||
|
|
|
@ -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']
|
||||
+++
|
||||
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, { parser: "markdown" });
|
|
@ -0,0 +1,5 @@
|
|||
+++
|
||||
date: '2017-10-10T22:49:47.369Z'
|
||||
title: 'My Post Title'
|
||||
categories: ['foo', 'bar']
|
||||
+++
|
Loading…
Reference in New Issue