1
<html xmlns="http://www.w3.org/1999/xhtml">
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 {
9
background-color: #eee;
13
font-family: monospace;
19
<body style="padding: 20px;">
21
This is a simple demonstration of the Python syntax highlighting module
22
for <a href="index.html">CodeMirror</a>.
25
Features of this parser include:
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>
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>
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>
41
<div style="border: 1px solid black; padding: 0px;">
42
<textarea id="code" cols="100" rows="20" style="width:100%">
61
his only begotten\' '''
62
'that whosoever believeth \
75
== != <= >= <> << >> // **
79
() [] {} , : ` = ; @ . # At-signs and periods require context
80
+= -= *= /= %= &= |= ^=
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
88
# Python 2 Keywords (otherwise Identifiers)
91
# Python 3 Keywords (otherwise Identifiers)
95
bool classmethod complex dict enumerate float frozenset int list object
96
property reversed set slice staticmethod str super tuple type
98
# Python 2 Types (otherwise Identifiers)
99
basestring buffer file long unicode xrange
101
# Python 3 Types (otherwise Identifiers)
102
bytearray bytes filter map memoryview open range zip
104
# Example Strict Errors
106
pass # indentUnit is set to 4 but this line is indented 3
110
from package import ParentClass
116
class ExampleClass(ParentClass):
118
def example(inputStr):
123
def __init__(self, mixin = 'Hello'):
129
<script type="text/javascript">
130
var editor = CodeMirror.fromTextArea('code', {
131
parserfile: ["../contrib/python/js/parsepython.js"],
132
stylesheet: "css/pythoncolors.css",
137
parserConfig: {'pythonVersion': 2, 'strictErrors': true}