A JSX lexer for Pygments
Project description
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
Release history Release notifications | RSS feed
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.8.tar.gz
(9.5 kB
view details)
Built Distribution
File details
Details for the file jsx-lexer-0.0.8.tar.gz
.
File metadata
- Download URL: jsx-lexer-0.0.8.tar.gz
- Upload date:
- Size: 9.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb35102b78525aa3f587dc327f3208c0e1c76d5cdea64d4f9c3ced05d10c017 |
|
MD5 | 6ed80e3d8f7381899d2dbd963d62827d |
|
BLAKE2b-256 | 31075234876c88b9125922da122f7b1bf07a8db2b698f53812c3b577bdb99a4a |
File details
Details for the file jsx_lexer-0.0.8-py2.py3-none-any.whl
.
File metadata
- Download URL: jsx_lexer-0.0.8-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b879c7fafe974440a1dd9f9544dfb8629fa22078ada7f769c8fbb06149eac5d1 |
|
MD5 | 49ea075ad1dc015e0b5cca4426461f70 |
|
BLAKE2b-256 | 7524dc55e070a39a25aa5076cec1390c67a3e1469845907c45b8ec775f5bba59 |