use opts.excerpt_separator #89

Open
gcoda wants to merge 2 commits from gcoda/patch-1 into master
gcoda commented 2019-01-12 09:56:33 +00:00 (Migrated from github.com)

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

Trying to stringify with same options as parsed failed. Does this looks like a fix?
gcoda commented 2019-01-12 10:57:47 +00:00 (Migrated from github.com)

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

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](https://github.com/jonschlinkert/gray-matter/blob/5a5817df1cc9b4656574318695aa9ce8beb3d2fe/lib/excerpt.js#L23): `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 commented 2019-01-12 22:57:59 +00:00 (Migrated from github.com)

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'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 commented 2019-01-13 06:13:19 +00:00 (Migrated from github.com)

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]

i am trying to stringify with custom excerpt_separator ```javascript 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]`
This pull request has changes conflicting with the target branch.
  • lib/stringify.js
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin "gcoda/patch-1:gcoda/patch-1"
git switch "gcoda/patch-1"
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rtlabs-llm-agents/gms-gray-matter!89
No description provided.