{"id":15560991,"url":"https://github.com/regexhq/gfm-code-block-regex","last_synced_at":"2026-01-11T13:28:55.151Z","repository":{"id":19656158,"uuid":"22909065","full_name":"regexhq/gfm-code-block-regex","owner":"regexhq","description":"RegExp for gfm (GitHub Flavored Markdown) code blocks.","archived":false,"fork":false,"pushed_at":"2017-03-16T15:39:58.000Z","size":18,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-23T21:44:59.852Z","etag":null,"topics":["gfm","github-flavored-markdown","markdown","regex","regular-expression"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/regexhq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-13T08:49:30.000Z","updated_at":"2024-01-17T06:04:56.000Z","dependencies_parsed_at":"2022-09-10T22:52:04.744Z","dependency_job_id":null,"html_url":"https://github.com/regexhq/gfm-code-block-regex","commit_stats":null,"previous_names":["jonschlinkert/gfm-code-block-regex"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexhq%2Fgfm-code-block-regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexhq%2Fgfm-code-block-regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexhq%2Fgfm-code-block-regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regexhq%2Fgfm-code-block-regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/regexhq","download_url":"https://codeload.github.com/regexhq/gfm-code-block-regex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522293,"owners_count":21444509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gfm","github-flavored-markdown","markdown","regex","regular-expression"],"created_at":"2024-10-02T16:04:44.274Z","updated_at":"2026-01-11T13:28:55.083Z","avatar_url":"https://github.com/regexhq.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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\u0026label=Travis)](https://travis-ci.org/regexhq/gfm-code-block-regex)\n\n\u003e RegExp for gfm (GitHub Flavored Markdown) fenced code blocks.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save gfm-code-block-regex\n```\n\n## Usage\n\n```js\nvar re = require('gfm-code-block-regex');\n\nvar match = re().exec('foo\\n```sh\\nnpm install micromatch --save-dev\\n```\\nbar');\nconsole.log(match);\n```\n\nReturns:\n\n```js\n[ '```sh\\nnpm install micromatch --save-dev\\n```',\n  '```sh\\nnpm install micromatch --save-dev\\n```',\n  '```',\n  'sh',\n  '\\nnpm install micromatch --save-dev\\n',\n  '```',\n  index: 4,\n  input: 'foo\\n```sh\\nnpm install micromatch --save-dev\\n```\\nbar' ]\n```\n\n## Heads up!\n\nNote 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.\n\n**Examples**\n\nThis should work:\n\n\u003cpre\u003e\n```js\n/**\n * This is a comment with\n * several lines of text.\n *\n * An example\n *\n * ```js\n * var foo = bar;\n * var foo = bar;\n * var foo = bar;\n * ```\n*/\n```\n\u003c/pre\u003e\n\nThis will not work (note the absence of leading stars inside the comment):\n\n\u003cpre\u003e\n```js\n/**\n  This is a comment with\n  several lines of text.\n\n  An example\n\n  ```js\n  var foo = bar;\n  var foo = bar;\n  var foo = bar;\n  ```\n */\n```\n\u003c/pre\u003e\n\nAlthough the previous example is perfectly valid, regex alone is not sufficient.\n\n## About\n### Related projects\n- [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.\")\n- [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.\")\n- [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.\")\n\n### Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n### Release history\n\n### Building docs\n_(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.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning 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:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 16, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregexhq%2Fgfm-code-block-regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fregexhq%2Fgfm-code-block-regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregexhq%2Fgfm-code-block-regex/lists"}