{"name":"gatsby-remark-prismjs","description":"Adds syntax highlighting to code blocks at build time using PrismJS","version":"1.2.16-3","author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"bugs":{"url":"https://github.com/gatsbyjs/gatsby/issues"},"dependencies":{"@babel/runtime":"^7.0.0-beta.42","parse-numeric-range":"^0.0.2","prismjs":"^1.13.0","unist-util-visit":"^1.1.1"},"devDependencies":{"@babel/cli":"^7.0.0-beta.42","@babel/core":"^7.0.0-beta.42","cross-env":"^5.1.4","remark":"^9.0.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__","prepublish":"cross-env NODE_ENV=production npm run build","watch":"babel -w src --out-dir . --ignore __tests__"},"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          },\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 */\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```\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\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 follwing 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[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\n## Contributing Notes\n\nWe vendor the `prismjs` components file in `prism-language-dependencies.js`. We use the `prism-language-dependencies.js` file to tell `gatsby-remark-prismjs` which languages it can syntax highlight. Thus, when the `prismjs` library is updated, we need to update the our `prism-language-dependencies.js` file. To do this, we have created a script at `scripts/get-prism-language-dependencies.js`. To run this script:\n\n* Move into the `gatsby/packages/gatsby-remark-prismjs/scripts` dir\n\n  ```bash\n  cd gatsby/packages/gatsby-remark-prismjs/scripts\n  ```\n\n* Run the script\n\n  ```bash\n  node get-prism-language-dependencies.js\n  ```\n","_id":"gatsby-remark-prismjs@1.2.16-3","dist":{"shasum":"220c6046bd3c6450dfe2fd210625189458cc48b8","tarball":"http://registry-npm.ywwl.com/gatsby-remark-prismjs/download/gatsby-remark-prismjs-1.2.16-3.tgz","fileCount":8,"unpackedSize":23631,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa2+ttCRA9TVsSAnZWagAAoc8P/jhen3D4yKDcmJcP1vvT\nFS7gGz2uJ9vE4bnbQnKkoHK9tYInJ3/q0ZBBccfBmSEvkN3aWn7bS75xVHru\nzHgeH+xGzM3OQQVIerbocW8PZ1gWgL8Yh/VuW2tgLHQHsnY+cVWKM9g69YeC\nloDDVwE3SiI01IRBEs5XuxiZYc50/G6kwndw39eg33CCX1h/C9PxN/12Aq0Q\nhr7zmWPBlWVrAWz/ozen5kryyT01IM1RsulIS8rimXhtJCqdgp8jL5rrd0S2\n2DKnQwV2jJQ61cUamIPw1lmKdUpic7fFmQcDu+DwZdrRo55VEix8LAfuUyeu\nHQu+1yRVeINhA8vK855oOUEzfxdMBpwIsbl7sCk1h61o8CLdw3Gbr1ucyYwd\nmOK2Myuj93Bt1Tr4kGoNS9ctGwgOqkPsb30Bfq7i0rFneyb5+JEND/sw0kwr\n9SamThFNIho4d8ZrsO91UM37dyTTFyIoVH++uvhF5DZPYdrNuIvAX13eNnJh\nL3hwMzN1xsc+Vn8I2bRLmm1bu/yptY84jHrYmUODirrGzv907LSGZDIVYaDp\n8AKXZc5bwq8o7JxfMtLoPmqX93xrvAuUObf23ikZKXaha6H/v5B85HHeCB1H\nBy/8c1jfbk9P6BzEh7y9V9ksnghJ7aryMlDG7B4Y7TBzZlDdrvpRFuE7N4w3\n6Qte\r\n=KOlX\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-ECEKDg12vrTMhFr/1sdB9b6DHNQXDZiDA62YsybWfwX4pF2C2bMvvYgkhla6HpPwIPOAqjyLIDpV5EpaFwblyw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDov8FL5coX9FSDj4ltCyzbgPV7xHWdACPEu1gPUn5R+wIgASlKGjytyLzyS1uBl+p3nQr6XqDAkzf6WnfMu5aGXrk="}],"size":7549,"noattachment":false,"key":"/gatsby-remark-prismjs/-/gatsby-remark-prismjs-1.2.16-3.tgz"},"maintainers":[{"email":"mathews.kyle@gmail.com","name":"kylemathews"},{"email":"monastic.panic@gmail.com","name":"monastic.panic"}],"_npmUser":{"name":"kylemathews","email":"mathews.kyle@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gatsby-remark-prismjs_1.2.16-3_1524362093070_0.5558155420536168"},"_hasShrinkwrap":false,"publish_time":1524362093186,"_cnpm_publish_time":1524362093186,"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"}}