{"author":{"name":"Derek Worthen"},"license":"MIT","name":"yaml-front-matter","description":"yaml front matter for JS. Parse yaml or JSON from the beginning of files.","main":"dist/yamlFront.js","module":"src/index.js","version":"4.0.0-3","keywords":["yaml"],"repository":{"type":"git","url":"git+https://github.com/dworthen/js-yaml-front-matter.git"},"dependencies":{"commander":"1.0.0","js-yaml":"^3.10.0"},"devDependencies":{"babel-core":"^6.26.0","babel-loader":"^7.1.3","babel-preset-env":"^1.6.1","browser-sync":"^2.11.1","commander":"^2.14.1","gulp":"^3.9.0","gulp-concat":"^2.6.0","gulp-rename":"^1.2.2","gulp-sourcemaps":"^1.6.0","gulp-uglify":"^1.5.1","http-server":"^0.11.1","mocha":"~1.3.0","should":"0.6.3","standard-version":"^4.3.0","webpack":"^4.0.1","webpack-cli":"^2.0.9"},"bin":{"yaml-front-matter":"bin/js-yaml-front.js"},"scripts":{"test":"mocha -u bdd --reporter spec","start":"npm run build:browser && http-server ./docs -p 8080","release":"standard-version","build":"webpack --mode production","build:browser":"webpack --mode production --env.browser"},"gitHead":"fb5ffb72cd922ad966e3239e142b702dc22448f6","readme":"# Yaml Front Matter\r\n\r\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.\r\n\r\n[Online Demo](https://dworthen.github.io/js-yaml-front-matter/).\r\n\r\n#### Breaking Changes\r\n\r\nThis readme is for the 4.x branch which introduces breaking changes. View the [changelog](CHANGELOG.md) for more information.\r\n\r\n[3.x readme](https://github.com/dworthen/js-yaml-front-matter/tree/v3.4.0)\r\n\r\n## Example\r\n\r\nThis\r\n\r\n```yaml\r\n---\r\nname: Derek Worthen\r\nage: young\r\ncontact:\r\n  email: email@domain.com\r\n  address: some location\r\npets:\r\n  - cat\r\n  - dog\r\n  - bat\r\nmatch: !!js/regexp /pattern/gim\r\nrun: !!js/function function() { }\r\n---\r\nSome Other content\r\n```\r\n\r\nbecomes\r\n\r\n```js\r\n{ \r\n    name: 'Derek Worthen',\r\n    age: 'young',\r\n    contact: { email: 'email@domain.com', address: 'some location' },\r\n    pets: [ 'cat', 'dog', 'bat' ],\r\n    match: /pattern/gim,\r\n    run: [Function],\r\n    __content: '\\nSome Other Content' \r\n}\r\n```\r\n\r\nMay also use JSON\r\n\r\n```json\r\n---\r\n{\r\n    \"name\": \"Derek Worthen\",\r\n    \"age\": \"young\",\r\n    \"anArray\": [\"one\",\"two\"],\r\n    \"subObj\":{\"field1\": \"one\"}\r\n}\r\n---\r\nSome content\r\n```\r\n\r\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 `---`.\r\n\r\n## Install\r\n\r\n#### npm\r\n\r\n```shell\r\n$ npm install yaml-front-matter@next\r\n```\r\n\r\nUse the `-g` flag if you plan on using the command line tool.\r\n\r\n```shell\r\n$ npm install yaml-front-matter -g\r\n```\r\n    \r\n#### Browser\r\n\r\nInclude the client script from [dist/yamlFront.js](dist/yamlFront.js). The library will be exposed 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.\r\n\r\n```html\r\n<script src=\"https://unpkg.com/js-yaml@3.10.0/dist/js-yaml.js\"></script>\r\n<script src=\"js-yaml-front-client.min.js\"></script>\r\n<script>\r\n  // parse front matter with yamlFront.loadFront(String);\r\n</script>\r\n```\r\n\r\n## Running the Browser Example\r\n\r\n```shell\r\n$ npm install --dev && npm start\r\n```\r\n\r\nThen visit `localhost:8080`.\r\n\r\n## Building from source\r\n\r\nOutputs client files in `dist/`.\r\n\r\n```shell\r\n$ npm install --dev && npm run build\r\n```\r\n\r\n## Running Tests\r\n\r\n```shell\r\nnpm install --dev && npm test\r\n```\r\n\r\n## Command Line\r\n\r\n```shell\r\nUsage: yaml-front-matter [options] <yaml-front-matter content>\r\n\r\nOptions:\r\n\r\n-h, --help            output usage information\r\n-v, --version         output the version number\r\n-c, --content [name]  set the property name for the files contents [__content]\r\n--pretty              formats json output with spaces. \r\n```\r\n\r\n> **Note** The cli uses `safeLoadFront` and therefore the cli cannot parse yaml containing regexps, functions or undefined values.\r\n\r\n## JS-YAML\r\n\r\nYaml front matter wraps [js-yaml](https://github.com/nodeca/js-yaml) to support parsing yaml front-matter.\r\n\r\n## API\r\n\r\n### loadFront(string, [options])\r\n\r\n```js\r\nvar yamlFront = require('yaml-front-matter')\r\n  , input = [\r\n        '---\\npost: title one\\n',\r\n        'anArray:\\n - one\\n - two\\n',\r\n        'subObject:\\n prop1: cool\\n prop2: two',\r\n        '\\nreg: !!js/regexp /pattern/gim',\r\n        '\\nfun: !!js/function function() {  }\\n---\\n',\r\n        'content\\nmore'\r\n    ].join('');\r\n\r\nvar results = yamlFront.loadFront(input);\r\nconsole.log(results);\r\n```\r\n\r\nthe above will produce the following in the console.\r\n\r\n```shell\r\n{ post: 'title one',\r\n  anArray: [ 'one', 'two' ],\r\n  subObject: { obj1: 'cool', obj2: 'two' },\r\n  reg: /pattern/gim,\r\n  fun: [Function],\r\n  __content: '\\ncontent\\nmore' }\r\n```\r\n\r\nThe front-matter is optional.\r\n\r\n```\r\nfrontMatter.loadFront('Hello World');\r\n```\r\n\r\nWill produce\r\n\r\n```js\r\n{ __content: \"Hello World!\" }\r\n```\r\n\r\nContent all together is optional\r\n\r\n```js\r\nfrontMatter.loadFront('');\r\n// will produce { __content: '' }\r\n```\r\n\r\n### safeLoadFront(string, [options])\r\n\r\nSame api as loadFront except it does not support regexps, functions and undefined. See [js-yaml](https://github.com/nodeca/js-yaml) for more information.\r\n\r\n### Options\r\n\r\nThe options object supports the same options available to [js-yaml](https://github.com/nodeca/js-yaml) except adds support for an additional key.\r\n\r\n- `options.contentKeyName`: Specify the object key where the remaining string content after parsing the yaml front-matter will be stored. defaults to `__content`.\r\n\r\n```js\r\nyamlFront.loadFront('Hello World', {\r\n    contentKeyName: 'fileContents' \r\n});\r\n// => { fileContents: \"Hello World\" }\r\n```\r\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/dworthen/js-yaml-front-matter/issues"},"homepage":"https://github.com/dworthen/js-yaml-front-matter#readme","_id":"yaml-front-matter@4.0.0-3","_shasum":"effcba11d467fda9def67961ef2fe229b957394d","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.4","_npmUser":{"name":"dworthen","email":"worthend.derek@gmail.com"},"dist":{"shasum":"effcba11d467fda9def67961ef2fe229b957394d","tarball":"http://registry-npm.ywwl.com/yaml-front-matter/download/yaml-front-matter-4.0.0-3.tgz","fileCount":20,"unpackedSize":209143,"integrity":"sha512-70iTU/34PDEiKTSe+jLeL4kY+uBbnPEJaKbHVWZZac16OJySWJ3vu5P9+beENdFJTd0ppprJGzNFmBmo7ACj8A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBvayUClnj8fFvoeJ0fEaFZFDeDLOMnQUz+Q3oI/Ek/DAiEA7hP91bBfRQcZfTzi3jNOP+h5+yq31mLP/Y2EbwMOFA0="}],"size":49500,"noattachment":false,"key":"/yaml-front-matter/-/yaml-front-matter-4.0.0-3.tgz"},"maintainers":[{"name":"dworthen","email":"worthend.derek@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/yaml-front-matter_4.0.0-3_1519772477820_0.8715528862989672"},"_hasShrinkwrap":false,"publish_time":1519772478043,"_cnpm_publish_time":1519772478043,"dist-tags":{"latest":"4.1.1","next":"4.0.0-4"}}