2
0

index.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CodeMirror: Python mode</title>
  6. <link rel="stylesheet" href="../../lib/codemirror.css">
  7. <script src="../../lib/codemirror.js"></script>
  8. <script src="../../addon/edit/matchbrackets.js"></script>
  9. <script src="python.js"></script>
  10. <link rel="stylesheet" href="../../doc/docs.css">
  11. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  12. </head>
  13. <body>
  14. <h1>CodeMirror: Python mode</h1>
  15. <div><textarea id="code" name="code">
  16. # Literals
  17. 1234
  18. 0.0e101
  19. .123
  20. 0b01010011100
  21. 0o01234567
  22. 0x0987654321abcdef
  23. 7
  24. 2147483647
  25. 3L
  26. 79228162514264337593543950336L
  27. 0x100000000L
  28. 79228162514264337593543950336
  29. 0xdeadbeef
  30. 3.14j
  31. 10.j
  32. 10j
  33. .001j
  34. 1e100j
  35. 3.14e-10j
  36. # String Literals
  37. 'For\''
  38. "God\""
  39. """so loved
  40. the world"""
  41. '''that he gave
  42. his only begotten\' '''
  43. 'that whosoever believeth \
  44. in him'
  45. ''
  46. # Identifiers
  47. __a__
  48. a.b
  49. a.b.c
  50. # Operators
  51. + - * / % & | ^ ~ < >
  52. == != <= >= <> << >> // **
  53. and or not in is
  54. # Delimiters
  55. () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
  56. += -= *= /= %= &= |= ^=
  57. //= >>= <<= **=
  58. # Keywords
  59. as assert break class continue def del elif else except
  60. finally for from global if import lambda pass raise
  61. return try while with yield
  62. # Python 2 Keywords (otherwise Identifiers)
  63. exec print
  64. # Python 3 Keywords (otherwise Identifiers)
  65. nonlocal
  66. # Types
  67. bool classmethod complex dict enumerate float frozenset int list object
  68. property reversed set slice staticmethod str super tuple type
  69. # Python 2 Types (otherwise Identifiers)
  70. basestring buffer file long unicode xrange
  71. # Python 3 Types (otherwise Identifiers)
  72. bytearray bytes filter map memoryview open range zip
  73. # Some Example code
  74. import os
  75. from package import ParentClass
  76. @nonsenseDecorator
  77. def doesNothing():
  78. pass
  79. class ExampleClass(ParentClass):
  80. @staticmethod
  81. def example(inputStr):
  82. a = list(inputStr)
  83. a.reverse()
  84. return ''.join(a)
  85. def __init__(self, mixin = 'Hello'):
  86. self.mixin = mixin
  87. </textarea></div>
  88. <script>
  89. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  90. mode: {name: "python",
  91. version: 2,
  92. singleLineStringErrors: false},
  93. lineNumbers: true,
  94. indentUnit: 4,
  95. tabMode: "shift",
  96. matchBrackets: true
  97. });
  98. </script>
  99. <h2>Configuration Options:</h2>
  100. <ul>
  101. <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
  102. <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>
  103. </ul>
  104. <h2>Advanced Configuration Options:</h2>
  105. <p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
  106. <ul>
  107. <li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
  108. <li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
  109. <li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
  110. <li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
  111. <li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
  112. <li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
  113. </ul>
  114. <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
  115. </body>
  116. </html>