Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use opts.excerpt_separator #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

gcoda
Copy link

@gcoda gcoda commented Jan 12, 2019

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

@gcoda
Copy link
Author

gcoda commented Jan 12, 2019

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
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
Copy link
Author

gcoda commented Jan 13, 2019

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.

None yet

2 participants