{"name":"gatsby-remark-prismjs","description":"Adds syntax highlighting to code blocks at build time using PrismJS","version":"1.3.0-alpha.2b695217","author":{"name":"Kyle Mathews","email":"mathews.kyle@gmail.com"},"dependencies":{"@babel/runtime":"^7.0.0-beta.38","parse-numeric-range":"^0.0.2","prismjs":"^1.7.0","unist-util-visit":"^1.1.1"},"devDependencies":{"@babel/cli":"^7.0.0-beta.38","@babel/core":"^7.0.0-beta.38","cross-env":"^5.0.5","remark":"^7.0.1"},"keywords":["gatsby","gatsby-plugin","prismjs","remark"],"license":"MIT","main":"index.js","scripts":{"build":"babel src --out-dir . --ignore **/__tests__/**","watch":"babel -w src --out-dir . --ignore **/__tests__/**","prepublish":"cross-env NODE_ENV=production npm run build"},"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`\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          },\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 `layouts/index.js` file, e.g.\n\n```javascript\n// layouts/index.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\n    This 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\n    You can also add line highlighting. It adds a span around lines of\n    code with a special class `.gatsby-highlight-code-line` that you can\n    target with styles. See this readme for more info.\n\n    In the following code snippit, lines 1 and 4 through 6 will get\n    the line highlighting. 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\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","_id":"gatsby-remark-prismjs@1.3.0-alpha.2b695217","dist":{"shasum":"4e571c9b1b9adc958e742b85cfb6f7af6584c7fc","tarball":"http://registry-npm.ywwl.com/gatsby-remark-prismjs/download/gatsby-remark-prismjs-1.3.0-alpha.2b695217.tgz","fileCount":10,"unpackedSize":20883,"integrity":"sha512-18mFbZ5pRkA/27cC0ycOi1vVq6Tc10FetSdfnHMvedKJESkingwr9t51Btw+3t7wQ4m7k/ZkxxapqpEKFLo14w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE+U/lZsOFMIzzBYQJqD049EFBmdvY8MrHA9gaMinTKKAiEA/Qs/jwaTEWhT87dlxr6YeeyHETW7ZNuvveA4yD+dSjw="}],"size":6983,"noattachment":false,"key":"/gatsby-remark-prismjs/-/gatsby-remark-prismjs-1.3.0-alpha.2b695217.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.3.0-alpha.2b695217_1518302230817_0.16876876341848068"},"_hasShrinkwrap":false,"publish_time":1518302230862,"_cnpm_publish_time":1518302230862,"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"}}