Skip to content

use opts.excerpt_separator#89

Open
gcoda wants to merge 2 commits into
jonschlinkert:masterfrom
gcoda:patch-1
Open

use opts.excerpt_separator#89
gcoda wants to merge 2 commits into
jonschlinkert:masterfrom
gcoda:patch-1

Conversation

@gcoda

@gcoda gcoda commented Jan 12, 2019

Copy link
Copy Markdown

Trying to stringify with same options as parsed failed.
Does this looks like a fix?

@gcoda

gcoda commented Jan 12, 2019

Copy link
Copy Markdown
Author

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} ?

@robertmassaioli

Copy link
Copy Markdown
Collaborator

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.

@gcoda

gcoda commented Jan 13, 2019

Copy link
Copy Markdown
Author

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]

@robertmassaioli robertmassaioli added the bug A problem that causes an error in the library at compilation or runtime. label Jan 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A problem that causes an error in the library at compilation or runtime.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants