Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 1.14 KB

.verb.md

File metadata and controls

68 lines (53 loc) · 1.14 KB

Usage

var re = require('{%= name %}');

var match = re().exec('foo\n```sh\nnpm install micromatch --save-dev\n```\nbar');
console.log(match);

Returns:

[ '```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:

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

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

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

  An example

  ```js
  var foo = bar;
  var foo = bar;
  var foo = bar;
  ```
 */
```

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