# gfm-code-block-regex

> RegExp for gfm (GitHub Flavored Markdown) fenced code blocks.

Latest version **1.0.0** (published 2017-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install gfm-code-block-regex
pnpm add gfm-code-block-regex
yarn add gfm-code-block-regex
bun add gfm-code-block-regex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-03-16 |
| First published | 2014-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert |
| Keywords | block, code, exec, expression, fence, fenced, fences, flavor, flavored, gfm, github, markdown, match, matches, pattern, patterns, re, regex, regexp, regular, replace, replacement |

## Links

- npm: https://www.npmjs.com/package/gfm-code-block-regex
- Repository: https://github.com/regexhq/gfm-code-block-regex
- Issues: https://github.com/regexhq/gfm-code-block-regex/issues
- npm.io page: https://npm.io/package/gfm-code-block-regex

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-03-16
- 0.2.3 — 2015-12-09
- 0.2.1 — 2014-09-24
- 0.2.0 — 2014-09-23
- 0.1.2 — 2014-08-13
- 0.1.1 — 2014-08-13
- 0.1.0 — 2014-08-13

## README

# gfm-code-block-regex [![NPM version](https://img.shields.io/npm/v/gfm-code-block-regex.svg?style=flat)](https://www.npmjs.com/package/gfm-code-block-regex) [![NPM monthly downloads](https://img.shields.io/npm/dm/gfm-code-block-regex.svg?style=flat)](https://npmjs.org/package/gfm-code-block-regex)  [![NPM total downloads](https://img.shields.io/npm/dt/gfm-code-block-regex.svg?style=flat)](https://npmjs.org/package/gfm-code-block-regex) [![Linux Build Status](https://img.shields.io/travis/regexhq/gfm-code-block-regex.svg?style=flat&label=Travis)](https://travis-ci.org/regexhq/gfm-code-block-regex)

> RegExp for gfm (GitHub Flavored Markdown) fenced code blocks.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save gfm-code-block-regex
```

## Usage

```js
var re = require('gfm-code-block-regex');

var match = re().exec('random text \n```js\nfoo\n```\n more random text');
console.log(match);
```

Returns:

```js
[ '```sh\nnpm install micromatch --save-dev\n```',
  '```sh\nnpm install micromatch --save-dev\n```',
  '```',
  'sh',
  '\nnpm install micromatch --save-dev\n',
  '```',
  index: 4,
  input: 'foo\n```sh\nnpm install micromatch --save-dev\n```\nbar' ]
```

## Heads up!

Note that if a gfm code block has a javascript block comment inside of it, and within the block comment is another gfm code block, it will fail if the block comment does not have leading stars.

**Examples**

This should work:

<pre>
```js
/**
 * This is a comment with
 * several lines of text.
 *
 * An example
 *
 * ```js
 * var foo = bar;
 * var foo = bar;
 * var foo = bar;
 * ```
*/
```
</pre>

This will not work (note the absence of leading stars inside the comment):

<pre>
```js
/**
  This is a comment with
  several lines of text.

  An example

  ```js
  var foo = bar;
  var foo = bar;
  var foo = bar;
  ```
 */
```
</pre>

Although the previous example is perfectly valid, regex alone is not sufficient.

## About
### Related projects
- [extract-gfm](https://www.npmjs.com/package/extract-gfm): Utilities for extracting and replacing GitHub Flavored Markdown code blocks. For example, you could easily… [more](https://github.com/jonschlinkert/extract-gfm) | [homepage](https://github.com/jonschlinkert/extract-gfm "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.")
- [gfm-code-blocks](https://www.npmjs.com/package/gfm-code-blocks): Extract gfm (GitHub Flavored Markdown) fenced code blocks from a string. | [homepage](https://github.com/jonschlinkert/gfm-code-blocks "Extract gfm (GitHub Flavored Markdown) fenced code blocks from a string.")
- [to-gfm-code-block](https://www.npmjs.com/package/to-gfm-code-block): Generate a github-flavored-markdown fenced-code-block snippet. | [homepage](https://github.com/jonschlinkert/to-gfm-code-block "Generate a github-flavored-markdown fenced-code-block snippet.")

### Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

### Contributors

### Release history

### Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

### Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)

### License

Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 16, 2017._

---
_Source: https://npm.io/package/gfm-code-block-regex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
