Skip to main content

A JSX lexer for Pygments

Project description

https://travis-ci.org/fcurella/jsx-lexer.svg?branch=master https://coveralls.io/repos/github/fcurella/jsx-lexer/badge.svg?branch=master

A JSX lexer for Pygments

Installation

$ pip install jsx-lexer

Usage with Sphinx

To use within Sphinx, simply specify jsx for your code-block:

.. code-block:: jsx

    const BlogTitle = ({ children }) => (
      <h3>{children}</h3>
    );
    // class component
    class BlogPost extends React.Component {
      renderTitle(title) {
        return <BlogTitle>{title}</BlogTitle>
      };
      render() {
        return (
        <div className="blog-body">
          {this.renderTitle(this.props.title)}
          <p>{this.props.body}</p>
        </div>
        );
      }
    }

Usage with mkdocs

First, you need to create the CSS for the highlighting:

$ pygmentize -S default -f html -a .codehilite > code/pygments.css

Then, add the following to your mkdocs.yml:

markdown_extensions:
  - codehilite
extra_css: [pygments.css]

Now, you can use jsx in your code blocks:

```jsx
const BlogTitle = ({ children }) => (
  <h3>{children}</h3>
);
// class component
class BlogPost extends React.Component {
  renderTitle(title) {
    return <BlogTitle>{title}</BlogTitle>
  };
  render() {
    return (
    <div className="blog-body">
      {this.renderTitle(this.props.title)}
      <p>{this.props.body}</p>
    </div>
    );
  }
}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsx-lexer-0.0.7.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

jsx_lexer-0.0.7-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file jsx-lexer-0.0.7.tar.gz.

File metadata

  • Download URL: jsx-lexer-0.0.7.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.4

File hashes

Hashes for jsx-lexer-0.0.7.tar.gz
Algorithm Hash digest
SHA256 80a107c08e5eb18188fc43b222859702bc83d5ed534bf63e1df6f2f77cc66e19
MD5 8212c88ae676fdd73f8006e72f3e9d7a
BLAKE2b-256 eec5a250bb2e6d88ea53691601d02afbdc9017296cc2017db9858aaf27a49d79

See more details on using hashes here.

File details

Details for the file jsx_lexer-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: jsx_lexer-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.6.4

File hashes

Hashes for jsx_lexer-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b1245cc02870376822fe8cc8e910810337ab6211425cf0089de504bf9da2afc6
MD5 1ceb9ef0172b0b38921d38da9c91dc90
BLAKE2b-256 9e0c4362a09d72c80443ca774548c38e0afe0abd434f471a9d83107da4b49781

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page