feat: updating to use yaml #147

Open
sakulstra wants to merge 2 commits from sakulstra/feat/yaml into master
sakulstra commented 2022-06-23 08:05:53 +00:00 (Migrated from github.com)

use yaml instead of js-yaml as requested in #145

@jonschlinkert are you sure yaml is smaller than js-yaml (for some reason bundlephobia is broken for yaml and vscode showing bigger package size, might be wrong due to shaking though)

yaml seems to behave slightly different as you can see in the two failing tests.

use yaml instead of js-yaml as requested in #145 @jonschlinkert are you sure `yaml` is smaller than `js-yaml` (for some reason bundlephobia is broken for yaml and vscode showing bigger package size, might be wrong due to shaking though) `yaml` seems to behave slightly different as you can see in the two failing tests.
sakulstra commented 2022-07-10 19:56:34 +00:00 (Migrated from github.com)

@jonschlinkert with #148 applied tests are passing.

@jonschlinkert with #148 applied tests are passing.
jonschlinkert commented 2022-07-11 15:59:02 +00:00 (Migrated from github.com)

are you sure yaml is smaller than js-yaml (for some reason bundlephobia is broken for yaml and vscode showing bigger package size

I'm not at all sure about that lol. Thank you for doing this and for bringing it to my attention. I was initially under the impression that yaml would be smaller, since js-yaml was massively bloated the last time I checked. They included all of their tests, test fixtures, browser code, etc. in the published package. Now that you have seen both, what is your recommendation?

edit: and also, thank you for taking the time to do this, and apologies for making you jump through hoops. I promise we'll get this merged and published as soon as we settle on which library to use.

> are you sure `yaml` is smaller than `js-yaml` (for some reason bundlephobia is broken for yaml and vscode showing bigger package size I'm not at all sure about that lol. Thank you for doing this and for bringing it to my attention. I was initially under the impression that `yaml` would be smaller, since `js-yaml` was massively bloated the last time I checked. They included all of their tests, test fixtures, browser code, etc. in the published package. Now that you have seen both, what is your recommendation? edit: and also, thank you for taking the time to do this, and apologies for making you jump through hoops. I promise we'll get this merged and published as soon as we settle on which library to use.
sakulstra commented 2022-07-11 16:02:37 +00:00 (Migrated from github.com)

Would in fact go with yaml - seems more solid to me.

Would in fact go with `yaml` - seems more solid to me.
sakulstra commented 2022-07-21 09:01:42 +00:00 (Migrated from github.com)

@jonschlinkert any chance of getting this merged? 😅

@jonschlinkert any chance of getting this merged? :sweat_smile:
sakulstra commented 2022-08-23 09:18:45 +00:00 (Migrated from github.com)

@jonschlinkert ping 😅

@jonschlinkert ping :sweat_smile:
sakulstra commented 2022-09-14 08:45:43 +00:00 (Migrated from github.com)

@jonschlinkert 😿 - quite a lot of ppl are using this library (1M downloads per week). Would be really good if this could be merged anytime soon.

@jonschlinkert :crying_cat_face: - quite a lot of ppl are using this library (1M downloads per week). Would be really good if this could be merged anytime soon.
sakulstra commented 2023-09-12 18:01:10 +00:00 (Migrated from github.com)

@jonschlinkert ping on this, let me know if anything prevents merging.

@jonschlinkert ping on this, let me know if anything prevents merging.
benmccann commented 2024-08-19 13:22:04 +00:00 (Migrated from github.com)

for some reason bundlephobia is broken for yaml

It no longer is. It shows yaml at 102.6 kB and js-yaml at 39 kB.

> for some reason bundlephobia is broken for yaml It no longer is. It shows yaml at 102.6 kB and js-yaml at 39 kB.
pedzed commented 2026-03-16 05:54:01 +00:00 (Migrated from github.com)

@sakulstra Thank you for your contributions.

@jonschlinkert Understandably you may have had to make other priorities. Would you be so kind to make @sakulstra a maintainer of this project? This nice library needs to keep up with the time.

I am surprised that there is no TypeScript support (#105, #107, #181 and others).

@sakulstra Thank you for your contributions. @jonschlinkert Understandably you may have had to make other priorities. Would you be so kind to make @sakulstra a maintainer of this project? This nice library needs to keep up with the time. I am surprised that there is no TypeScript support (#105, #107, #181 and others).
sakulstra commented 2026-03-16 07:49:15 +00:00 (Migrated from github.com)

@pedzed Thanks, but I have no interest in maintaining this project at this point. Eventually we only need a very small portion of it's capabilities, so we have sth like:

import yaml from "js-yaml";

/**
 * Simple frontmatter parser using js-yaml
 * Extracts YAML frontmatter from markdown content
 */
export function parseFrontmatterMd(content: string): {
  data: Record<string, any>;
  content: string;
} {
  const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/;
  const match = content.match(frontmatterRegex);

  if (!match) {
    return { data: {}, content };
  }

  const [, frontmatter, body] = match;
  const data = yaml.load(frontmatter) as Record<string, any>;

  return { data, content: body };
}

which covers all our needs.

@pedzed Thanks, but I have no interest in maintaining this project at this point. Eventually we only need a very small portion of it's capabilities, so we have sth like: ``` import yaml from "js-yaml"; /** * Simple frontmatter parser using js-yaml * Extracts YAML frontmatter from markdown content */ export function parseFrontmatterMd(content: string): { data: Record<string, any>; content: string; } { const frontmatterRegex = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/; const match = content.match(frontmatterRegex); if (!match) { return { data: {}, content }; } const [, frontmatter, body] = match; const data = yaml.load(frontmatter) as Record<string, any>; return { data, content: body }; } ``` which covers all our needs.
pedzed commented 2026-03-26 19:17:46 +00:00 (Migrated from github.com)

@sakulstra Yeah, sometimes a small function may suffice, rendering a dependency such as this redundant. Thanks for your snippet, I will keep it in mind. I would go for the yaml library though, rather than js-yaml.

@sakulstra Yeah, sometimes a small function may suffice, rendering a dependency such as this redundant. Thanks for your snippet, I will keep it in mind. I would go for the `yaml` library though, rather than `js-yaml`.
This pull request has changes conflicting with the target branch.
  • examples/sections.js
  • index.js
  • lib/engines.js
  • package.json
  • test/parse-custom.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 "sakulstra/feat/yaml:sakulstra/feat/yaml"
git switch "sakulstra/feat/yaml"
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!147
No description provided.