summaryrefslogtreecommitdiffstats
path: root/media/CodeMirror-0.62/contrib/python/index.html
blob: 31d2f0a0ac71a28673d1af4fed6c9ba130dbd45d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="../../js/codemirror.js" type="text/javascript"></script>
    <title>CodeMirror: Python demonstration</title>
    <style type="text/css">
      .CodeMirror-line-numbers {
        width: 2.2em;
        color: #aaa;
        background-color: #eee;
        text-align: right;
        padding: .4em;
        margin: 0;
        font-family: monospace;
        font-size: 10pt;
        line-height: 1.1em;
      }
    </style>
</head>
<body style="padding: 20px;">
<p>
    This is a simple demonstration of the Python syntax highlighting module
    for <a href="index.html">CodeMirror</a>.
</p>
<p>
    Features of this parser include:
</p>
<ul>
    <li>Token-based syntax highlighting - currently very little lexical analysis happens.  Few lexical errors will be detected.</li>
    <li>Use the normal indentation mode to enforce regular indentation, otherwise the "shift" indentation mode will give you more flexibility.</li>
    <li>Parser Options:
        <ul>
            <li>pythonVersion (Integer) - 2 or 3 to indicate which version of Python to parse.  Default = 2</li>
            <li>strictErrors (Bool) - true to highlight errors that may not be Python errors but cause confusion for this parser. Default = true</li>
        </ul>
    </li>
</ul>
<p>Written by Timothy Farrell (<a href="LICENSE">license</a>). Special
thanks to Adam Brand and Marijn Haverbeke for their help in debugging
and providing for this parser.</p>

<div style="border: 1px solid black; padding: 0px;">
<textarea id="code" cols="100" rows="20" style="width:100%">
# Literals
1234
0.0e101
.123
0b01010011100
0o01234567
0x0987654321abcdef
# Error Literals
.0b000
0.0e
0e

# String Literals
'For\''
"God\""
"""so loved
the world"""
'''that he gave
his only begotten\' '''
'that whosoever believeth \
in him'
''

# Identifiers
__a__
a.b
a.b.c
# Error Identifiers
a.

# Operators
+ - * / % & | ^ ~ < >
== != <= >= <> << >> // **
and or not in is

# Delimiters
() [] {} , : ` = ; @ . # At-signs and periods require context
+= -= *= /= %= &= |= ^=
//= >>= <<= **=

# Keywords
as assert break class continue def del elif else except
finally for from global if import lambda pass raise
return try while with yield

# Python 2 Keywords (otherwise Identifiers)
exec print

# Python 3 Keywords (otherwise Identifiers)
nonlocal

# Types
bool classmethod complex dict enumerate float frozenset int list object
property reversed set slice staticmethod str super tuple type

# Python 2 Types (otherwise Identifiers)
basestring buffer file long unicode xrange

# Python 3 Types (otherwise Identifiers)
bytearray bytes filter map memoryview open range zip

# Example Strict Errors
def doesNothing():
   pass # indentUnit is set to 4 but this line is indented 3

# Some Example code
import os
from package import ParentClass

@nonsenseDecorator
def doesNothing():
    pass

class ExampleClass(ParentClass):
    @staticmethod
    def example(inputStr):
        a = list(inputStr)
        a.reverse()
        return ''.join(a)

    def __init__(self, mixin = 'Hello'):
        self.mixin = mixin

</textarea>
</div>

<script type="text/javascript">
    var editor = CodeMirror.fromTextArea('code', {
        parserfile: ["../contrib/python/js/parsepython.js"],
        stylesheet: "css/pythoncolors.css",
        path: "../../js/",
        lineNumbers: true,
        textWrapping: false,
        indentUnit: 4,
        parserConfig: {'pythonVersion': 2, 'strictErrors': true}
    });
</script>
</body>
</html>