• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

jsx/H26-Apr-2019-6149

tests/H26-Apr-2019-575536

.bumpversion.cfgH A D26-Apr-2019185 118

.coveragercH A D26-Apr-201984 96

.gitignoreH A D26-Apr-201984 109

.travis.ymlH A D26-Apr-2019268 2120

LICENSEH A D26-Apr-20191 KiB1916

MakefileH A D26-Apr-2019132 86

README.rstH A D26-Apr-20191.8 KiB8162

setup.pyH A D26-Apr-2019952 3732

README.rst

1jsx-lexer
2=========
3
4.. image:: https://travis-ci.org/fcurella/jsx-lexer.svg?branch=master
5    :target: https://travis-ci.org/fcurella/jsx-lexer
6
7.. image:: https://coveralls.io/repos/github/fcurella/jsx-lexer/badge.svg?branch=master
8    :target: https://coveralls.io/github/fcurella/jsx-lexer?branch=master
9
10A JSX lexer for Pygments
11
12Installation
13------------
14.. code-block:: sh
15
16    $ pip install jsx-lexer
17
18Usage with Sphinx
19-----------------
20
21To use within Sphinx, simply specify ``jsx`` for your ``code-block``::
22
23    .. code-block:: jsx
24
25        const BlogTitle = ({ children }) => (
26          <h3>{children}</h3>
27        );
28        // class component
29        class BlogPost extends React.Component {
30          renderTitle(title) {
31            return <BlogTitle>{title}</BlogTitle>
32          };
33          render() {
34            return (
35            <div className="blog-body">
36              {this.renderTitle(this.props.title)}
37              <p>{this.props.body}</p>
38            </div>
39            );
40          }
41        }
42
43Usage with mkdocs
44-----------------
45
46First, you need to create the ``CSS`` for the highlighting:
47
48.. code-block:: bash
49
50  $ pygmentize -S default -f html -a .codehilite > code/pygments.css
51
52Then, add the following to your ``mkdocs.yml``:
53
54.. code-block:: yaml
55
56  markdown_extensions:
57    - codehilite
58  extra_css: [pygments.css]
59
60Now, you can use ``jsx`` in your code blocks::
61
62    ```jsx
63    const BlogTitle = ({ children }) => (
64      <h3>{children}</h3>
65    );
66    // class component
67    class BlogPost extends React.Component {
68      renderTitle(title) {
69        return <BlogTitle>{title}</BlogTitle>
70      };
71      render() {
72        return (
73        <div className="blog-body">
74          {this.renderTitle(this.props.title)}
75          <p>{this.props.body}</p>
76        </div>
77        );
78      }
79    }
80    ```
81