{"name":"gatsby-remark-prismjs","description":"Adds syntax highlighting to code blocks at build time using PrismJS","version":"3.0.0-rc.1","author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"dependencies":{"@babel/runtime":"7.0.0-beta.52","parse-numeric-range":"^0.0.2","unist-util-visit":"^1.3.0"},"devDependencies":{"@babel/cli":"7.0.0-beta.52","@babel/core":"7.0.0-beta.52","cross-env":"^5.1.4","prismjs":"^1.15.0","remark":"^9.0.0"},"peerDependencies":{"gatsby":">2.0.0-alpha","prismjs":"^1.15.0"},"homepage":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-prismjs#readme","keywords":["gatsby","gatsby-plugin","prismjs","remark"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-prismjs"},"scripts":{"build":"babel src --out-dir . --ignore **/__tests__","prepare":"cross-env NODE_ENV=production npm run build","watch":"babel -w src --out-dir . --ignore **/__tests__"},"gitHead":"cf39c4630bd2f8fbbf44dd55dd2910553221040f","readmeFilename":"README.md","readme":"# gatsby-remark-prismjs\n\nAdds syntax highlighting to code blocks in markdown files using\n[PrismJS](http://prismjs.com/).\n\n## Install\n\n`npm install --save gatsby-transformer-remark gatsby-remark-prismjs prismjs`\n\n## How to use\n\n```javascript\n// In your gatsby-config.js\nplugins: [\n  {\n    resolve: `gatsby-transformer-remark`,\n    options: {\n      plugins: [\n        {\n          resolve: `gatsby-remark-prismjs`,\n          options: {\n            // Class prefix for <pre> tags containing syntax highlighting;\n            // defaults to 'language-' (eg <pre class=\"language-js\">).\n            // If your site loads Prism into the browser at runtime,\n            // (eg for use with libraries like react-live),\n            // you may use this to prevent Prism from re-processing syntax.\n            // This is an uncommon use-case though;\n            // If you're unsure, it's best to use the default value.\n            classPrefix: \"language-\",\n            // This is used to allow setting a language for inline code\n            // (i.e. single backticks) by creating a separator.\n            // This separator is a string and will do no white-space\n            // stripping.\n            // A suggested value for English speakers is the non-ascii\n            // character '›'.\n            inlineCodeMarker: null,\n            // This lets you set up language aliases.  For example,\n            // setting this to '{ sh: \"bash\" }' will let you use\n            // the language \"sh\" which will highlight using the\n            // bash highlighter.\n            aliases: {},\n            // This toggles the display of line numbers alongside the code.\n            // To use it, add the following line in src/layouts/index.js\n            // right after importing the prism color scheme:\n            //  `require(\"prismjs/plugins/line-numbers/prism-line-numbers.css\");`\n            // Defaults to false.\n            showLineNumbers: false,\n          },\n        },\n      ],\n    },\n  },\n]\n```\n\n### Include CSS\n\n#### Required: Pick a PrismJS theme or create your own\n\nPrismJS ships with a number of [themes][5] (previewable on the [PrismJS\nwebsite][6]) that you can easily include in your Gatsby site, or you can build\nyour own by copying and modifying an example (which is what we've done for\n[gatsbyjs.org](https://gatsbyjs.org)).\n\nTo load a theme, just require its CSS file in your `gatsby-browser.js` file, e.g.\n\n```javascript\n// gatsby-browser.js\nrequire(\"prismjs/themes/prism-solarizedlight.css\")\n```\n\n#### Optional: Add line highlighting styles\n\nIf you want to highlight lines of code, you also need to add some additional CSS\nthat targets our _custom line highlighting implementation_ (which slightly\ndiffers from PrismJS's own plugin for that – more on that later).\n\nFor line highlights similar to PrismJS's, try:\n\n```css\n.gatsby-highlight-code-line {\n  background-color: #feb;\n  display: block;\n  margin-right: -1em;\n  margin-left: -1em;\n  padding-right: 1em;\n  padding-left: 0.75em;\n  border-left: 0.25em solid #f99;\n}\n```\n\nThis should work out quite nicely for the \"Solarized Light\" PrismJS theme we\njust added in the previous part. However, you will notice that when a\nhighlighted line runs wider than the surrounding code block container (causing a\nhorizontal scrollbar), its background won't be drawn for the initially hidden,\noverflowing part. :(\n\nWe saw others fix that problem and decided to do so, too. Just add the following\nCSS along your PrismJS theme and the styles for `.gatsby-highlight-code-line`:\n\n```css\n/**\n * Add back the container background-color, border-radius, padding, margin\n * and overflow that we removed from <pre>.\n */\n.gatsby-highlight {\n  background-color: #fdf6e3;\n  border-radius: 0.3em;\n  margin: 0.5em 0;\n  padding: 1em;\n  overflow: auto;\n}\n\n/**\n * Remove the default PrismJS theme background-color, border-radius, margin,\n * padding and overflow.\n * 1. Make the element just wide enough to fit its content.\n * 2. Always fill the visible space in .gatsby-highlight.\n * 3. Adjust the position of the line numbers\n */\n.gatsby-highlight pre[class*=\"language-\"] {\n  background-color: transparent;\n  margin: 0;\n  padding: 0;\n  overflow: initial;\n  float: left; /* 1 */\n  min-width: 100%; /* 2 */\n}\n.gatsby-highlight pre[class*=\"language-\"].line-numbers {\n  padding-left: 2.8em; /* 3 */\n}\n```\n\n#### Optional: Add line numbering\n\nIf you want to add line numbering alongside your code, you need to\nimport the corresponding CSS file from PrismJS, right after importing your\ncolorscheme in `layout/index.js`:\n\n```javascript\n// layouts/index.js\nrequire(\"prismjs/plugins/line-numbers/prism-line-numbers.css\")\n```\n\n### Usage in Markdown\n\nThis is some beautiful code:\n\n    ```javascript\n    // In your gatsby-config.js\n    plugins: [\n      {\n        resolve: `gatsby-transformer-remark`,\n        options: {\n          plugins: [\n            `gatsby-remark-prismjs`,\n          ]\n        }\n      }\n    ]\n    ```\n\nTo see the line numbers alongside your code, you can use the `numberLines` option:\n\n    ```javascript{numberLines: true}\n    // In your gatsby-config.js\n    plugins: [\n      {\n        resolve: `gatsby-transformer-remark`,\n        options: {\n          plugins: [\n            `gatsby-remark-prismjs`,\n          ]\n        }\n      }\n    ]\n    ```\n\nYou can also start numbering at any index you wish (here, numbering\nwill start at index 5):\n\n    ```javascript{numberLines: 5}\n    // In your gatsby-config.js\n    plugins: [\n      {\n        resolve: `gatsby-transformer-remark`,\n        options: {\n          plugins: [\n            `gatsby-remark-prismjs`,\n          ]\n        }\n      }\n    ]\n    ```\n\nYou can also add line highlighting. It adds a span around lines of code with a\nspecial class `.gatsby-highlight-code-line` that you can target with styles. See\nthis README for more info.\n\nIn the following code snippet, lines 1 and 4 through 6 will get the line\nhighlighting. The line range parsing is done with\n<https://www.npmjs.com/package/parse-numeric-range>.\n\n    ```javascript{1,4-6}\n    // In your gatsby-config.js\n    plugins: [\n      {\n        resolve: `gatsby-transformer-remark`,\n        options: {\n          plugins: [\n            `gatsby-remark-prismjs`,\n          ]\n        }\n      }\n    ]\n    ```\n\nIn addition to fenced code blocks, inline code blocks will be passed through\nPrismJS as well.\n\nIf you set the `inlineCodeMarker`, then you can also specify a format style.\n\nHere's an example of how to use this if the `inlineCodeMarker` was set to `±`:\n\n    I can highlight `css±.some-class { background-color: red }` with CSS syntax.\n\nThis will be rendered in a `<code class=language-css>` with just the (syntax\nhighlighted) text of `.some-class { background-color: red }`\n\nIf you need to prevent any escaping or highlighting, you can use the `none`\nlanguage; the inner contents will not be changed at all.\n\n## Implementation notes\n\n### Line highlighting\n\nPlease note that we do _not_ use PrismJS's\n[line highlighting plugin](http://prismjs.com/plugins/line-highlight/). Here's\nwhy:\n\n- [PrismJS plugins][3] assume you're running things client side, but we are\n  _build-time folks_.\n- PrismJS's line highlighting plugin [implementation][1] does not allow for\n  solid background colors or 100% wide backgrounds that are drawn beyond the\n  _visible part_ of the container when content is overflowing.\n\nOur approach follows the [Pygments-based][2] implementation of the [React\nTutorial/Documentation][4] for line highlights:\n\n- It uses a wrapper element `<div class=\"gatsby-highlight\">` around the\n  PrismJS-formatted `<pre><code>`-blocks.\n- Highlighted lines are wrapped in `<span class=\"gatsby-highlight-code-line\">`.\n- We insert a linebreak before the closing tag of `.gatsby-highlight-code-line`\n  so it ends up at the start of the following line.\n\nWith all of this in place, we can apply `float:left; min-width:100%` to `<pre>`,\nthrow our overflow and background on `.gatsby-highlight`, and use\n`display:block` on `.gatsby-highlight-code-line` – all of this coming together\nto facilitate the desired line highlight behavior.\n\n### Line numbering\n\nBecause [the line numbering PrismJS plugin][7] runs client-side, a few adaptations were required to make it work:\n\n- A class `.line-numbers` is dynamically added to the `<pre>` element.\n- A new node `<span class=\"line-numbers-rows\">` is added right before the closing `</pre>`\n  containing as many empty `<span>`s as there are lines.\n\nSee the [client-side PrismJS implementation][8] for reference.\n\n[1]: https://github.com/PrismJS/prism/tree/8eb0ab6f76484ca47fa7acbf77657fab17b03ca7/plugins/line-highlight\n[2]: https://github.com/facebook/react/blob/00ba97a354e841701b4b83983c3a3904895e7b87/docs/_config.yml#L10\n[3]: http://prismjs.com/#plugins\n[4]: https://facebook.github.io/react/tutorial/tutorial.html\n[5]: https://github.com/PrismJS/prism/tree/1d5047df37aacc900f8270b1c6215028f6988eb1/themes\n[6]: http://prismjs.com/\n[7]: https://prismjs.com/plugins/line-numbers/\n[8]: https://github.com/PrismJS/prism/blob/master/plugins/line-numbers/prism-line-numbers.js#L69-L115\n","licenseText":"The MIT License (MIT)\n\nCopyright (c) 2015 Gatsbyjs\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n","_id":"gatsby-remark-prismjs@3.0.0-rc.1","dist":{"shasum":"62bad97c0e5325e601ac735f258e0c68ef853dc5","tarball":"http://registry-npm.ywwl.com/gatsby-remark-prismjs/download/gatsby-remark-prismjs-3.0.0-rc.1.tgz","integrity":"sha512-fWcmOnjcK1iYaKtO04rF5TLRrRgcLUJ9sfrGr71Tv+L3ghc56zFnqkZTF6ZoIO8uUDerROGDjTcIFwMsDQ5uZw==","fileCount":13,"unpackedSize":30502,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbhtMCCRA9TVsSAnZWagAA9LIP/jtRf0ReRhPS2AZftx0t\nwC8Q3q7jcWHd5MlNHagO7Lh6tbcRohnqqu9DRBWbeLMlB27Hz8Vqgjeefws0\nb/D1qBzLRgRw7ljLbdueGHML8jYW2WmMDvu/wkKnEXkwBGNwy/C34j6qGGRz\nRs5zxzOhrIfoyXFZlniJ5aS0rwpBiY9ZujW3fP0TS38lrDw7v8//KGfpXE9e\niGnAQ1OmEKTafN1lRmPCrfhMqGk+Yqsm9M592L9ExcLJqVqyLb6OAk7whqEI\nKYgt+fd2b8TAIjs9RPW8uwIRHZkj84xLdBGkXmUQfxl3WMEss/t4R0g43zgt\nMAUltsqMJ6BITUmbWKEcnas5CwD7HzzMKxMbJYLZWmx8f5vu7aHfJ295OHMI\nLgNASItt5XzgXCdJTHF9IAyq9ZJJeljqv16acApmreV20QfLoGc4ZSD75SvZ\n9cL10Oj5hUVywlAz3ypCqMjVw/NrQP6Nfqlqgl4KHAFhvBGy9dnf4bstU0We\nWzBNc91skPOypuWOXAEcVGRvpKMhe6SjzZEs9vOpFBfyZ81f27IeTABMnRsx\n2WAKLvTxk6UFG4N3n0g+kFbt+PyRtlHrTLB+y+Wci05NPr0zD1eUVhPz3jJM\nq5qxuh8OGRqQf+8bD3fCgNEgYAc+afwMT0C7NqAGA3HAGzXCiYBqUlApMT/c\nK7He\r\n=ZCfC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGG4ziuE8DKOnER88GDcrbps2AWOt4p5Zxgy9fqL8jEXAiEAoz9PtHxC7Y+NpB3+On6MiJSy2HA6l8BVDmiTz9/DYug="}],"size":9846,"noattachment":false,"key":"/gatsby-remark-prismjs/-/gatsby-remark-prismjs-3.0.0-rc.1.tgz"},"maintainers":[{"email":"mathews.kyle@gmail.com","name":"kylemathews"},{"email":"michael.allanson@gmail.com","name":"m-allanson"},{"email":"monastic.panic@gmail.com","name":"monastic.panic"},{"email":"misiek.piechowiak@gmail.com","name":"pieh"}],"_npmUser":{"name":"m-allanson","email":"michael.allanson@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-remark-prismjs_3.0.0-rc.1_1535562497397_0.9306144901922233"},"_hasShrinkwrap":false,"publish_time":1535562497498,"_cnpm_publish_time":1535562497498,"dist-tags":{"alpha-9689ff":"6.23.0-alpha-9689ff.25","alpha-a5-peer":"6.23.0-alpha-a5-peer.70","alpha-qe-sm":"5.11.0-alpha-qe-sm.46","alpha-remark13":"4.0.0-alpha-remark13.167","alpha-transformer-json":"6.14.0-alpha-transformer-json.26","alpha-ts-jit":"6.6.0-alpha-ts-jit.60","alpha-v5":"7.0.0-alpha-v5.d20221012t101120.57","drupal-proxyurl":"7.0.0-alpha-drupal-proxyurl.14","drupal-self-reference":"6.18.0-alpha-drupal-self-reference.18","image-helpers":"3.8.0-image-helpers.58","image-service":"6.8.0-alpha-image-service.24","latest":"7.16.0","latest-v3":"5.12.0","latest-v4":"6.25.0","less-lmdb":"7.11.1-canary-less-lmdb.0","next":"7.17.0-next.0","otp-test":"3.3.10-otp-test.69","preview-gh-api":"6.23.0-alpha-preview-gh-api.26","react19":"7.17.0-react19.1","unifiedroutes":"3.4.3-unifiedroutes.76","v3rc":"4.0.0-v3rc.0","wp-image-cdn-auth":"6.15.0-alpha-wp-image-cdn-auth.48"}}