gray-matter
gray-matter copied to clipboard
use opts.excerpt_separator
Trying to stringify with same options as parsed failed. Does this looks like a fix?
Tests can pass with const sep = opts.excerpt_separator || opts.delimiters[0];
But it looks like it should be inside default.js
if (opts.excerpt) {
opts.excerpt_separator = opts.excerpt_separator || opts.delimiters[0];
}
Then another one fails,
.stringify
1) should stringify an excerpt
So default.js: opts.sep = opts.excerpt_separator || opts.delimiters[0];
and stringify.js: const sep = opts.sep;
seems even more wrong.
lib/excerpt.js: sep || opts.delimiters[0]
so maybe stringify.js should not use default separator too, i am really not sure
or test for stringify maybe should use {excerpt: true}
?
I'm on vacation for the next few days but can you provide an example of what you did and what you expected to happen vs what did happen? Your fix suggestion seems to be a breaking change at a glance.
I'll respond properly at the end of the week.
i am trying to stringify with custom excerpt_separator
var source = '---\nDATA: 1\n---\nEXCERPT\n<!-- -->\nBODY\n'
var options = { excerpt: true, excerpt_separator: '<!-- -->' }
var parsed = matter(source, options)
var file = {
excerpt: parsed.excerpt,
content: 'Something new',
data: parsed.data,
}
var string = matter.stringify(file, {}, options)
i am confused why stringify uses opts.delimiters[1]
as separator but lib/excerpt.js using opts.delimiters[0]