diff --git a/index.js b/index.js index 9011f4e..45609b9 100644 --- a/index.js +++ b/index.js @@ -1,62 +1,19 @@ 'use strict' -var matters = require('./lib/matters') -var parse = require('./lib/parse') -var compile = require('./lib/compile') +var syntax = require('micromark-extension-frontmatter') +var fromMarkdown = require('mdast-util-frontmatter/from-markdown') +var toMarkdown = require('mdast-util-frontmatter/to-markdown') module.exports = frontmatter function frontmatter(options) { - var parser = this.Parser - var compiler = this.Compiler - var config = matters(options || ['yaml']) - - if (isRemarkParser(parser)) { - attachParser(parser, config) - } - - if (isRemarkCompiler(compiler)) { - attachCompiler(compiler, config) - } -} - -function attachParser(parser, matters) { - var proto = parser.prototype - var tokenizers = wrap(parse, matters) - var names = [] - var key - - for (key in tokenizers) { - names.push(key) + var data = this.data() + add('micromarkExtensions', syntax(options)) + add('fromMarkdownExtensions', fromMarkdown(options)) + add('toMarkdownExtensions', toMarkdown(options)) + function add(field, value) { + /* istanbul ignore if - other extensions. */ + if (data[field]) data[field].push(value) + else data[field] = [value] } - - proto.blockMethods = names.concat(proto.blockMethods) - proto.blockTokenizers = Object.assign({}, tokenizers, proto.blockTokenizers) -} - -function attachCompiler(compiler, matters) { - var proto = compiler.prototype - proto.visitors = Object.assign({}, wrap(compile, matters), proto.visitors) -} - -function wrap(func, matters) { - var result = {} - var length = matters.length - var index = -1 - var tuple - - while (++index < length) { - tuple = func(matters[index]) - result[tuple[0]] = tuple[1] - } - - return result -} - -function isRemarkParser(parser) { - return Boolean(parser && parser.prototype && parser.prototype.blockTokenizers) -} - -function isRemarkCompiler(compiler) { - return Boolean(compiler && compiler.prototype && compiler.prototype.visitors) } diff --git a/lib/compile.js b/lib/compile.js deleted file mode 100644 index 109b6ea..0000000 --- a/lib/compile.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict' - -var fence = require('./fence') - -module.exports = create - -function create(matter) { - var type = matter.type - var open = fence(matter, 'open') - var close = fence(matter, 'close') - - frontmatter.displayName = type + 'FrontMatter' - - return [type, frontmatter] - - function frontmatter(node) { - return open + (node.value ? '\n' + node.value : '') + '\n' + close - } -} diff --git a/lib/fence.js b/lib/fence.js deleted file mode 100644 index 9e80c48..0000000 --- a/lib/fence.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict' - -module.exports = fence - -function fence(matter, prop) { - var marker - - if (matter.marker) { - marker = pick(matter.marker, prop) - return marker + marker + marker - } - - return pick(matter.fence, prop) -} - -function pick(schema, prop) { - return typeof schema === 'string' ? schema : schema[prop] -} diff --git a/lib/matters.js b/lib/matters.js deleted file mode 100644 index 543998d..0000000 --- a/lib/matters.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict' - -var fault = require('fault') - -module.exports = matters - -var own = {}.hasOwnProperty - -var markers = { - yaml: '-', - toml: '+' -} - -function matters(options) { - var results = [] - var index = -1 - var length - - // One preset or matter. - if (typeof options === 'string' || !('length' in options)) { - options = [options] - } - - length = options.length - - while (++index < length) { - results[index] = matter(options[index]) - } - - return results -} - -function matter(option) { - var result = option - - if (typeof result === 'string') { - if (!own.call(markers, result)) { - throw fault('Missing matter definition for `%s`', result) - } - - result = {type: result, marker: markers[result]} - } else if (typeof result !== 'object') { - throw fault('Expected matter to be an object, not `%j`', result) - } - - if (!own.call(result, 'type')) { - throw fault('Missing `type` in matter `%j`', result) - } - - if (!own.call(result, 'fence') && !own.call(result, 'marker')) { - throw fault('Missing `marker` or `fence` in matter `%j`', result) - } - - return result -} diff --git a/lib/parse.js b/lib/parse.js deleted file mode 100644 index 2852983..0000000 --- a/lib/parse.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' - -var fence = require('./fence') - -module.exports = create - -function create(matter) { - var name = matter.type + 'FrontMatter' - var open = fence(matter, 'open') - var close = fence(matter, 'close') - var newline = '\n' - var anywhere = matter.anywhere - - frontmatter.displayName = name - frontmatter.onlyAtStart = typeof anywhere === 'boolean' ? !anywhere : true - - return [name, frontmatter] - - function frontmatter(eat, value, silent) { - var index = open.length - var offset - - if (value.slice(0, index) !== open || value.charAt(index) !== newline) { - return - } - - offset = value.indexOf(close, index) - - while (offset !== -1 && value.charAt(offset - 1) !== newline) { - index = offset + close.length - offset = value.indexOf(close, index) - } - - if (offset !== -1) { - /* istanbul ignore if - never used (yet) */ - if (silent) { - return true - } - - return eat(value.slice(0, offset + close.length))({ - type: matter.type, - value: value.slice(open.length + 1, offset - 1) - }) - } - } -} diff --git a/package.json b/package.json index 5483d7d..010fd70 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,12 @@ ], "files": [ "index.js", - "lib", "types/index.d.ts" ], "types": "types/index.d.ts", "dependencies": { - "fault": "^1.0.1" + "mdast-util-frontmatter": "^0.2.0", + "micromark-extension-frontmatter": "^0.2.0" }, "devDependencies": { "browserify": "^16.0.0", @@ -42,7 +42,7 @@ "not": "^0.1.0", "nyc": "^15.0.0", "prettier": "^2.0.0", - "remark": "^12.0.0", + "remark": "^13.0.0-alpha.1", "remark-cli": "^8.0.0", "remark-preset-wooorm": "^7.0.0", "tape": "^5.0.0", diff --git a/readme.md b/readme.md index c66c4e7..bf161c4 100644 --- a/readme.md +++ b/readme.md @@ -10,6 +10,14 @@ [**remark**][remark] plugin to support frontmatter (YAML, TOML, and more). +## Important! + +This plugin is affected by the new parser in remark +([`micromark`](https://github.com/micromark/micromark), +see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)). +Use version 2 while you’re still on remark 12. +Use version 3 for remark 13+. + ## Install [npm][]: @@ -45,9 +53,9 @@ unified() .use(stringify) .use(frontmatter, ['yaml', 'toml']) .use(logger) - .process(vfile.readSync('example.md'), function(err, file) { - console.log(String(file)) + .process(vfile.readSync('example.md'), function (err, file) { console.error(report(err || file)) + console.log(String(file)) }) function logger() { @@ -58,16 +66,17 @@ function logger() { Now, running `node example` yields: ```js -{ type: 'root', - children: - [ { type: 'toml', - value: 'title = "New Website"', - position: [Object] }, - { type: 'heading', - depth: 1, - children: [Array], - position: [Object] } ], - position: [Object] } +{ + type: 'root', + children: [ + {type: 'toml', value: 'title = "New Website"', position: [Object]}, + {type: 'heading', depth: 1, children: [Array], position: [Object]} + ], + position: { + start: {line: 1, column: 1, offset: 0}, + end: {line: 6, column: 1, offset: 48} + } +} ``` ```markdown @@ -83,117 +92,12 @@ title = "New Website" ### `remark().use(frontmatter[, options])` -Support frontmatter (YAML, TOML, and more). -Adds [tokenizers][] if the [processor][] is configured with -[`remark-parse`][parse], and [visitors][] if configured with -[`remark-stringify`][stringify]. - -If you are parsing from a different syntax, or compiling to a different syntax -(such as, [`remark-man`][man]) your custom nodes may not be supported. +Configures remark so that it can parse and serialize frontmatter (YAML, TOML, +and more). ##### `options` -One [`preset`][preset] or [`Matter`][matter], or an array of them, defining all -the supported frontmatters (default: `'yaml'`). - -##### `preset` - -Either `'yaml'` or `'toml'`: - -* `'yaml'` — [`matter`][matter] defined as `{type: 'yaml', marker: '-'}` -* `'toml'` — [`matter`][matter] defined as `{type: 'toml', marker: '+'}` - -##### `Matter` - -An object with a `type` and either a `marker` or a `fence`: - -* `type` (`string`) - — Node type to parse to in [mdast][] and compile from -* `marker` (`string` or `{open: string, close: string}`) - — Character used to construct fences. - By providing an object with `open` and `close`. - different characters can be used for opening and closing fences. - For example the character `'-'` will result in `'---'` being used as the - fence -* `fence` (`string` or `{open: string, close: string}`) - — String used as the complete fence. - By providing an object with `open` and `close` different values can be used - for opening and closing fences. - This can be used too if fences contain different characters or lengths other - than 3 -* `anywhere` (`boolean`, default: `false`) - – if `true`, matter can be found anywhere in the document. - If `false` (default), only matter at the start of the document is recognized - -###### Example - -For `{type: 'yaml', marker: '-'}`: - -```yaml ---- -key: value ---- -``` - -Yields: - -```json -{ - "type": "yaml", - "value": "key: value" -} -``` - -For `{type: 'custom', marker: {open: '<', close: '>'}}`: - -```text -<<< -data ->>> -``` - -Yields: - -```json -{ - "type": "custom", - "value": "data" -} -``` - -For `{type: 'custom', fence: '+=+=+=+'}`: - -```text -+=+=+=+ -data -+=+=+=+ -``` - -Yields: - -```json -{ - "type": "custom", - "value": "data" -} -``` - -For `{type: 'json', fence: {open: '{', close: '}'}}`: - -```json -{ - "key": "value" -} -``` - -Yields: - -```json -{ - "type": "json", - "value": "\"key\": \"value\"" -} -``` +See [`micromark-extension-frontmatter`][options] for a description of `options`. ## Security @@ -203,10 +107,14 @@ Use of `remark-frontmatter` does not involve [**rehype**][rehype] ## Related +* [`remark-gfm`](https://github.com/remarkjs/remark-gfm) + — GitHub Flavored Markdown +* [`remark-footnotes`](https://github.com/remarkjs/remark-footnotes) + — Footnotes +* [`remark-math`](https://github.com/remarkjs/remark-math) + — Math * [`remark-github`](https://github.com/remarkjs/remark-github) — Auto-link references like in GitHub issues, PRs, and comments -* [`remark-math`](https://github.com/rokt33r/remark-math) - — Math support * [`remark-yaml-config`](https://github.com/remarkjs/remark-yaml-config) — Configure remark from YAML configuration @@ -268,26 +176,10 @@ abide by its terms. [remark]: https://github.com/remarkjs/remark -[parse]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-parse - -[tokenizers]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-parse#parserblocktokenizers - -[stringify]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify - -[visitors]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#compilervisitors - -[processor]: https://github.com/unifiedjs/unified#processor - -[mdast]: https://github.com/syntax-tree/mdast - -[man]: https://github.com/remarkjs/remark-man - -[preset]: #preset - -[matter]: #matter - [xss]: https://en.wikipedia.org/wiki/Cross-site_scripting [rehype]: https://github.com/rehypejs/rehype [hast]: https://github.com/syntax-tree/hast + +[options]: https://github.com/micromark/micromark-extension-frontmatter#options diff --git a/test/fixtures/config-options-as-matter/tree.json b/test/fixtures/config-options-as-matter/tree.json index f762643..7d3df04 100644 --- a/test/fixtures/config-options-as-matter/tree.json +++ b/test/fixtures/config-options-as-matter/tree.json @@ -14,8 +14,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -35,8 +34,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/config-options-as-string/tree.json b/test/fixtures/config-options-as-string/tree.json index 3ae296b..593c0dc 100644 --- a/test/fixtures/config-options-as-string/tree.json +++ b/test/fixtures/config-options-as-string/tree.json @@ -14,8 +14,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -35,8 +34,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/core-yaml-delayed/output.md b/test/fixtures/core-yaml-delayed/output.md index 715bee6..b79854a 100644 --- a/test/fixtures/core-yaml-delayed/output.md +++ b/test/fixtures/core-yaml-delayed/output.md @@ -1,5 +1,5 @@ ---- -title: post ---- +*** + +## title: post # Later (whitespace before yaml) diff --git a/test/fixtures/core-yaml-delayed/tree.json b/test/fixtures/core-yaml-delayed/tree.json index 7c67f87..9490f0d 100644 --- a/test/fixtures/core-yaml-delayed/tree.json +++ b/test/fixtures/core-yaml-delayed/tree.json @@ -2,20 +2,52 @@ "type": "root", "children": [ { - "type": "yaml", - "value": "title: post", + "type": "thematicBreak", "position": { "start": { "line": 3, "column": 1, "offset": 2 }, + "end": { + "line": 3, + "column": 4, + "offset": 5 + } + } + }, + { + "type": "heading", + "depth": 2, + "children": [ + { + "type": "text", + "value": "title: post", + "position": { + "start": { + "line": 4, + "column": 1, + "offset": 6 + }, + "end": { + "line": 4, + "column": 12, + "offset": 17 + } + } + } + ], + "position": { + "start": { + "line": 4, + "column": 1, + "offset": 6 + }, "end": { "line": 5, "column": 4, "offset": 21 - }, - "indent": [1, 1] + } } }, { @@ -35,8 +67,7 @@ "line": 7, "column": 33, "offset": 55 - }, - "indent": [] + } } } ], @@ -50,8 +81,7 @@ "line": 7, "column": 33, "offset": 55 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/core-yaml-not-at-top/output.md b/test/fixtures/core-yaml-not-at-top/output.md index 3769912..887fc8e 100644 --- a/test/fixtures/core-yaml-not-at-top/output.md +++ b/test/fixtures/core-yaml-not-at-top/output.md @@ -1,6 +1,6 @@ # Two horizontal rules -* * * +*** ## A horizontal rule diff --git a/test/fixtures/core-yaml-not-at-top/tree.json b/test/fixtures/core-yaml-not-at-top/tree.json index 266f016..1987b6f 100644 --- a/test/fixtures/core-yaml-not-at-top/tree.json +++ b/test/fixtures/core-yaml-not-at-top/tree.json @@ -18,8 +18,7 @@ "line": 1, "column": 23, "offset": 22 - }, - "indent": [] + } } } ], @@ -33,8 +32,7 @@ "line": 1, "column": 23, "offset": 22 - }, - "indent": [] + } } }, { @@ -49,8 +47,7 @@ "line": 3, "column": 4, "offset": 27 - }, - "indent": [] + } } }, { @@ -70,8 +67,7 @@ "line": 4, "column": 18, "offset": 45 - }, - "indent": [] + } } } ], @@ -85,8 +81,7 @@ "line": 5, "column": 4, "offset": 49 - }, - "indent": [1] + } } }, { @@ -105,8 +100,7 @@ "line": 7, "column": 13, "offset": 63 - }, - "indent": [] + } } } ], @@ -120,8 +114,7 @@ "line": 7, "column": 13, "offset": 63 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-deep/tree.json b/test/fixtures/custom-deep/tree.json index dfc7895..5567fde 100644 --- a/test/fixtures/custom-deep/tree.json +++ b/test/fixtures/custom-deep/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 4, "offset": 49 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-default/output.md b/test/fixtures/custom-default/output.md index 2a341da..afee159 100644 --- a/test/fixtures/custom-default/output.md +++ b/test/fixtures/custom-default/output.md @@ -1,9 +1,9 @@ -* * * +*** { - "hello": "World!" +"hello": "World!" } -* * * +*** # Default diff --git a/test/fixtures/custom-default/tree.json b/test/fixtures/custom-default/tree.json index 33fd012..075478e 100644 --- a/test/fixtures/custom-default/tree.json +++ b/test/fixtures/custom-default/tree.json @@ -13,8 +13,7 @@ "line": 1, "column": 4, "offset": 3 - }, - "indent": [] + } } }, { @@ -22,7 +21,7 @@ "children": [ { "type": "text", - "value": "{\n \"hello\": \"World!\"\n}", + "value": "{\n\"hello\": \"World!\"\n}", "position": { "start": { "line": 2, @@ -33,8 +32,7 @@ "line": 4, "column": 2, "offset": 27 - }, - "indent": [1, 1] + } } } ], @@ -48,8 +46,7 @@ "line": 4, "column": 2, "offset": 27 - }, - "indent": [1, 1] + } } }, { @@ -64,8 +61,7 @@ "line": 5, "column": 4, "offset": 31 - }, - "indent": [] + } } }, { @@ -85,8 +81,7 @@ "line": 7, "column": 10, "offset": 42 - }, - "indent": [] + } } } ], @@ -100,8 +95,7 @@ "line": 7, "column": 10, "offset": 42 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-empty/tree.json b/test/fixtures/custom-empty/tree.json index f762643..7d3df04 100644 --- a/test/fixtures/custom-empty/tree.json +++ b/test/fixtures/custom-empty/tree.json @@ -14,8 +14,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -35,8 +34,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-fence-long/tree.json b/test/fixtures/custom-fence-long/tree.json index 723ecfb..2718f76 100644 --- a/test/fixtures/custom-fence-long/tree.json +++ b/test/fixtures/custom-fence-long/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 11, "offset": 63 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 71 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 71 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-fence-openclose/tree.json b/test/fixtures/custom-fence-openclose/tree.json index ced98ef..9a665d1 100644 --- a/test/fixtures/custom-fence-openclose/tree.json +++ b/test/fixtures/custom-fence-openclose/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 8, "offset": 56 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 64 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 64 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-fence-short/tree.json b/test/fixtures/custom-fence-short/tree.json index e83f786..9f9ce1d 100644 --- a/test/fixtures/custom-fence-short/tree.json +++ b/test/fixtures/custom-fence-short/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 3, "offset": 47 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 55 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 55 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-fence/tree.json b/test/fixtures/custom-fence/tree.json index dfc7895..5567fde 100644 --- a/test/fixtures/custom-fence/tree.json +++ b/test/fixtures/custom-fence/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 4, "offset": 49 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-marker-openclose/tree.json b/test/fixtures/custom-marker-openclose/tree.json index dfc7895..5567fde 100644 --- a/test/fixtures/custom-marker-openclose/tree.json +++ b/test/fixtures/custom-marker-openclose/tree.json @@ -14,8 +14,7 @@ "line": 6, "column": 4, "offset": 49 - }, - "indent": [1, 1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 8, "column": 7, "offset": 57 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/custom-yaml-anywhere/tree.json b/test/fixtures/custom-yaml-anywhere/tree.json index 78be2fe..6051858 100644 --- a/test/fixtures/custom-yaml-anywhere/tree.json +++ b/test/fixtures/custom-yaml-anywhere/tree.json @@ -18,8 +18,7 @@ "line": 1, "column": 22, "offset": 21 - }, - "indent": [] + } } } ], @@ -33,8 +32,7 @@ "line": 1, "column": 22, "offset": 21 - }, - "indent": [] + } } }, { @@ -50,8 +48,7 @@ "line": 5, "column": 4, "offset": 42 - }, - "indent": [1, 1] + } } }, { @@ -70,8 +67,7 @@ "line": 7, "column": 10, "offset": 53 - }, - "indent": [] + } } } ], @@ -85,8 +81,7 @@ "line": 7, "column": 10, "offset": 53 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/toml-advanced/tree.json b/test/fixtures/toml-advanced/tree.json index 4a172cc..1091746 100644 --- a/test/fixtures/toml-advanced/tree.json +++ b/test/fixtures/toml-advanced/tree.json @@ -14,41 +14,7 @@ "line": 33, "column": 4, "offset": 524 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -68,8 +34,7 @@ "line": 35, "column": 15, "offset": 540 - }, - "indent": [] + } } } ], @@ -83,8 +48,7 @@ "line": 35, "column": 15, "offset": 540 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/toml-deep/tree.json b/test/fixtures/toml-deep/tree.json index 50d0f78..26bf304 100644 --- a/test/fixtures/toml-deep/tree.json +++ b/test/fixtures/toml-deep/tree.json @@ -14,8 +14,7 @@ "line": 4, "column": 4, "offset": 43 - }, - "indent": [1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 6, "column": 7, "offset": 51 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 6, "column": 7, "offset": 51 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/toml-default/tree.json b/test/fixtures/toml-default/tree.json index 1beb531..59cb060 100644 --- a/test/fixtures/toml-default/tree.json +++ b/test/fixtures/toml-default/tree.json @@ -17,8 +17,7 @@ "line": 3, "column": 4, "offset": 22 - }, - "indent": [1, 1] + } } } ], @@ -32,8 +31,7 @@ "line": 3, "column": 4, "offset": 22 - }, - "indent": [1, 1] + } } }, { @@ -53,8 +51,7 @@ "line": 5, "column": 10, "offset": 33 - }, - "indent": [] + } } } ], @@ -68,8 +65,7 @@ "line": 5, "column": 10, "offset": 33 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/toml-empty/tree.json b/test/fixtures/toml-empty/tree.json index 4a4a021..a75b8cf 100644 --- a/test/fixtures/toml-empty/tree.json +++ b/test/fixtures/toml-empty/tree.json @@ -14,8 +14,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -35,8 +34,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/toml-unconfigured/tree.json b/test/fixtures/toml-unconfigured/tree.json index a70fc7b..dbf3d18 100644 --- a/test/fixtures/toml-unconfigured/tree.json +++ b/test/fixtures/toml-unconfigured/tree.json @@ -17,8 +17,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } } ], @@ -32,8 +31,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -53,8 +51,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -68,8 +65,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-advanced/tree.json b/test/fixtures/yaml-advanced/tree.json index b616fd4..0634528 100644 --- a/test/fixtures/yaml-advanced/tree.json +++ b/test/fixtures/yaml-advanced/tree.json @@ -14,38 +14,7 @@ "line": 30, "column": 4, "offset": 614 - }, - "indent": [ - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1, - 1 - ] + } } }, { @@ -65,8 +34,7 @@ "line": 32, "column": 15, "offset": 630 - }, - "indent": [] + } } } ], @@ -80,8 +48,7 @@ "line": 32, "column": 15, "offset": 630 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-closed-incorrectly/output.md b/test/fixtures/yaml-closed-incorrectly/output.md index 9b731de..a609e2b 100644 --- a/test/fixtures/yaml-closed-incorrectly/output.md +++ b/test/fixtures/yaml-closed-incorrectly/output.md @@ -1,3 +1,3 @@ -* * * +*** # Incorrect --- diff --git a/test/fixtures/yaml-closed-incorrectly/tree.json b/test/fixtures/yaml-closed-incorrectly/tree.json index 8d9366d..66d36b2 100644 --- a/test/fixtures/yaml-closed-incorrectly/tree.json +++ b/test/fixtures/yaml-closed-incorrectly/tree.json @@ -13,8 +13,7 @@ "line": 1, "column": 4, "offset": 3 - }, - "indent": [] + } } }, { @@ -34,8 +33,7 @@ "line": 3, "column": 16, "offset": 20 - }, - "indent": [] + } } } ], @@ -49,8 +47,7 @@ "line": 3, "column": 16, "offset": 20 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-deep/tree.json b/test/fixtures/yaml-deep/tree.json index 822e523..25f1681 100644 --- a/test/fixtures/yaml-deep/tree.json +++ b/test/fixtures/yaml-deep/tree.json @@ -14,8 +14,7 @@ "line": 5, "column": 4, "offset": 44 - }, - "indent": [1, 1, 1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 7, "column": 7, "offset": 52 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 7, "column": 7, "offset": 52 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-default/tree.json b/test/fixtures/yaml-default/tree.json index 58aa2ed..7cb7b95 100644 --- a/test/fixtures/yaml-default/tree.json +++ b/test/fixtures/yaml-default/tree.json @@ -14,8 +14,7 @@ "line": 3, "column": 4, "offset": 22 - }, - "indent": [1, 1] + } } }, { @@ -35,8 +34,7 @@ "line": 5, "column": 10, "offset": 33 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 5, "column": 10, "offset": 33 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-empty/tree.json b/test/fixtures/yaml-empty/tree.json index 3ae296b..593c0dc 100644 --- a/test/fixtures/yaml-empty/tree.json +++ b/test/fixtures/yaml-empty/tree.json @@ -14,8 +14,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [1] + } } }, { @@ -35,8 +34,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-unclosed/output.md b/test/fixtures/yaml-unclosed/output.md index 6ccf7af..5a8ae6c 100644 --- a/test/fixtures/yaml-unclosed/output.md +++ b/test/fixtures/yaml-unclosed/output.md @@ -1,3 +1,3 @@ -* * * +*** # Unclosed diff --git a/test/fixtures/yaml-unclosed/tree.json b/test/fixtures/yaml-unclosed/tree.json index df42148..5f7beb7 100644 --- a/test/fixtures/yaml-unclosed/tree.json +++ b/test/fixtures/yaml-unclosed/tree.json @@ -13,8 +13,7 @@ "line": 1, "column": 4, "offset": 3 - }, - "indent": [] + } } }, { @@ -34,8 +33,7 @@ "line": 3, "column": 11, "offset": 15 - }, - "indent": [] + } } } ], @@ -49,8 +47,7 @@ "line": 3, "column": 11, "offset": 15 - }, - "indent": [] + } } } ], diff --git a/test/fixtures/yaml-unconfigured/output.md b/test/fixtures/yaml-unconfigured/output.md index 514e45f..740ca4a 100644 --- a/test/fixtures/yaml-unconfigured/output.md +++ b/test/fixtures/yaml-unconfigured/output.md @@ -1,5 +1,5 @@ -* * * +*** -* * * +*** # Empty diff --git a/test/fixtures/yaml-unconfigured/tree.json b/test/fixtures/yaml-unconfigured/tree.json index 47de3d7..dee7e5c 100644 --- a/test/fixtures/yaml-unconfigured/tree.json +++ b/test/fixtures/yaml-unconfigured/tree.json @@ -13,8 +13,7 @@ "line": 1, "column": 4, "offset": 3 - }, - "indent": [] + } } }, { @@ -29,8 +28,7 @@ "line": 2, "column": 4, "offset": 7 - }, - "indent": [] + } } }, { @@ -50,8 +48,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], @@ -65,8 +62,7 @@ "line": 4, "column": 8, "offset": 16 - }, - "indent": [] + } } } ], diff --git a/types/index.d.ts b/types/index.d.ts index dbd479d..a256daf 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -37,7 +37,7 @@ declare namespace remarkFrontmatter { fence?: string | Fence /** - * if `true`, matter can be found anywhere in the document. + * If `true`, matter can be found anywhere in the document. * If `false` (default), only matter at the start of the document is recognized * * @default false