GitXplorerGitXplorer
M

gatsby-remark-codemirror

public
0 stars
2 forks
3 issues

Commits

List of commits on branch main.
Verified
1a0bc3b0bcfc04fd0071fc440d23e279fd69f9d5

Bump minimist from 1.2.5 to 1.2.6 (#18)

ddependabot[bot] committed 3 years ago
Verified
3fcf935b8abe17ec17115da15be732abb10ad194

Update Node.js dependencies

MMaxDesiatov committed 3 years ago
Unverified
4f41acb2177b428ec7376a44cdc2b8fbb27044f6

Update `package-lock.json`

MMaxDesiatov committed 3 years ago
Verified
b95314b3dcd229a03d53b481452e9725e0f6bfa1

Bump tmpl from 1.0.4 to 1.0.5 (#17)

ddependabot[bot] committed 3 years ago
Verified
601458f4af1466a61f3f201d38c3b82a12649df1

Bump path-parse from 1.0.6 to 1.0.7 (#16)

ddependabot[bot] committed 3 years ago
Verified
70352ed41a9965042e0b3cf5b270afdf43526381

Bump ws from 7.3.1 to 7.4.6 (#15)

ddependabot[bot] committed 4 years ago

README

The README file for this repository.

gatsby-remark-codemirror

Adds syntax highlighting to code blocks in your Gatsby Markdown files using CodeMirror Mode Runner. Note that this Remark plugin does not convert your code blocks to code editor instances, only uses CodeMirror's syntax highlighting engine to render static <code><pre>...</code></pre> blocks with appropriate CSS classes for <span/> tags contained within.

Install

npm install --save gatsby-transformer-remark gatsby-remark-codemirror

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-transformer-remark`,
    options: {
      plugins: [
        {
          resolve: `gatsby-remark-codemirror`,
          options: {
            // CSS class suffix to be used for produced `<pre/>` blocks.
            // Default value is "default", which adds "cm-s-default" class.
            // This class name matches
            theme: "default"
          }
        }
      ]
    }
  }
];

Include CSS

Required: Pick a CodeMirror theme or create your own

CodeMirror ships with a number of themes (previewable on the CodeMirror website) that you can easily include in your Gatsby site, or you can build your own by copying and modifying an example.

To load a theme, just require its CSS file in your gatsby-browser.js file, e.g.

// gatsby-browser.js
require("codemirror/lib/codemirror.css");

or for a non-default theme:

// gatsby-browser.js
require("codemirror/theme/ambiance.css");
// don't forget to set `theme: "ambiance"` in gatsby-config.js

Usage in Markdown

This is some beautiful code:

```swift
extension Never: Equatable {
  public static func == (lhs: Never, rhs: Never) -> Bool {
    switch (lhs, rhs) {
    }
  }
}

extension Never: Hashable {
  public func hash(into hasher: inout Hasher) {
  }
}
```