1212 </ head >
1313 < body >
1414 < h1 > CodeMirror: Python mode</ h1 >
15-
15+ < h2 > Python mode </ h2 >
1616 < div > < textarea id ="code " name ="code ">
1717# Literals
18181234
@@ -102,6 +102,34 @@ <h1>CodeMirror: Python mode</h1>
102102 self.mixin = mixin
103103
104104</ textarea > </ div >
105+
106+
107+ < h2 > Cython mode</ h2 >
108+
109+ < div > < textarea id ="code-cython " name ="code-cython ">
110+
111+ import numpy as np
112+ cimport cython
113+ from libc.math cimport sqrt
114+
115+ @cython.boundscheck(False)
116+ @cython.wraparound(False)
117+ def pairwise_cython(double[:, ::1] X):
118+ cdef int M = X.shape[0]
119+ cdef int N = X.shape[1]
120+ cdef double tmp, d
121+ cdef double[:, ::1] D = np.empty((M, M), dtype=np.float64)
122+ for i in range(M):
123+ for j in range(M):
124+ d = 0.0
125+ for k in range(N):
126+ tmp = X[i, k] - X[j, k]
127+ d += tmp * tmp
128+ D[i, j] = sqrt(d)
129+ return np.asarray(D)
130+
131+ </ textarea > </ div >
132+
105133 < script >
106134 var editor = CodeMirror . fromTextArea ( document . getElementById ( "code" ) , {
107135 mode : { name : "python" ,
@@ -111,9 +139,19 @@ <h1>CodeMirror: Python mode</h1>
111139 indentUnit : 4 ,
112140 tabMode : "shift" ,
113141 matchBrackets : true
142+ } ) ;
143+
144+ CodeMirror . fromTextArea ( document . getElementById ( "code-cython" ) , {
145+ mode : { name : "text/x-cython" ,
146+ version : 2 ,
147+ singleLineStringErrors : false } ,
148+ lineNumbers : true ,
149+ indentUnit : 4 ,
150+ tabMode : "shift" ,
151+ matchBrackets : true
114152 } ) ;
115153 </ script >
116- < h2 > Configuration Options:</ h2 >
154+ < h2 > Configuration Options for Python mode :</ h2 >
117155 < ul >
118156 < li > version - 2/3 - The version of Python to recognize. Default is 2.</ li >
119157 < li > singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</ li >
@@ -127,9 +165,11 @@ <h2>Advanced Configuration Options:</h2>
127165 < li > doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : < pre > ^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))</ pre > </ li >
128166 < li > tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : < pre > ^((//=)|(>>=)|(<<=)|(\\*\\*=))</ pre > </ li >
129167 < li > identifiers - RegEx - Regular Expression for identifier, default : < pre > ^[_A-Za-z][_A-Za-z0-9]*</ pre > </ li >
168+ < li > extra_keywords - list of string - List of extra words ton consider as keywords</ li >
169+ < li > extra_builtins - list of string - List of extra words ton consider as builtins</ li >
130170 </ ul >
131171
132172
133- < p > < strong > MIME types defined:</ strong > < code > text/x-python</ code > .</ p >
173+ < p > < strong > MIME types defined:</ strong > < code > text/x-python</ code > and < code > text/x-cython </ code > .</ p >
134174 </ body >
135175</ html >
0 commit comments