diff --git a/src/parser-markdown.js b/src/parser-markdown.js index 18255884..a20fdc45 100644 --- a/src/parser-markdown.js +++ b/src/parser-markdown.js @@ -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) diff --git a/src/printer-markdown.js b/src/printer-markdown.js index 6281bf5e..5dd0331c 100644 --- a/src/printer-markdown.js +++ b/src/printer-markdown.js @@ -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" && diff --git a/tests/markdown_toml/__snapshots__/jsfmt.spec.js.snap b/tests/markdown_toml/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..868297fc --- /dev/null +++ b/tests/markdown_toml/__snapshots__/jsfmt.spec.js.snap @@ -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'] ++++ + +`; diff --git a/tests/markdown_toml/jsfmt.spec.js b/tests/markdown_toml/jsfmt.spec.js new file mode 100644 index 00000000..552a6a92 --- /dev/null +++ b/tests/markdown_toml/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "markdown" }); diff --git a/tests/markdown_toml/simple.md b/tests/markdown_toml/simple.md new file mode 100644 index 00000000..7a0aa6e7 --- /dev/null +++ b/tests/markdown_toml/simple.md @@ -0,0 +1,5 @@ ++++ +date: '2017-10-10T22:49:47.369Z' +title: 'My Post Title' +categories: ['foo', 'bar'] ++++