Skip to content

Commit

Permalink
fix: resolves closeTag with newline
Browse files Browse the repository at this point in the history
  • Loading branch information
bent10 committed Oct 1, 2023
1 parent dbddda1 commit 83ebe3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/hook-frontmatter/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const lexer = moo.states({
openTag: { match: /^---\n/, lineBreaks: true, push: 'matter' }
},
matter: {
closeTag: { match: /^---\n?/, lineBreaks: true, push: 'content' },
closeTag: { match: /^---\n/, lineBreaks: true, push: 'content' },
data: /.+/,
lineBreak: { match: /\n+/, lineBreaks: true }
},
Expand Down
12 changes: 12 additions & 0 deletions packages/hook-frontmatter/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,15 @@ it('should pass the filename option when available in data', () => {
.parse(md)
).toThrow(/test\.md/)
})

it('should ends `closeTag` with newline', () => {
expect(() =>
new Marked()
.use(
markedSequentialHooks({
markdownHooks: [markedHookFrontmatter()]
})
)
.parse('---\nfoo: bar\n------\n')
).toThrow(/can not read a block mapping entry/)
})

0 comments on commit 83ebe3d

Please sign in to comment.