~ivle-dev/ivle/codemirror

« back to all changes in this revision

Viewing changes to ivle/webapp/filesystem/browser/media/codemirror/contrib/python/index.html

  • Committer: David Coles
  • Date: 2010-05-31 10:38:53 UTC
  • Revision ID: coles.david@gmail.com-20100531103853-8xypjpracvwy0qt4
Editor: Added CodeMirror-0.67 Javascript code editor source from 
http://marijn.haverbeke.nl/codemirror/ (zlib-style licence)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html xmlns="http://www.w3.org/1999/xhtml">
 
2
<head>
 
3
    <script src="../../js/codemirror.js" type="text/javascript"></script>
 
4
    <title>CodeMirror: Python demonstration</title>
 
5
    <style type="text/css">
 
6
      .CodeMirror-line-numbers {
 
7
        width: 2.2em;
 
8
        color: #aaa;
 
9
        background-color: #eee;
 
10
        text-align: right;
 
11
        padding: .4em;
 
12
        margin: 0;
 
13
        font-family: monospace;
 
14
        font-size: 10pt;
 
15
        line-height: 1.1em;
 
16
      }
 
17
    </style>
 
18
</head>
 
19
<body style="padding: 20px;">
 
20
<p>
 
21
    This is a simple demonstration of the Python syntax highlighting module
 
22
    for <a href="index.html">CodeMirror</a>.
 
23
</p>
 
24
<p>
 
25
    Features of this parser include:
 
26
</p>
 
27
<ul>
 
28
    <li>Token-based syntax highlighting - currently very little lexical analysis happens.  Few lexical errors will be detected.</li>
 
29
    <li>Use the normal indentation mode to enforce regular indentation, otherwise the "shift" indentation mode will give you more flexibility.</li>
 
30
    <li>Parser Options:
 
31
        <ul>
 
32
            <li>pythonVersion (Integer) - 2 or 3 to indicate which version of Python to parse.  Default = 2</li>
 
33
            <li>strictErrors (Bool) - true to highlight errors that may not be Python errors but cause confusion for this parser. Default = true</li>
 
34
        </ul>
 
35
    </li>
 
36
</ul>
 
37
<p>Written by Timothy Farrell (<a href="LICENSE">license</a>). Special
 
38
thanks to Adam Brand and Marijn Haverbeke for their help in debugging
 
39
and providing for this parser.</p>
 
40
 
 
41
<div style="border: 1px solid black; padding: 0px;">
 
42
<textarea id="code" cols="100" rows="20" style="width:100%">
 
43
# Literals
 
44
1234
 
45
0.0e101
 
46
.123
 
47
0b01010011100
 
48
0o01234567
 
49
0x0987654321abcdef
 
50
# Error Literals
 
51
.0b000
 
52
0.0e
 
53
0e
 
54
 
 
55
# String Literals
 
56
'For\''
 
57
"God\""
 
58
"""so loved
 
59
the world"""
 
60
'''that he gave
 
61
his only begotten\' '''
 
62
'that whosoever believeth \
 
63
in him'
 
64
''
 
65
 
 
66
# Identifiers
 
67
__a__
 
68
a.b
 
69
a.b.c
 
70
# Error Identifiers
 
71
a.
 
72
 
 
73
# Operators
 
74
+ - * / % & | ^ ~ < >
 
75
== != <= >= <> << >> // **
 
76
and or not in is
 
77
 
 
78
# Delimiters
 
79
() [] {} , : ` = ; @ . # At-signs and periods require context
 
80
+= -= *= /= %= &= |= ^=
 
81
//= >>= <<= **=
 
82
 
 
83
# Keywords
 
84
as assert break class continue def del elif else except
 
85
finally for from global if import lambda pass raise
 
86
return try while with yield
 
87
 
 
88
# Python 2 Keywords (otherwise Identifiers)
 
89
exec print
 
90
 
 
91
# Python 3 Keywords (otherwise Identifiers)
 
92
nonlocal
 
93
 
 
94
# Types
 
95
bool classmethod complex dict enumerate float frozenset int list object
 
96
property reversed set slice staticmethod str super tuple type
 
97
 
 
98
# Python 2 Types (otherwise Identifiers)
 
99
basestring buffer file long unicode xrange
 
100
 
 
101
# Python 3 Types (otherwise Identifiers)
 
102
bytearray bytes filter map memoryview open range zip
 
103
 
 
104
# Example Strict Errors
 
105
def doesNothing():
 
106
   pass # indentUnit is set to 4 but this line is indented 3
 
107
 
 
108
# Some Example code
 
109
import os
 
110
from package import ParentClass
 
111
 
 
112
@nonsenseDecorator
 
113
def doesNothing():
 
114
    pass
 
115
 
 
116
class ExampleClass(ParentClass):
 
117
    @staticmethod
 
118
    def example(inputStr):
 
119
        a = list(inputStr)
 
120
        a.reverse()
 
121
        return ''.join(a)
 
122
 
 
123
    def __init__(self, mixin = 'Hello'):
 
124
        self.mixin = mixin
 
125
 
 
126
</textarea>
 
127
</div>
 
128
 
 
129
<script type="text/javascript">
 
130
    var editor = CodeMirror.fromTextArea('code', {
 
131
        parserfile: ["../contrib/python/js/parsepython.js"],
 
132
        stylesheet: "css/pythoncolors.css",
 
133
        path: "../../js/",
 
134
        lineNumbers: true,
 
135
        textWrapping: false,
 
136
        indentUnit: 4,
 
137
        parserConfig: {'pythonVersion': 2, 'strictErrors': true}
 
138
    });
 
139
</script>
 
140
</body>
 
141
</html>