Skip to content

Commit fb1357b

Browse files
committedOct 4, 2020
Update for remark 13
* Update to a micromark parser, defer work to <https://github.com/micromark/micromark-extension-frontmatter>, <https://github.com/syntax-tree/mdast-util-frontmatter> * Frontmatter must now start on the first line Previously, delaying with blank lines first worked. That behavior does not match how GitHub parses YAML, and is thus removed.
1 parent 9df76a0 commit fb1357b

File tree

39 files changed

+181
-587
lines changed

39 files changed

+181
-587
lines changed
 

‎index.js

+11-54
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,19 @@
11
'use strict'
22

3-
var matters = require('./lib/matters')
4-
var parse = require('./lib/parse')
5-
var compile = require('./lib/compile')
3+
var syntax = require('micromark-extension-frontmatter')
4+
var fromMarkdown = require('mdast-util-frontmatter/from-markdown')
5+
var toMarkdown = require('mdast-util-frontmatter/to-markdown')
66

77
module.exports = frontmatter
88

99
function frontmatter(options) {
10-
var parser = this.Parser
11-
var compiler = this.Compiler
12-
var config = matters(options || ['yaml'])
13-
14-
if (isRemarkParser(parser)) {
15-
attachParser(parser, config)
16-
}
17-
18-
if (isRemarkCompiler(compiler)) {
19-
attachCompiler(compiler, config)
20-
}
21-
}
22-
23-
function attachParser(parser, matters) {
24-
var proto = parser.prototype
25-
var tokenizers = wrap(parse, matters)
26-
var names = []
27-
var key
28-
29-
for (key in tokenizers) {
30-
names.push(key)
10+
var data = this.data()
11+
add('micromarkExtensions', syntax(options))
12+
add('fromMarkdownExtensions', fromMarkdown(options))
13+
add('toMarkdownExtensions', toMarkdown(options))
14+
function add(field, value) {
15+
/* istanbul ignore if - other extensions. */
16+
if (data[field]) data[field].push(value)
17+
else data[field] = [value]
3118
}
32-
33-
proto.blockMethods = names.concat(proto.blockMethods)
34-
proto.blockTokenizers = Object.assign({}, tokenizers, proto.blockTokenizers)
35-
}
36-
37-
function attachCompiler(compiler, matters) {
38-
var proto = compiler.prototype
39-
proto.visitors = Object.assign({}, wrap(compile, matters), proto.visitors)
40-
}
41-
42-
function wrap(func, matters) {
43-
var result = {}
44-
var length = matters.length
45-
var index = -1
46-
var tuple
47-
48-
while (++index < length) {
49-
tuple = func(matters[index])
50-
result[tuple[0]] = tuple[1]
51-
}
52-
53-
return result
54-
}
55-
56-
function isRemarkParser(parser) {
57-
return Boolean(parser && parser.prototype && parser.prototype.blockTokenizers)
58-
}
59-
60-
function isRemarkCompiler(compiler) {
61-
return Boolean(compiler && compiler.prototype && compiler.prototype.visitors)
6219
}

‎lib/compile.js

-19
This file was deleted.

‎lib/fence.js

-18
This file was deleted.

‎lib/matters.js

-55
This file was deleted.

‎lib/parse.js

-46
This file was deleted.

‎package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
],
2929
"files": [
3030
"index.js",
31-
"lib",
3231
"types/index.d.ts"
3332
],
3433
"types": "types/index.d.ts",
3534
"dependencies": {
36-
"fault": "^1.0.1"
35+
"mdast-util-frontmatter": "^0.2.0",
36+
"micromark-extension-frontmatter": "^0.2.0"
3737
},
3838
"devDependencies": {
3939
"browserify": "^16.0.0",
@@ -42,7 +42,7 @@
4242
"not": "^0.1.0",
4343
"nyc": "^15.0.0",
4444
"prettier": "^2.0.0",
45-
"remark": "^12.0.0",
45+
"remark": "^13.0.0-alpha.1",
4646
"remark-cli": "^8.0.0",
4747
"remark-preset-wooorm": "^7.0.0",
4848
"tape": "^5.0.0",

‎readme.md

+32-140
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010

1111
[**remark**][remark] plugin to support frontmatter (YAML, TOML, and more).
1212

13+
## Important!
14+
15+
This plugin is affected by the new parser in remark
16+
([`micromark`](https://github.com/micromark/micromark),
17+
see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)).
18+
Use version 2 while you’re still on remark 12.
19+
Use version 3 for remark 13+.
20+
1321
## Install
1422

1523
[npm][]:
@@ -45,9 +53,9 @@ unified()
4553
.use(stringify)
4654
.use(frontmatter, ['yaml', 'toml'])
4755
.use(logger)
48-
.process(vfile.readSync('example.md'), function(err, file) {
49-
console.log(String(file))
56+
.process(vfile.readSync('example.md'), function (err, file) {
5057
console.error(report(err || file))
58+
console.log(String(file))
5159
})
5260

5361
function logger() {
@@ -58,16 +66,17 @@ function logger() {
5866
Now, running `node example` yields:
5967

6068
```js
61-
{ type: 'root',
62-
children:
63-
[ { type: 'toml',
64-
value: 'title = "New Website"',
65-
position: [Object] },
66-
{ type: 'heading',
67-
depth: 1,
68-
children: [Array],
69-
position: [Object] } ],
70-
position: [Object] }
69+
{
70+
type: 'root',
71+
children: [
72+
{type: 'toml', value: 'title = "New Website"', position: [Object]},
73+
{type: 'heading', depth: 1, children: [Array], position: [Object]}
74+
],
75+
position: {
76+
start: {line: 1, column: 1, offset: 0},
77+
end: {line: 6, column: 1, offset: 48}
78+
}
79+
}
7180
```
7281

7382
```markdown
@@ -83,117 +92,12 @@ title = "New Website"
8392

8493
### `remark().use(frontmatter[, options])`
8594

86-
Support frontmatter (YAML, TOML, and more).
87-
Adds [tokenizers][] if the [processor][] is configured with
88-
[`remark-parse`][parse], and [visitors][] if configured with
89-
[`remark-stringify`][stringify].
90-
91-
If you are parsing from a different syntax, or compiling to a different syntax
92-
(such as, [`remark-man`][man]) your custom nodes may not be supported.
95+
Configures remark so that it can parse and serialize frontmatter (YAML, TOML,
96+
and more).
9397

9498
##### `options`
9599

96-
One [`preset`][preset] or [`Matter`][matter], or an array of them, defining all
97-
the supported frontmatters (default: `'yaml'`).
98-
99-
##### `preset`
100-
101-
Either `'yaml'` or `'toml'`:
102-
103-
* `'yaml'`[`matter`][matter] defined as `{type: 'yaml', marker: '-'}`
104-
* `'toml'`[`matter`][matter] defined as `{type: 'toml', marker: '+'}`
105-
106-
##### `Matter`
107-
108-
An object with a `type` and either a `marker` or a `fence`:
109-
110-
* `type` (`string`)
111-
— Node type to parse to in [mdast][] and compile from
112-
* `marker` (`string` or `{open: string, close: string}`)
113-
— Character used to construct fences.
114-
By providing an object with `open` and `close`.
115-
different characters can be used for opening and closing fences.
116-
For example the character `'-'` will result in `'---'` being used as the
117-
fence
118-
* `fence` (`string` or `{open: string, close: string}`)
119-
— String used as the complete fence.
120-
By providing an object with `open` and `close` different values can be used
121-
for opening and closing fences.
122-
This can be used too if fences contain different characters or lengths other
123-
than 3
124-
* `anywhere` (`boolean`, default: `false`)
125-
– if `true`, matter can be found anywhere in the document.
126-
If `false` (default), only matter at the start of the document is recognized
127-
128-
###### Example
129-
130-
For `{type: 'yaml', marker: '-'}`:
131-
132-
```yaml
133-
---
134-
key: value
135-
---
136-
```
137-
138-
Yields:
139-
140-
```json
141-
{
142-
"type": "yaml",
143-
"value": "key: value"
144-
}
145-
```
146-
147-
For `{type: 'custom', marker: {open: '<', close: '>'}}`:
148-
149-
```text
150-
<<<
151-
data
152-
>>>
153-
```
154-
155-
Yields:
156-
157-
```json
158-
{
159-
"type": "custom",
160-
"value": "data"
161-
}
162-
```
163-
164-
For `{type: 'custom', fence: '+=+=+=+'}`:
165-
166-
```text
167-
+=+=+=+
168-
data
169-
+=+=+=+
170-
```
171-
172-
Yields:
173-
174-
```json
175-
{
176-
"type": "custom",
177-
"value": "data"
178-
}
179-
```
180-
181-
For `{type: 'json', fence: {open: '{', close: '}'}}`:
182-
183-
```json
184-
{
185-
"key": "value"
186-
}
187-
```
188-
189-
Yields:
190-
191-
```json
192-
{
193-
"type": "json",
194-
"value": "\"key\": \"value\""
195-
}
196-
```
100+
See [`micromark-extension-frontmatter`][options] for a description of `options`.
197101

198102
## Security
199103

@@ -203,10 +107,14 @@ Use of `remark-frontmatter` does not involve [**rehype**][rehype]
203107

204108
## Related
205109

110+
* [`remark-gfm`](https://github.com/remarkjs/remark-gfm)
111+
— GitHub Flavored Markdown
112+
* [`remark-footnotes`](https://github.com/remarkjs/remark-footnotes)
113+
— Footnotes
114+
* [`remark-math`](https://github.com/remarkjs/remark-math)
115+
— Math
206116
* [`remark-github`](https://github.com/remarkjs/remark-github)
207117
— Auto-link references like in GitHub issues, PRs, and comments
208-
* [`remark-math`](https://github.com/rokt33r/remark-math)
209-
— Math support
210118
* [`remark-yaml-config`](https://github.com/remarkjs/remark-yaml-config)
211119
— Configure remark from YAML configuration
212120

@@ -268,26 +176,10 @@ abide by its terms.
268176

269177
[remark]: https://github.com/remarkjs/remark
270178

271-
[parse]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-parse
272-
273-
[tokenizers]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-parse#parserblocktokenizers
274-
275-
[stringify]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify
276-
277-
[visitors]: https://github.com/remarkjs/remark/tree/HEAD/packages/remark-stringify#compilervisitors
278-
279-
[processor]: https://github.com/unifiedjs/unified#processor
280-
281-
[mdast]: https://github.com/syntax-tree/mdast
282-
283-
[man]: https://github.com/remarkjs/remark-man
284-
285-
[preset]: #preset
286-
287-
[matter]: #matter
288-
289179
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
290180

291181
[rehype]: https://github.com/rehypejs/rehype
292182

293183
[hast]: https://github.com/syntax-tree/hast
184+
185+
[options]: https://github.com/micromark/micromark-extension-frontmatter#options

‎test/fixtures/config-options-as-matter/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 2,
1515
"column": 4,
1616
"offset": 7
17-
},
18-
"indent": [1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 4,
3635
"column": 8,
3736
"offset": 16
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/config-options-as-string/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 2,
1515
"column": 4,
1616
"offset": 7
17-
},
18-
"indent": [1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 4,
3635
"column": 8,
3736
"offset": 16
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
---
2-
title: post
3-
---
1+
***
2+
3+
## title: post
44

55
# Later (whitespace before yaml)

‎test/fixtures/core-yaml-delayed/tree.json

+38-8
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,52 @@
22
"type": "root",
33
"children": [
44
{
5-
"type": "yaml",
6-
"value": "title: post",
5+
"type": "thematicBreak",
76
"position": {
87
"start": {
98
"line": 3,
109
"column": 1,
1110
"offset": 2
1211
},
12+
"end": {
13+
"line": 3,
14+
"column": 4,
15+
"offset": 5
16+
}
17+
}
18+
},
19+
{
20+
"type": "heading",
21+
"depth": 2,
22+
"children": [
23+
{
24+
"type": "text",
25+
"value": "title: post",
26+
"position": {
27+
"start": {
28+
"line": 4,
29+
"column": 1,
30+
"offset": 6
31+
},
32+
"end": {
33+
"line": 4,
34+
"column": 12,
35+
"offset": 17
36+
}
37+
}
38+
}
39+
],
40+
"position": {
41+
"start": {
42+
"line": 4,
43+
"column": 1,
44+
"offset": 6
45+
},
1346
"end": {
1447
"line": 5,
1548
"column": 4,
1649
"offset": 21
17-
},
18-
"indent": [1, 1]
50+
}
1951
}
2052
},
2153
{
@@ -35,8 +67,7 @@
3567
"line": 7,
3668
"column": 33,
3769
"offset": 55
38-
},
39-
"indent": []
70+
}
4071
}
4172
}
4273
],
@@ -50,8 +81,7 @@
5081
"line": 7,
5182
"column": 33,
5283
"offset": 55
53-
},
54-
"indent": []
84+
}
5585
}
5686
}
5787
],

‎test/fixtures/core-yaml-not-at-top/output.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Two horizontal rules
22

3-
* * *
3+
***
44

55
## A horizontal rule
66

‎test/fixtures/core-yaml-not-at-top/tree.json

+7-14
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"line": 1,
1919
"column": 23,
2020
"offset": 22
21-
},
22-
"indent": []
21+
}
2322
}
2423
}
2524
],
@@ -33,8 +32,7 @@
3332
"line": 1,
3433
"column": 23,
3534
"offset": 22
36-
},
37-
"indent": []
35+
}
3836
}
3937
},
4038
{
@@ -49,8 +47,7 @@
4947
"line": 3,
5048
"column": 4,
5149
"offset": 27
52-
},
53-
"indent": []
50+
}
5451
}
5552
},
5653
{
@@ -70,8 +67,7 @@
7067
"line": 4,
7168
"column": 18,
7269
"offset": 45
73-
},
74-
"indent": []
70+
}
7571
}
7672
}
7773
],
@@ -85,8 +81,7 @@
8581
"line": 5,
8682
"column": 4,
8783
"offset": 49
88-
},
89-
"indent": [1]
84+
}
9085
}
9186
},
9287
{
@@ -105,8 +100,7 @@
105100
"line": 7,
106101
"column": 13,
107102
"offset": 63
108-
},
109-
"indent": []
103+
}
110104
}
111105
}
112106
],
@@ -120,8 +114,7 @@
120114
"line": 7,
121115
"column": 13,
122116
"offset": 63
123-
},
124-
"indent": []
117+
}
125118
}
126119
}
127120
],

‎test/fixtures/custom-deep/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 4,
1616
"offset": 49
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 57
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 57
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
* * *
1+
***
22

33
{
4-
"hello": "World!"
4+
"hello": "World!"
55
}
66

7-
* * *
7+
***
88

99
# Default

‎test/fixtures/custom-default/tree.json

+7-13
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
"line": 1,
1414
"column": 4,
1515
"offset": 3
16-
},
17-
"indent": []
16+
}
1817
}
1918
},
2019
{
2120
"type": "paragraph",
2221
"children": [
2322
{
2423
"type": "text",
25-
"value": "{\n \"hello\": \"World!\"\n}",
24+
"value": "{\n\"hello\": \"World!\"\n}",
2625
"position": {
2726
"start": {
2827
"line": 2,
@@ -33,8 +32,7 @@
3332
"line": 4,
3433
"column": 2,
3534
"offset": 27
36-
},
37-
"indent": [1, 1]
35+
}
3836
}
3937
}
4038
],
@@ -48,8 +46,7 @@
4846
"line": 4,
4947
"column": 2,
5048
"offset": 27
51-
},
52-
"indent": [1, 1]
49+
}
5350
}
5451
},
5552
{
@@ -64,8 +61,7 @@
6461
"line": 5,
6562
"column": 4,
6663
"offset": 31
67-
},
68-
"indent": []
64+
}
6965
}
7066
},
7167
{
@@ -85,8 +81,7 @@
8581
"line": 7,
8682
"column": 10,
8783
"offset": 42
88-
},
89-
"indent": []
84+
}
9085
}
9186
}
9287
],
@@ -100,8 +95,7 @@
10095
"line": 7,
10196
"column": 10,
10297
"offset": 42
103-
},
104-
"indent": []
98+
}
10599
}
106100
}
107101
],

‎test/fixtures/custom-empty/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 2,
1515
"column": 4,
1616
"offset": 7
17-
},
18-
"indent": [1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 4,
3635
"column": 8,
3736
"offset": 16
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-fence-long/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 11,
1616
"offset": 63
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 71
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 71
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-fence-openclose/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 8,
1616
"offset": 56
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 64
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 64
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-fence-short/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 3,
1616
"offset": 47
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 55
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 55
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-fence/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 4,
1616
"offset": 49
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 57
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 57
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-marker-openclose/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 6,
1515
"column": 4,
1616
"offset": 49
17-
},
18-
"indent": [1, 1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 8,
3635
"column": 7,
3736
"offset": 57
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 8,
5149
"column": 7,
5250
"offset": 57
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/custom-yaml-anywhere/tree.json

+5-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"line": 1,
1919
"column": 22,
2020
"offset": 21
21-
},
22-
"indent": []
21+
}
2322
}
2423
}
2524
],
@@ -33,8 +32,7 @@
3332
"line": 1,
3433
"column": 22,
3534
"offset": 21
36-
},
37-
"indent": []
35+
}
3836
}
3937
},
4038
{
@@ -50,8 +48,7 @@
5048
"line": 5,
5149
"column": 4,
5250
"offset": 42
53-
},
54-
"indent": [1, 1]
51+
}
5552
}
5653
},
5754
{
@@ -70,8 +67,7 @@
7067
"line": 7,
7168
"column": 10,
7269
"offset": 53
73-
},
74-
"indent": []
70+
}
7571
}
7672
}
7773
],
@@ -85,8 +81,7 @@
8581
"line": 7,
8682
"column": 10,
8783
"offset": 53
88-
},
89-
"indent": []
84+
}
9085
}
9186
}
9287
],

‎test/fixtures/toml-advanced/tree.json

+3-39
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,7 @@
1414
"line": 33,
1515
"column": 4,
1616
"offset": 524
17-
},
18-
"indent": [
19-
1,
20-
1,
21-
1,
22-
1,
23-
1,
24-
1,
25-
1,
26-
1,
27-
1,
28-
1,
29-
1,
30-
1,
31-
1,
32-
1,
33-
1,
34-
1,
35-
1,
36-
1,
37-
1,
38-
1,
39-
1,
40-
1,
41-
1,
42-
1,
43-
1,
44-
1,
45-
1,
46-
1,
47-
1,
48-
1,
49-
1,
50-
1
51-
]
17+
}
5218
}
5319
},
5420
{
@@ -68,8 +34,7 @@
6834
"line": 35,
6935
"column": 15,
7036
"offset": 540
71-
},
72-
"indent": []
37+
}
7338
}
7439
}
7540
],
@@ -83,8 +48,7 @@
8348
"line": 35,
8449
"column": 15,
8550
"offset": 540
86-
},
87-
"indent": []
51+
}
8852
}
8953
}
9054
],

‎test/fixtures/toml-deep/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 4,
1515
"column": 4,
1616
"offset": 43
17-
},
18-
"indent": [1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 6,
3635
"column": 7,
3736
"offset": 51
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 6,
5149
"column": 7,
5250
"offset": 51
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/toml-default/tree.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"line": 3,
1818
"column": 4,
1919
"offset": 22
20-
},
21-
"indent": [1, 1]
20+
}
2221
}
2322
}
2423
],
@@ -32,8 +31,7 @@
3231
"line": 3,
3332
"column": 4,
3433
"offset": 22
35-
},
36-
"indent": [1, 1]
34+
}
3735
}
3836
},
3937
{
@@ -53,8 +51,7 @@
5351
"line": 5,
5452
"column": 10,
5553
"offset": 33
56-
},
57-
"indent": []
54+
}
5855
}
5956
}
6057
],
@@ -68,8 +65,7 @@
6865
"line": 5,
6966
"column": 10,
7067
"offset": 33
71-
},
72-
"indent": []
68+
}
7369
}
7470
}
7571
],

‎test/fixtures/toml-empty/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 2,
1515
"column": 4,
1616
"offset": 7
17-
},
18-
"indent": [1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 4,
3635
"column": 8,
3736
"offset": 16
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/toml-unconfigured/tree.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
"line": 2,
1818
"column": 4,
1919
"offset": 7
20-
},
21-
"indent": [1]
20+
}
2221
}
2322
}
2423
],
@@ -32,8 +31,7 @@
3231
"line": 2,
3332
"column": 4,
3433
"offset": 7
35-
},
36-
"indent": [1]
34+
}
3735
}
3836
},
3937
{
@@ -53,8 +51,7 @@
5351
"line": 4,
5452
"column": 8,
5553
"offset": 16
56-
},
57-
"indent": []
54+
}
5855
}
5956
}
6057
],
@@ -68,8 +65,7 @@
6865
"line": 4,
6966
"column": 8,
7067
"offset": 16
71-
},
72-
"indent": []
68+
}
7369
}
7470
}
7571
],

‎test/fixtures/yaml-advanced/tree.json

+3-36
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,7 @@
1414
"line": 30,
1515
"column": 4,
1616
"offset": 614
17-
},
18-
"indent": [
19-
1,
20-
1,
21-
1,
22-
1,
23-
1,
24-
1,
25-
1,
26-
1,
27-
1,
28-
1,
29-
1,
30-
1,
31-
1,
32-
1,
33-
1,
34-
1,
35-
1,
36-
1,
37-
1,
38-
1,
39-
1,
40-
1,
41-
1,
42-
1,
43-
1,
44-
1,
45-
1,
46-
1,
47-
1
48-
]
17+
}
4918
}
5019
},
5120
{
@@ -65,8 +34,7 @@
6534
"line": 32,
6635
"column": 15,
6736
"offset": 630
68-
},
69-
"indent": []
37+
}
7038
}
7139
}
7240
],
@@ -80,8 +48,7 @@
8048
"line": 32,
8149
"column": 15,
8250
"offset": 630
83-
},
84-
"indent": []
51+
}
8552
}
8653
}
8754
],
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* * *
1+
***
22

33
# Incorrect ---

‎test/fixtures/yaml-closed-incorrectly/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"line": 1,
1414
"column": 4,
1515
"offset": 3
16-
},
17-
"indent": []
16+
}
1817
}
1918
},
2019
{
@@ -34,8 +33,7 @@
3433
"line": 3,
3534
"column": 16,
3635
"offset": 20
37-
},
38-
"indent": []
36+
}
3937
}
4038
}
4139
],
@@ -49,8 +47,7 @@
4947
"line": 3,
5048
"column": 16,
5149
"offset": 20
52-
},
53-
"indent": []
50+
}
5451
}
5552
}
5653
],

‎test/fixtures/yaml-deep/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 5,
1515
"column": 4,
1616
"offset": 44
17-
},
18-
"indent": [1, 1, 1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 7,
3635
"column": 7,
3736
"offset": 52
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 7,
5149
"column": 7,
5250
"offset": 52
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/yaml-default/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 3,
1515
"column": 4,
1616
"offset": 22
17-
},
18-
"indent": [1, 1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 5,
3635
"column": 10,
3736
"offset": 33
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 5,
5149
"column": 10,
5250
"offset": 33
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/yaml-empty/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"line": 2,
1515
"column": 4,
1616
"offset": 7
17-
},
18-
"indent": [1]
17+
}
1918
}
2019
},
2120
{
@@ -35,8 +34,7 @@
3534
"line": 4,
3635
"column": 8,
3736
"offset": 16
38-
},
39-
"indent": []
37+
}
4038
}
4139
}
4240
],
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],

‎test/fixtures/yaml-unclosed/output.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
* * *
1+
***
22

33
# Unclosed

‎test/fixtures/yaml-unclosed/tree.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"line": 1,
1414
"column": 4,
1515
"offset": 3
16-
},
17-
"indent": []
16+
}
1817
}
1918
},
2019
{
@@ -34,8 +33,7 @@
3433
"line": 3,
3534
"column": 11,
3635
"offset": 15
37-
},
38-
"indent": []
36+
}
3937
}
4038
}
4139
],
@@ -49,8 +47,7 @@
4947
"line": 3,
5048
"column": 11,
5149
"offset": 15
52-
},
53-
"indent": []
50+
}
5451
}
5552
}
5653
],
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
* * *
1+
***
22

3-
* * *
3+
***
44

55
# Empty

‎test/fixtures/yaml-unconfigured/tree.json

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"line": 1,
1414
"column": 4,
1515
"offset": 3
16-
},
17-
"indent": []
16+
}
1817
}
1918
},
2019
{
@@ -29,8 +28,7 @@
2928
"line": 2,
3029
"column": 4,
3130
"offset": 7
32-
},
33-
"indent": []
31+
}
3432
}
3533
},
3634
{
@@ -50,8 +48,7 @@
5048
"line": 4,
5149
"column": 8,
5250
"offset": 16
53-
},
54-
"indent": []
51+
}
5552
}
5653
}
5754
],
@@ -65,8 +62,7 @@
6562
"line": 4,
6663
"column": 8,
6764
"offset": 16
68-
},
69-
"indent": []
65+
}
7066
}
7167
}
7268
],

‎types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare namespace remarkFrontmatter {
3737
fence?: string | Fence
3838

3939
/**
40-
* if `true`, matter can be found anywhere in the document.
40+
* If `true`, matter can be found anywhere in the document.
4141
* If `false` (default), only matter at the start of the document is recognized
4242
*
4343
* @default false

0 commit comments

Comments
 (0)
Please sign in to comment.