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

* [feature] pure front-matter with no builtin parsers. #15

Closed
wants to merge 3 commits into from

Conversation

snowyu
Copy link

@snowyu snowyu commented Aug 9, 2015

It could get the non-builtin matter and can register your parsers.

cson = require 'cson'
matter = require 'gray-matter/lib'
matter.register ['cson', 'json'], cson.parse.bind(cson)
matter.defalutLang = 'cson'
matter '---\na:123\n---'

matter = require 'gray-matter' # with builtin parsers
  • can register the new parser
  • separate the builtin parsers to regiter individually
  • defaultLang attriubte to matter, default to 'yaml'
  • move ./index.js to lib/index.js
  • remove builtin parsers on lib/index.js
  • rewrite ./index.js to register builtin parsers.

Suggesions and todo:

  • matter.read should remove to high level library.

    • to get rid of the fs library dependency.
  • register to stringify too.

  • remove ugly parsers.requires cache.

    register = require 'gray-matter/lib/parser/parser'
    try
    parser = require '...'
    catch
    throw new Error('you should "npm install xxx" the parser before use')
    register 'xxx', parser

+ register the new parser
* separate the builtin parsers to regiter individually
@jonschlinkert
Copy link
Owner

looks like a great pr! these are some pretty big changes, so I'll need some time to review. I'll come back with some comments as soon as I have a chance

@tunnckoCore
Copy link

@snowyu parser system can be handled completely and it's intended to be handled (#12) with https://github.com/jonschlinkert/parser-cache

@jonschlinkert
Copy link
Owner

closing in light of 2c1b5ce, but I do appreciate the pr. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants