{"author":{"name":"Derek Worthen"},"name":"yaml-front-matter","description":"yaml front matter for JS using the js-yaml module","version":"2.1.0","repository":{"type":"git","url":"https://github.com/dworthen/js-yaml-front-matter"},"dependencies":{"commander":"1.0.0","js-yaml":"~2.1.0"},"devDependencies":{"should":"0.6.3","mocha":"~1.3.0"},"engines":{"node":">=0.8.x","npm":"1.1.x"},"bin":{"yaml-front-matter":"bin/js-yaml-front.js","js-yaml":"node_modules/js-yaml/bin/js-yaml.js"},"bugs":{"url":"https://github.com/dworthen/js-yaml-front-matter/issues"},"_id":"yaml-front-matter@2.1.0","dist":{"shasum":"f11a46efef1a3b09218643b9f1058920e09e3ccf","tarball":"http://registry-npm.ywwl.com/yaml-front-matter/download/yaml-front-matter-2.1.0.tgz","integrity":"sha512-uL4WKh0z/Yi9c1jGmpwl1Fjgqen/fSlAFwui3h/uuC7YzgzzgbIzzLO/gwNr6bwIz2Wi7UbFEmsUYnsF2eHMeQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBVw9EiVGrSxPBsBhUaN6HlOKTZrUacEJRdWsRU9S2opAiEApyb/SSci+UO7aAIRXe0pbUQNFzWPlg2C6rKWHS8EL64="}],"size":3844,"noattachment":false,"key":"/yaml-front-matter/-/yaml-front-matter-2.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"dworthen","email":"worthend.derek@gmail.com"},"maintainers":[{"name":"dworthen","email":"worthend.derek@gmail.com"}],"directories":{},"readme":"# Yaml Front Matter\n\nParses yaml or json at the front of a string. Places the parsed content, plus the rest of the string content, into an object literal.\n\n[Online Demo](https://dworthen.github.io/js-yaml-front-matter/).\n\n#### Breaking Changes\n\nThis readme is for the 4.x release, which introduces breaking changes. View the [changelog](CHANGELOG.md) for more information.\n\n[3.x readme](https://github.com/dworthen/js-yaml-front-matter/tree/v3.4.0)\n\n## Example\n\nThis\n\n```yaml\n---\nname: Derek Worthen\nage: 127\ncontact:\n  email: email@domain.com\n  address: some location\npets:\n  - cat\n  - dog\n  - bat\nmatch: !!js/regexp /pattern/gim\nrun: !!js/function function() { }\n---\nSome Other content\n```\n\n```js\nvar fs = require('fs');\nvar yamlFront = require('yaml-front-matter');\n\nfs.readFile('./some/file.txt', 'utf8', function(fileContents) {\n    console.log(yamlFront.loadFront(fileContents));\n});\n\n```\n\noutputs\n\n```js\n{ \n    name: 'Derek Worthen',\n    age: 127,\n    contact: { email: 'email@domain.com', address: 'some location' },\n    pets: [ 'cat', 'dog', 'bat' ],\n    match: /pattern/gim,\n    run: [Function],\n    __content: '\\nSome Other Content' \n}\n```\n\nMay also use JSON\n\n```json\n---\n{\n    \"name\": \"Derek Worthen\",\n    \"age\": \"young\",\n    \"anArray\": [\"one\",\"two\"],\n    \"subObj\":{\"field1\": \"one\"}\n}\n---\nSome content\n```\n\n> __NOTE:__ The `---` are required to denote the start and end of front matter. There must be a newline after the opening `---` and a newline preceding the closing `---`.\n\n## Install\n\n### npm\n\n```shell\n$ npm install yaml-front-matter\n```\n\nUse the `-g` flag if you plan on using the command line tool.\n\n```shell\n$ npm install yaml-front-matter -g\n```\n\n### Node or client with module bundler (webpack or browsify)\n\n```js\nvar yamlFront = require('yaml-front-matter');\n```\n    \n### Browser Bundle\n\nThe [dist/yamlFront.js](dist/yamlFront.js) client script will expose the yaml-front-matter library as a global, `yamlFront`. The client script for [js-yaml](https://github.com/nodeca/js-yaml) is also required. May need to load espirma for some use cases. See [js-yaml](https://github.com/nodeca/js-yaml) for more information.\n\n```html\n<script src=\"https://unpkg.com/js-yaml@3.10.0/dist/js-yaml.js\"></script>\n<script src=\"yamlFront.js\"></script>\n<script>\n  // parse front matter with yamlFront.loadFront(String);\n</script>\n```\n\n> **Note**: yaml-front-matter is delivered as a umd package so it should work within commonjs, amd and browser (as a global) environments.\n\n## Running Browser Example\n\n```shell\n$ npm install --dev && npm start\n```\n\nThen visit `localhost:8080`.\n\n## Building from source\n\nOutputs build files to `dist/`.\n\n```shell\n$ npm install --dev && npm run build\n```\n\n## Running Tests\n\n```shell\nnpm install --dev && npm test\n```\n\n## Command Line\n\n```shell\nUsage: yaml-front-matter [options] <yaml-front-matter content>\n\nOptions:\n\n-h, --help            output usage information\n-v, --version         output the version number\n-c, --content [name]  set the property name for the files contents [__content]\n--pretty              formats json output with spaces. \n```\n\n> **Note** The cli uses `safeLoadFront` and therefore will not parse yaml containing regexps, functions or undefined values.\n\n### Example\n\n```shell\n# Piping content from one file, through yaml parser and into another file\ncat ./some/file.txt | yaml-front-matter > output.txt\n```\n\n## JS-YAML\n\nYaml front matter wraps [js-yaml](https://github.com/nodeca/js-yaml) to support parsing yaml front-matter.\n\n## API\n\n### loadFront(string, [options])\n\n```js\nvar input = [\n        '---\\npost: title one\\n',\n        'anArray:\\n - one\\n - two\\n',\n        'subObject:\\n prop1: cool\\n prop2: two',\n        '\\nreg: !!js/regexp /pattern/gim',\n        '\\nfun: !!js/function function() {  }\\n---\\n',\n        'content\\nmore'\n    ].join('');\n\nvar results = yamlFront.loadFront(input);\nconsole.log(results);\n```\n\noutputs\n\n```shell\n{ post: 'title one',\n  anArray: [ 'one', 'two' ],\n  subObject: { obj1: 'cool', obj2: 'two' },\n  reg: /pattern/gim,\n  fun: [Function],\n  __content: '\\ncontent\\nmore' }\n```\n\nFront-matter is optional.\n\n```js\nyamlFront.loadFront('Hello World');\n// => { __content: \"Hello World!\" }\n```\n\nContent is optional\n\n```js\nyamlFront.loadFront('');\n// => { __content: '' }\n```\n\n### safeLoadFront(string, [options])\n\nSame api as loadFront except it does not support regexps, functions or undefined. See [js-yaml](https://github.com/nodeca/js-yaml) for more information.\n\n### Options\n\nThe options object supports the same options available to [js-yaml](https://github.com/nodeca/js-yaml) and adds support for an additional key.\n\n- `options.contentKeyName`: Specify the object key where to store content not parsed by yaml-front-matter. defaults to `__content`.\n\n```js\nyamlFront.loadFront('Hello World', {\n    contentKeyName: 'fileContents' \n});\n// => { fileContents: \"Hello World\" }\n```\n\n","publish_time":1377970687884,"_cnpm_publish_time":1377970687884,"dist-tags":{"latest":"4.1.1","next":"4.0.0-4"}}