{"_id":"yfm","_rev":"80050","name":"yfm","description":"A simple to use YAML Front-Matter parsing and extraction Library.","dist-tags":{"latest":"0.2.0"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:25:36.000Z","created":"2014-02-05T13:10:32.557Z","0.2.0":"2014-02-05T13:11:06.942Z","0.1.1":"2014-02-05T13:10:32.557Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"https://github.com/assemble/yfm.git"},"versions":{"0.2.0":{"name":"yfm","description":"A simple to use YAML Front-Matter parsing and extraction Library.","version":"0.2.0","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"https://github.com/assemble/yfm.git"},"licenses":[{"type":"MIT","url":"https://github.com/assemble/yfm/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">= 0.8.0"},"dependencies":{"delims":"~0.1.0","fs-utils":"~0.1.6","js-yaml":"~3.0.1","lodash":"~2.4.1"},"devDependencies":{"chai":"~1.8.1","globule":"~0.2.0","grunt":"~0.4.2","grunt-contrib-clean":"~0.5.0","grunt-contrib-jshint":"~0.8.0","grunt-mocha-test":"~0.8.2","grunt-readme":"~0.4.5","grunt-repos":"~0.1.2","grunt-sync-pkg":"~0.1.2"},"keywords":["front-matter","front matter","frontmatter","yaml front matter","yfm","yaml"],"bugs":{"url":"https://github.com/assemble/yfm/issues"},"homepage":"https://github.com/assemble/yfm","_id":"yfm@0.2.0","dist":{"shasum":"a1cb79050dae85479cd796384250c50b5e1a4cb0","size":25796,"noattachment":false,"key":"/yfm/-/yfm-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/yfm/download/yfm-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"publish_time":1391605866942,"_cnpm_publish_time":1391605866942,"_hasShrinkwrap":false},"0.1.1":{"name":"yfm","description":"A YAML Front-Matter parsing and extraction Library.","version":"0.1.1","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"bugs":{"url":"https://github.com/assemble/yfm/issues"},"homepage":"https://github.com/assemble/yfm","repository":{"type":"git","url":"https://github.com/assemble/yfm.git"},"licenses":[{"type":"MIT","url":"https://github.com/assemble/yfm/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">= 0.8.0"},"dependencies":{"js-yaml":"~3.0.1","lodash":"~2.4.1","fs-utils":"~0.1.6"},"keywords":["front-matter","front matter","yaml front matter","yfm","yaml"],"_id":"yfm@0.1.1","dist":{"shasum":"937431a9374b21fc0c668fa6d29688f6bd659820","size":46231,"noattachment":false,"key":"/yfm/-/yfm-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/yfm/download/yfm-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"directories":{},"publish_time":1391605832557,"_cnpm_publish_time":1391605832557,"_hasShrinkwrap":false}},"readme":"# yfm [![NPM version](https://badge.fury.io/js/yfm.png)](http://badge.fury.io/js/yfm)\r\n\r\n> A simple to use YAML Front-Matter parsing and extraction Library.\r\n\r\n**Why another YAML Front Matter library?**\r\n\r\nBecause other libraries we tried failed to meet our requirements with [Assemble](http://assemble.io). Some most of the libraries met most of the requirements, but _none had all of them_. Here are the most important:\r\n\r\n* Be usable, if not simple\r\n* Allow custom delimiters\r\n* Use a dependable and well-supported library for parsing YAML\r\n* Don't fail if YAML front matter exists, but no content\r\n* Don't fail if content exists, but no YAML front matter\r\n* Have no problem reading YAML files directly\r\n* Have no problem with complex content, including fenced code blocks containing examples of YAML front matter.\r\n* Should return an object that contains the parsed YAML front matter and content, as well as the \"original\" content.\r\n\r\n```bash\r\nnpm i yfm --save\r\n```\r\n## Usage\r\n\r\n```js\r\nvar yfm = require('yfm');\r\nyfm(String, Object);\r\n```\r\n\r\n## Methods\r\n\r\n### yfm\r\n\r\nBy default the `yfm()` method expects a string. So this:\r\n\r\n```js\r\nyfm('---\\nTitle: This is YFM\\n---\\n<p>This is content.<p>');\r\n```\r\n\r\nresults in:\r\n\r\n```json\r\n{\r\n  \"context\": {\r\n    \"title\": \"This is YFM\"\r\n  },\r\n  \"content\": \"<p>This is content.<p>\",\r\n  \"original\": \"---\\nTitle: This is YFM\\n---\\n<p>This is content.<p>\"\r\n}\r\n```\r\n\r\n### yfm.read\r\n\r\nTo read a file from the file system before parsing, use `yfm.read`:\r\n\r\n```js\r\nyfm.read('file.md');\r\n```\r\n\r\n### yfm.exists\r\n\r\nTo check for YAML front matter, returning `true` or `false` if it exists, use `yfm.exists`:\r\n\r\n```js\r\nyfm.exists('file.md');\r\n```\r\n\r\n\r\n\r\n## Options\r\n\r\n> All methods will accept an options object to be passed as a second paramer\r\n\r\n#### delimiters\r\nType: `object`\r\n\r\nDefault: `{delims: ['---', '---']}`\r\n\r\nOpen and close delimiters can be passed in as an array of strings. Example:\r\n\r\n```js\r\nyfm.read('file.md', {delims: ['~~~', '~~~']});\r\n```\r\n\r\nYou may also pass an array of arrays, allowing multiple alternate delimiters to be used. Example:\r\n\r\n\r\n```js\r\n{\r\n  delims: [\r\n    ['---', '~~~'], ['---', '~~~']\r\n  ]\r\n}\r\n```\r\n\r\n_However, passing multiple delimiters will yield unpredictable results, so it is recommended that you use this option only for testing purposes._\r\n\r\n\r\n## Examples\r\n\r\nLet's say our page, `foo.html` contains\r\n\r\n```html\r\n---\r\ntitle: YAML Front matter\r\ndescription: This is a page\r\n---\r\n<h1>{{title}}</h1>\r\n```\r\n\r\nthen running the following in the command line:\r\n\r\n```js\r\nconsole.log(yfm('foo.html'));\r\n```\r\nreturns\r\n\r\n```json\r\n{\r\n  \"context\": {\r\n    \"title\": \"YAML Front matter\",\r\n    \"description\": \"This is a page\"\r\n  },\r\n  \"content\": \"<h1>{{title}}</h1>\",\r\n  \"original\": \"---\\ntitle: YAML Front matter\\n---\\n<h1>{{title}}</h1>\"\r\n}\r\n```\r\nand\r\n\r\n```js\r\nconsole.log(yfm('foo.html').context);\r\n```\r\nreturns\r\n\r\n\r\n```json\r\n{\"title\": \"YAML Front matter\", \"description\": \"This is a page\"}\r\n```\r\n\r\n\r\n## Authors\r\n\r\n**Jon Schlinkert**\r\n\r\n+ [github/jonschlinkert](https://github.com/jonschlinkert)\r\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\r\n\r\n**Brian Woodward**\r\n\r\n+ [github/doowb](https://github.com/doowb)\r\n+ [twitter/doowb](http://twitter.com/jonschlinkert)\r\n\r\n\r\n## License\r\nCopyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors.\r\nReleased under the MIT license\r\n\r\n***\r\n\r\n_This file was generated by [grunt-readme](https://github.com/assemble/grunt-readme) on Monday, January 27, 2014._\r\n\r\n[grunt]: http://gruntjs.com/\r\n[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md\r\n[package.json]: https://npmjs.org/doc/json.html\r\n","_attachments":{},"homepage":"https://github.com/assemble/yfm","bugs":{"url":"https://github.com/assemble/yfm/issues"}}