{"_id":"extract-gfm","_rev":"83350","name":"extract-gfm","description":"Utilities for extracting and replacing GitHub Flavored Markdown code blocks. For example, you could easily find code blocks for a specific language and run the code through a linter.","dist-tags":{"latest":"0.1.0"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T10:26:31.000Z","created":"2014-09-24T03:06:29.360Z","0.1.0":"2014-09-24T03:06:29.360Z"},"users":{},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/extract-gfm.git"},"versions":{"0.1.0":{"name":"extract-gfm","description":"Utilities for extracting and replacing GitHub Flavored Markdown code blocks. For example, you could easily find code blocks for a specific language and run the code through a linter.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/extract-gfm","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/extract-gfm.git"},"bugs":{"url":"https://github.com/jonschlinkert/extract-gfm/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/extract-gfm/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha -R spec"},"devDependencies":{"mocha":"*","reduce-object":"^0.1.2","should":"^4.0.4","test-helpers":"^0.1.4","verb":">= 0.2.6","verb-tag-jscomments":">= 0.2.0"},"keywords":["docs","documentation","generate","generator","markdown","templates","verb"],"dependencies":{"gfm-code-block-regex":"^0.2.1","gfm-code-blocks":"^0.2.0"},"_id":"extract-gfm@0.1.0","_shasum":"6cdaeb14eb46e3bd3ba464d98171d05a83acff6b","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"6cdaeb14eb46e3bd3ba464d98171d05a83acff6b","size":4159,"noattachment":false,"key":"/extract-gfm/-/extract-gfm-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/extract-gfm/download/extract-gfm-0.1.0.tgz"},"directories":{},"publish_time":1411527989360,"_cnpm_publish_time":1411527989360,"_hasShrinkwrap":false}},"readme":"# extract-gfm [![NPM version](https://badge.fury.io/js/extract-gfm.svg)](http://badge.fury.io/js/extract-gfm)\n\n\n> Utilities for extracting and replacing GitHub Flavored Markdown code blocks. For example, you could easily find code blocks for a specific language and run the code through a linter.\n\nSee the [example](./example.js) for ideas.\n\n## Install\n#### Install with [npm](npmjs.org):\n\n```bash\nnpm i extract-gfm --save-dev\n```\n\n## Run tests\n\n```bash\nnpm test\n```\n\n## Usage\n\n```js\nvar extract = require('extract-gfm');\nextract.parseBlocks('abc\\n```js\\nvar foo = \"bar\";\\n```\\nxyz');\n```\n**Returns:**\n\n```js\n{ text: 'abc\\n__CODE_BLOCK0__\\nxyz',\n  blocks:\n   [ { lang: 'js',\n       code: 'var foo = \"bar\";',\n       block: '```js\\nvar foo = \"bar\";\\n```' } ],\n  markers: [ '__CODE_BLOCK0__' ] }\n```\n\n## API\n### [.stripBlocks](index.js#L24)\n\n* `str` **{String}**: Original string with gfm code blocks.    \n* `returns`: {String}  \n\nStrip code blocks from a string and replaced them with\nheuristic markers.\n\n### [.extractBlocks](index.js#L41)\n\n* `str` **{String}**: The string to parse.    \n* `returns`: {Array}  \n\nReturn an array of all **gfm code blocks** found.\nSee [gfm-code-blocks] for more detail.\n\n### [.parseBlocks](index.js#L70)\n\nConvenience method to make it easy to replace code blocks.\n\n* `str` **{String}**: The string to parse.    \n* `returns`: {Object}  \n\nReturns an object with:\n\n   - `text`: the string stripped of code blocks, where each block\n     is replaced with a heuristic marker.\n   - `blocks`: An array of code blocks, using the [.extractBlocks()](#extractBlocks) method.\n   - `markers`: An array of heuristic markers to be used for adding code blocks back.\n\n**Example**\n\n```js\nvar code = require('extract-gfm');\nvar fs = require('fs');\nvar str = fs.readFileSync('README.md', 'utf8');\nconsole.log(code.parseBlocks(str));\n```\n\n### [.injectBlocks](index.js#L93)\n\nUsed for adding code blocks back into the string after they have been modified somehow.\n\n* `str` **{String}**: A string with heuristic markers to replace.    \n* `object` **{String}**: Object created by [.parseBlocks()](#parseBlocks)    \n* `returns` **{String}**: Updated string, with shiny new code blocks.  \n\nTo customize how this is done, just look at the `injectBlocks`\nmethod and create your own based on this. [.parseBlocks()](#parseBlocks)\nreally does all of the hard work.\n\n## Author\n\n**Jon Schlinkert**\n \n+ [github/jonschlinkert](https://github.com/jonschlinkert)\n+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) \n\n## License\nCopyright (c) 2014 Jon Schlinkert, contributors.  \nReleased under the MIT license\n\n***\n\n_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 23, 2014._\n\n[gfm-code-blocks]: https://github.com/jonschlinkert/gfm-code-blocks","_attachments":{},"homepage":"https://github.com/jonschlinkert/extract-gfm","bugs":{"url":"https://github.com/jonschlinkert/extract-gfm/issues"}}