fluentd-ui 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd-ui might be problematic. Click here for more details.

Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +4 -0
  3. data/Gemfile.lock +1 -1
  4. data/app/assets/javascripts/application.js +2 -0
  5. data/app/assets/javascripts/codemirror.js +29 -0
  6. data/app/assets/javascripts/codemirror_fluentd.js +59 -0
  7. data/app/assets/stylesheets/application.css +6 -0
  8. data/app/views/fluentd/settings/edit.html.haml +1 -1
  9. data/app/views/shared/vue/_setting.html.erb +1 -1
  10. data/bower.json +2 -1
  11. data/lib/fluentd-ui/version.rb +1 -1
  12. data/spec/features/source_and_output_spec.rb +16 -6
  13. data/vendor/assets/javascripts/bower/codemirror/.bower.json +29 -0
  14. data/vendor/assets/javascripts/bower/codemirror/AUTHORS +423 -0
  15. data/vendor/assets/javascripts/bower/codemirror/CONTRIBUTING.md +76 -0
  16. data/vendor/assets/javascripts/bower/codemirror/LICENSE +19 -0
  17. data/vendor/assets/javascripts/bower/codemirror/README.md +11 -0
  18. data/vendor/assets/javascripts/bower/codemirror/addon/comment/comment.js +183 -0
  19. data/vendor/assets/javascripts/bower/codemirror/addon/comment/continuecomment.js +85 -0
  20. data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.css +32 -0
  21. data/vendor/assets/javascripts/bower/codemirror/addon/dialog/dialog.js +155 -0
  22. data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.css +6 -0
  23. data/vendor/assets/javascripts/bower/codemirror/addon/display/fullscreen.js +41 -0
  24. data/vendor/assets/javascripts/bower/codemirror/addon/display/panel.js +94 -0
  25. data/vendor/assets/javascripts/bower/codemirror/addon/display/placeholder.js +58 -0
  26. data/vendor/assets/javascripts/bower/codemirror/addon/display/rulers.js +64 -0
  27. data/vendor/assets/javascripts/bower/codemirror/addon/edit/closebrackets.js +159 -0
  28. data/vendor/assets/javascripts/bower/codemirror/addon/edit/closetag.js +159 -0
  29. data/vendor/assets/javascripts/bower/codemirror/addon/edit/continuelist.js +51 -0
  30. data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchbrackets.js +120 -0
  31. data/vendor/assets/javascripts/bower/codemirror/addon/edit/matchtags.js +66 -0
  32. data/vendor/assets/javascripts/bower/codemirror/addon/edit/trailingspace.js +27 -0
  33. data/vendor/assets/javascripts/bower/codemirror/addon/fold/brace-fold.js +105 -0
  34. data/vendor/assets/javascripts/bower/codemirror/addon/fold/comment-fold.js +57 -0
  35. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldcode.js +145 -0
  36. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.css +20 -0
  37. data/vendor/assets/javascripts/bower/codemirror/addon/fold/foldgutter.js +134 -0
  38. data/vendor/assets/javascripts/bower/codemirror/addon/fold/indent-fold.js +44 -0
  39. data/vendor/assets/javascripts/bower/codemirror/addon/fold/markdown-fold.js +49 -0
  40. data/vendor/assets/javascripts/bower/codemirror/addon/fold/xml-fold.js +182 -0
  41. data/vendor/assets/javascripts/bower/codemirror/addon/hint/anyword-hint.js +41 -0
  42. data/vendor/assets/javascripts/bower/codemirror/addon/hint/css-hint.js +56 -0
  43. data/vendor/assets/javascripts/bower/codemirror/addon/hint/html-hint.js +348 -0
  44. data/vendor/assets/javascripts/bower/codemirror/addon/hint/javascript-hint.js +146 -0
  45. data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.css +38 -0
  46. data/vendor/assets/javascripts/bower/codemirror/addon/hint/show-hint.js +389 -0
  47. data/vendor/assets/javascripts/bower/codemirror/addon/hint/sql-hint.js +197 -0
  48. data/vendor/assets/javascripts/bower/codemirror/addon/hint/xml-hint.js +110 -0
  49. data/vendor/assets/javascripts/bower/codemirror/addon/lint/coffeescript-lint.js +41 -0
  50. data/vendor/assets/javascripts/bower/codemirror/addon/lint/css-lint.js +35 -0
  51. data/vendor/assets/javascripts/bower/codemirror/addon/lint/javascript-lint.js +136 -0
  52. data/vendor/assets/javascripts/bower/codemirror/addon/lint/json-lint.js +31 -0
  53. data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.css +73 -0
  54. data/vendor/assets/javascripts/bower/codemirror/addon/lint/lint.js +204 -0
  55. data/vendor/assets/javascripts/bower/codemirror/addon/lint/yaml-lint.js +28 -0
  56. data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.css +112 -0
  57. data/vendor/assets/javascripts/bower/codemirror/addon/merge/merge.js +643 -0
  58. data/vendor/assets/javascripts/bower/codemirror/addon/mode/loadmode.js +64 -0
  59. data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex.js +118 -0
  60. data/vendor/assets/javascripts/bower/codemirror/addon/mode/multiplex_test.js +33 -0
  61. data/vendor/assets/javascripts/bower/codemirror/addon/mode/overlay.js +85 -0
  62. data/vendor/assets/javascripts/bower/codemirror/addon/mode/simple.js +213 -0
  63. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/colorize.js +40 -0
  64. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode-standalone.js +157 -0
  65. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.js +72 -0
  66. data/vendor/assets/javascripts/bower/codemirror/addon/runmode/runmode.node.js +120 -0
  67. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/annotatescrollbar.js +76 -0
  68. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/scrollpastend.js +46 -0
  69. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.css +66 -0
  70. data/vendor/assets/javascripts/bower/codemirror/addon/scroll/simplescrollbars.js +139 -0
  71. data/vendor/assets/javascripts/bower/codemirror/addon/search/match-highlighter.js +128 -0
  72. data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.css +8 -0
  73. data/vendor/assets/javascripts/bower/codemirror/addon/search/matchesonscrollbar.js +90 -0
  74. data/vendor/assets/javascripts/bower/codemirror/addon/search/search.js +164 -0
  75. data/vendor/assets/javascripts/bower/codemirror/addon/search/searchcursor.js +189 -0
  76. data/vendor/assets/javascripts/bower/codemirror/addon/selection/active-line.js +71 -0
  77. data/vendor/assets/javascripts/bower/codemirror/addon/selection/mark-selection.js +118 -0
  78. data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.css +86 -0
  79. data/vendor/assets/javascripts/bower/codemirror/addon/tern/tern.js +670 -0
  80. data/vendor/assets/javascripts/bower/codemirror/addon/tern/worker.js +44 -0
  81. data/vendor/assets/javascripts/bower/codemirror/addon/wrap/hardwrap.js +139 -0
  82. data/vendor/assets/javascripts/bower/codemirror/bower.json +16 -0
  83. data/vendor/assets/javascripts/bower/codemirror/keymap/emacs.js +411 -0
  84. data/vendor/assets/javascripts/bower/codemirror/keymap/sublime.js +540 -0
  85. data/vendor/assets/javascripts/bower/codemirror/keymap/vim.js +4901 -0
  86. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +309 -0
  87. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +8029 -0
  88. data/vendor/assets/javascripts/bower/codemirror/mode/apl/apl.js +175 -0
  89. data/vendor/assets/javascripts/bower/codemirror/mode/asterisk/asterisk.js +198 -0
  90. data/vendor/assets/javascripts/bower/codemirror/mode/clike/clike.js +489 -0
  91. data/vendor/assets/javascripts/bower/codemirror/mode/clike/scala.html +767 -0
  92. data/vendor/assets/javascripts/bower/codemirror/mode/clojure/clojure.js +243 -0
  93. data/vendor/assets/javascripts/bower/codemirror/mode/cobol/cobol.js +255 -0
  94. data/vendor/assets/javascripts/bower/codemirror/mode/coffeescript/coffeescript.js +369 -0
  95. data/vendor/assets/javascripts/bower/codemirror/mode/commonlisp/commonlisp.js +122 -0
  96. data/vendor/assets/javascripts/bower/codemirror/mode/css/css.js +717 -0
  97. data/vendor/assets/javascripts/bower/codemirror/mode/css/less.html +152 -0
  98. data/vendor/assets/javascripts/bower/codemirror/mode/css/less_test.js +51 -0
  99. data/vendor/assets/javascripts/bower/codemirror/mode/css/scss.html +157 -0
  100. data/vendor/assets/javascripts/bower/codemirror/mode/css/scss_test.js +110 -0
  101. data/vendor/assets/javascripts/bower/codemirror/mode/css/test.js +135 -0
  102. data/vendor/assets/javascripts/bower/codemirror/mode/cypher/cypher.js +146 -0
  103. data/vendor/assets/javascripts/bower/codemirror/mode/d/d.js +218 -0
  104. data/vendor/assets/javascripts/bower/codemirror/mode/dart/dart.js +50 -0
  105. data/vendor/assets/javascripts/bower/codemirror/mode/diff/diff.js +47 -0
  106. data/vendor/assets/javascripts/bower/codemirror/mode/django/django.js +67 -0
  107. data/vendor/assets/javascripts/bower/codemirror/mode/dockerfile/dockerfile.js +76 -0
  108. data/vendor/assets/javascripts/bower/codemirror/mode/dtd/dtd.js +142 -0
  109. data/vendor/assets/javascripts/bower/codemirror/mode/dylan/dylan.js +299 -0
  110. data/vendor/assets/javascripts/bower/codemirror/mode/ebnf/ebnf.js +195 -0
  111. data/vendor/assets/javascripts/bower/codemirror/mode/ecl/ecl.js +207 -0
  112. data/vendor/assets/javascripts/bower/codemirror/mode/eiffel/eiffel.js +162 -0
  113. data/vendor/assets/javascripts/bower/codemirror/mode/erlang/erlang.js +622 -0
  114. data/vendor/assets/javascripts/bower/codemirror/mode/fortran/fortran.js +188 -0
  115. data/vendor/assets/javascripts/bower/codemirror/mode/gas/gas.js +345 -0
  116. data/vendor/assets/javascripts/bower/codemirror/mode/gfm/gfm.js +123 -0
  117. data/vendor/assets/javascripts/bower/codemirror/mode/gfm/test.js +213 -0
  118. data/vendor/assets/javascripts/bower/codemirror/mode/gherkin/gherkin.js +178 -0
  119. data/vendor/assets/javascripts/bower/codemirror/mode/go/go.js +184 -0
  120. data/vendor/assets/javascripts/bower/codemirror/mode/groovy/groovy.js +226 -0
  121. data/vendor/assets/javascripts/bower/codemirror/mode/haml/haml.js +159 -0
  122. data/vendor/assets/javascripts/bower/codemirror/mode/haml/test.js +97 -0
  123. data/vendor/assets/javascripts/bower/codemirror/mode/haskell/haskell.js +267 -0
  124. data/vendor/assets/javascripts/bower/codemirror/mode/haxe/haxe.js +518 -0
  125. data/vendor/assets/javascripts/bower/codemirror/mode/htmlembedded/htmlembedded.js +86 -0
  126. data/vendor/assets/javascripts/bower/codemirror/mode/htmlmixed/htmlmixed.js +121 -0
  127. data/vendor/assets/javascripts/bower/codemirror/mode/http/http.js +113 -0
  128. data/vendor/assets/javascripts/bower/codemirror/mode/idl/idl.js +290 -0
  129. data/vendor/assets/javascripts/bower/codemirror/mode/jade/jade.js +590 -0
  130. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/javascript.js +686 -0
  131. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/json-ld.html +72 -0
  132. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/test.js +200 -0
  133. data/vendor/assets/javascripts/bower/codemirror/mode/javascript/typescript.html +61 -0
  134. data/vendor/assets/javascripts/bower/codemirror/mode/jinja2/jinja2.js +142 -0
  135. data/vendor/assets/javascripts/bower/codemirror/mode/julia/julia.js +301 -0
  136. data/vendor/assets/javascripts/bower/codemirror/mode/kotlin/kotlin.js +280 -0
  137. data/vendor/assets/javascripts/bower/codemirror/mode/livescript/livescript.js +280 -0
  138. data/vendor/assets/javascripts/bower/codemirror/mode/lua/lua.js +159 -0
  139. data/vendor/assets/javascripts/bower/codemirror/mode/markdown/markdown.js +765 -0
  140. data/vendor/assets/javascripts/bower/codemirror/mode/markdown/test.js +754 -0
  141. data/vendor/assets/javascripts/bower/codemirror/mode/meta.js +165 -0
  142. data/vendor/assets/javascripts/bower/codemirror/mode/mirc/mirc.js +193 -0
  143. data/vendor/assets/javascripts/bower/codemirror/mode/mllike/mllike.js +205 -0
  144. data/vendor/assets/javascripts/bower/codemirror/mode/modelica/modelica.js +245 -0
  145. data/vendor/assets/javascripts/bower/codemirror/mode/nginx/nginx.js +178 -0
  146. data/vendor/assets/javascripts/bower/codemirror/mode/ntriples/ntriples.js +186 -0
  147. data/vendor/assets/javascripts/bower/codemirror/mode/octave/octave.js +135 -0
  148. data/vendor/assets/javascripts/bower/codemirror/mode/pascal/pascal.js +109 -0
  149. data/vendor/assets/javascripts/bower/codemirror/mode/pegjs/pegjs.js +114 -0
  150. data/vendor/assets/javascripts/bower/codemirror/mode/perl/perl.js +832 -0
  151. data/vendor/assets/javascripts/bower/codemirror/mode/php/php.js +226 -0
  152. data/vendor/assets/javascripts/bower/codemirror/mode/php/test.js +154 -0
  153. data/vendor/assets/javascripts/bower/codemirror/mode/pig/pig.js +188 -0
  154. data/vendor/assets/javascripts/bower/codemirror/mode/properties/properties.js +78 -0
  155. data/vendor/assets/javascripts/bower/codemirror/mode/puppet/puppet.js +220 -0
  156. data/vendor/assets/javascripts/bower/codemirror/mode/python/python.js +359 -0
  157. data/vendor/assets/javascripts/bower/codemirror/mode/q/q.js +139 -0
  158. data/vendor/assets/javascripts/bower/codemirror/mode/r/r.js +162 -0
  159. data/vendor/assets/javascripts/bower/codemirror/mode/rpm/rpm.js +101 -0
  160. data/vendor/assets/javascripts/bower/codemirror/mode/rst/rst.js +557 -0
  161. data/vendor/assets/javascripts/bower/codemirror/mode/ruby/ruby.js +285 -0
  162. data/vendor/assets/javascripts/bower/codemirror/mode/ruby/test.js +14 -0
  163. data/vendor/assets/javascripts/bower/codemirror/mode/rust/rust.js +451 -0
  164. data/vendor/assets/javascripts/bower/codemirror/mode/sass/sass.js +327 -0
  165. data/vendor/assets/javascripts/bower/codemirror/mode/scheme/scheme.js +248 -0
  166. data/vendor/assets/javascripts/bower/codemirror/mode/shell/shell.js +139 -0
  167. data/vendor/assets/javascripts/bower/codemirror/mode/shell/test.js +58 -0
  168. data/vendor/assets/javascripts/bower/codemirror/mode/sieve/sieve.js +193 -0
  169. data/vendor/assets/javascripts/bower/codemirror/mode/slim/slim.js +575 -0
  170. data/vendor/assets/javascripts/bower/codemirror/mode/slim/test.js +96 -0
  171. data/vendor/assets/javascripts/bower/codemirror/mode/smalltalk/smalltalk.js +168 -0
  172. data/vendor/assets/javascripts/bower/codemirror/mode/smarty/smarty.js +221 -0
  173. data/vendor/assets/javascripts/bower/codemirror/mode/smartymixed/smartymixed.js +197 -0
  174. data/vendor/assets/javascripts/bower/codemirror/mode/solr/solr.js +104 -0
  175. data/vendor/assets/javascripts/bower/codemirror/mode/soy/soy.js +198 -0
  176. data/vendor/assets/javascripts/bower/codemirror/mode/sparql/sparql.js +174 -0
  177. data/vendor/assets/javascripts/bower/codemirror/mode/spreadsheet/spreadsheet.js +109 -0
  178. data/vendor/assets/javascripts/bower/codemirror/mode/sql/sql.js +391 -0
  179. data/vendor/assets/javascripts/bower/codemirror/mode/stex/stex.js +251 -0
  180. data/vendor/assets/javascripts/bower/codemirror/mode/stex/test.js +123 -0
  181. data/vendor/assets/javascripts/bower/codemirror/mode/tcl/tcl.js +147 -0
  182. data/vendor/assets/javascripts/bower/codemirror/mode/textile/test.js +417 -0
  183. data/vendor/assets/javascripts/bower/codemirror/mode/textile/textile.js +469 -0
  184. data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  185. data/vendor/assets/javascripts/bower/codemirror/mode/tiddlywiki/tiddlywiki.js +369 -0
  186. data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.css +26 -0
  187. data/vendor/assets/javascripts/bower/codemirror/mode/tiki/tiki.js +323 -0
  188. data/vendor/assets/javascripts/bower/codemirror/mode/toml/toml.js +88 -0
  189. data/vendor/assets/javascripts/bower/codemirror/mode/tornado/tornado.js +68 -0
  190. data/vendor/assets/javascripts/bower/codemirror/mode/turtle/turtle.js +162 -0
  191. data/vendor/assets/javascripts/bower/codemirror/mode/vb/vb.js +274 -0
  192. data/vendor/assets/javascripts/bower/codemirror/mode/vbscript/vbscript.js +350 -0
  193. data/vendor/assets/javascripts/bower/codemirror/mode/velocity/velocity.js +201 -0
  194. data/vendor/assets/javascripts/bower/codemirror/mode/verilog/test.js +273 -0
  195. data/vendor/assets/javascripts/bower/codemirror/mode/verilog/verilog.js +364 -0
  196. data/vendor/assets/javascripts/bower/codemirror/mode/xml/test.js +51 -0
  197. data/vendor/assets/javascripts/bower/codemirror/mode/xml/xml.js +384 -0
  198. data/vendor/assets/javascripts/bower/codemirror/mode/xquery/test.js +67 -0
  199. data/vendor/assets/javascripts/bower/codemirror/mode/xquery/xquery.js +447 -0
  200. data/vendor/assets/javascripts/bower/codemirror/mode/yaml/yaml.js +117 -0
  201. data/vendor/assets/javascripts/bower/codemirror/mode/z80/z80.js +100 -0
  202. data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +38 -0
  203. data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +37 -0
  204. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +5 -0
  205. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +77 -0
  206. data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +36 -0
  207. data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +36 -0
  208. data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +30 -0
  209. data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +23 -0
  210. data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +23 -0
  211. data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +13 -0
  212. data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +32 -0
  213. data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +45 -0
  214. data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +35 -0
  215. data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +44 -0
  216. data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +45 -0
  217. data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +31 -0
  218. data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +12 -0
  219. data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +43 -0
  220. data/vendor/assets/javascripts/bower/codemirror/theme/night.css +26 -0
  221. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +36 -0
  222. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +36 -0
  223. data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +50 -0
  224. data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +23 -0
  225. data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +165 -0
  226. data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +28 -0
  227. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +35 -0
  228. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +36 -0
  229. data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +30 -0
  230. data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +32 -0
  231. data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +51 -0
  232. data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +43 -0
  233. data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +37 -0
  234. metadata +225 -2
@@ -0,0 +1,280 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ /**
5
+ * Link to the project's GitHub page:
6
+ * https://github.com/duralog/CodeMirror
7
+ */
8
+
9
+ (function(mod) {
10
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
11
+ mod(require("../../lib/codemirror"));
12
+ else if (typeof define == "function" && define.amd) // AMD
13
+ define(["../../lib/codemirror"], mod);
14
+ else // Plain browser env
15
+ mod(CodeMirror);
16
+ })(function(CodeMirror) {
17
+ "use strict";
18
+
19
+ CodeMirror.defineMode('livescript', function(){
20
+ var tokenBase = function(stream, state) {
21
+ var next_rule = state.next || "start";
22
+ if (next_rule) {
23
+ state.next = state.next;
24
+ var nr = Rules[next_rule];
25
+ if (nr.splice) {
26
+ for (var i$ = 0; i$ < nr.length; ++i$) {
27
+ var r = nr[i$], m;
28
+ if (r.regex && (m = stream.match(r.regex))) {
29
+ state.next = r.next || state.next;
30
+ return r.token;
31
+ }
32
+ }
33
+ stream.next();
34
+ return 'error';
35
+ }
36
+ if (stream.match(r = Rules[next_rule])) {
37
+ if (r.regex && stream.match(r.regex)) {
38
+ state.next = r.next;
39
+ return r.token;
40
+ } else {
41
+ stream.next();
42
+ return 'error';
43
+ }
44
+ }
45
+ }
46
+ stream.next();
47
+ return 'error';
48
+ };
49
+ var external = {
50
+ startState: function(){
51
+ return {
52
+ next: 'start',
53
+ lastToken: null
54
+ };
55
+ },
56
+ token: function(stream, state){
57
+ while (stream.pos == stream.start)
58
+ var style = tokenBase(stream, state);
59
+ state.lastToken = {
60
+ style: style,
61
+ indent: stream.indentation(),
62
+ content: stream.current()
63
+ };
64
+ return style.replace(/\./g, ' ');
65
+ },
66
+ indent: function(state){
67
+ var indentation = state.lastToken.indent;
68
+ if (state.lastToken.content.match(indenter)) {
69
+ indentation += 2;
70
+ }
71
+ return indentation;
72
+ }
73
+ };
74
+ return external;
75
+ });
76
+
77
+ var identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
78
+ var indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
79
+ var keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
80
+ var stringfill = {
81
+ token: 'string',
82
+ regex: '.+'
83
+ };
84
+ var Rules = {
85
+ start: [
86
+ {
87
+ token: 'comment.doc',
88
+ regex: '/\\*',
89
+ next: 'comment'
90
+ }, {
91
+ token: 'comment',
92
+ regex: '#.*'
93
+ }, {
94
+ token: 'keyword',
95
+ regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
96
+ }, {
97
+ token: 'constant.language',
98
+ regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
99
+ }, {
100
+ token: 'invalid.illegal',
101
+ regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
102
+ }, {
103
+ token: 'language.support.class',
104
+ regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
105
+ }, {
106
+ token: 'language.support.function',
107
+ regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
108
+ }, {
109
+ token: 'variable.language',
110
+ regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
111
+ }, {
112
+ token: 'identifier',
113
+ regex: identifier + '\\s*:(?![:=])'
114
+ }, {
115
+ token: 'variable',
116
+ regex: identifier
117
+ }, {
118
+ token: 'keyword.operator',
119
+ regex: '(?:\\.{3}|\\s+\\?)'
120
+ }, {
121
+ token: 'keyword.variable',
122
+ regex: '(?:@+|::|\\.\\.)',
123
+ next: 'key'
124
+ }, {
125
+ token: 'keyword.operator',
126
+ regex: '\\.\\s*',
127
+ next: 'key'
128
+ }, {
129
+ token: 'string',
130
+ regex: '\\\\\\S[^\\s,;)}\\]]*'
131
+ }, {
132
+ token: 'string.doc',
133
+ regex: '\'\'\'',
134
+ next: 'qdoc'
135
+ }, {
136
+ token: 'string.doc',
137
+ regex: '"""',
138
+ next: 'qqdoc'
139
+ }, {
140
+ token: 'string',
141
+ regex: '\'',
142
+ next: 'qstring'
143
+ }, {
144
+ token: 'string',
145
+ regex: '"',
146
+ next: 'qqstring'
147
+ }, {
148
+ token: 'string',
149
+ regex: '`',
150
+ next: 'js'
151
+ }, {
152
+ token: 'string',
153
+ regex: '<\\[',
154
+ next: 'words'
155
+ }, {
156
+ token: 'string.regex',
157
+ regex: '//',
158
+ next: 'heregex'
159
+ }, {
160
+ token: 'string.regex',
161
+ regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
162
+ next: 'key'
163
+ }, {
164
+ token: 'constant.numeric',
165
+ regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
166
+ }, {
167
+ token: 'lparen',
168
+ regex: '[({[]'
169
+ }, {
170
+ token: 'rparen',
171
+ regex: '[)}\\]]',
172
+ next: 'key'
173
+ }, {
174
+ token: 'keyword.operator',
175
+ regex: '\\S+'
176
+ }, {
177
+ token: 'text',
178
+ regex: '\\s+'
179
+ }
180
+ ],
181
+ heregex: [
182
+ {
183
+ token: 'string.regex',
184
+ regex: '.*?//[gimy$?]{0,4}',
185
+ next: 'start'
186
+ }, {
187
+ token: 'string.regex',
188
+ regex: '\\s*#{'
189
+ }, {
190
+ token: 'comment.regex',
191
+ regex: '\\s+(?:#.*)?'
192
+ }, {
193
+ token: 'string.regex',
194
+ regex: '\\S+'
195
+ }
196
+ ],
197
+ key: [
198
+ {
199
+ token: 'keyword.operator',
200
+ regex: '[.?@!]+'
201
+ }, {
202
+ token: 'identifier',
203
+ regex: identifier,
204
+ next: 'start'
205
+ }, {
206
+ token: 'text',
207
+ regex: '',
208
+ next: 'start'
209
+ }
210
+ ],
211
+ comment: [
212
+ {
213
+ token: 'comment.doc',
214
+ regex: '.*?\\*/',
215
+ next: 'start'
216
+ }, {
217
+ token: 'comment.doc',
218
+ regex: '.+'
219
+ }
220
+ ],
221
+ qdoc: [
222
+ {
223
+ token: 'string',
224
+ regex: ".*?'''",
225
+ next: 'key'
226
+ }, stringfill
227
+ ],
228
+ qqdoc: [
229
+ {
230
+ token: 'string',
231
+ regex: '.*?"""',
232
+ next: 'key'
233
+ }, stringfill
234
+ ],
235
+ qstring: [
236
+ {
237
+ token: 'string',
238
+ regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
239
+ next: 'key'
240
+ }, stringfill
241
+ ],
242
+ qqstring: [
243
+ {
244
+ token: 'string',
245
+ regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
246
+ next: 'key'
247
+ }, stringfill
248
+ ],
249
+ js: [
250
+ {
251
+ token: 'string',
252
+ regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
253
+ next: 'key'
254
+ }, stringfill
255
+ ],
256
+ words: [
257
+ {
258
+ token: 'string',
259
+ regex: '.*?\\]>',
260
+ next: 'key'
261
+ }, stringfill
262
+ ]
263
+ };
264
+ for (var idx in Rules) {
265
+ var r = Rules[idx];
266
+ if (r.splice) {
267
+ for (var i = 0, len = r.length; i < len; ++i) {
268
+ var rr = r[i];
269
+ if (typeof rr.regex === 'string') {
270
+ Rules[idx][i].regex = new RegExp('^' + rr.regex);
271
+ }
272
+ }
273
+ } else if (typeof rr.regex === 'string') {
274
+ Rules[idx].regex = new RegExp('^' + r.regex);
275
+ }
276
+ }
277
+
278
+ CodeMirror.defineMIME('text/x-livescript', 'livescript');
279
+
280
+ });
@@ -0,0 +1,159 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ // LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
5
+ // CodeMirror 1 mode.
6
+ // highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
7
+
8
+ (function(mod) {
9
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
10
+ mod(require("../../lib/codemirror"));
11
+ else if (typeof define == "function" && define.amd) // AMD
12
+ define(["../../lib/codemirror"], mod);
13
+ else // Plain browser env
14
+ mod(CodeMirror);
15
+ })(function(CodeMirror) {
16
+ "use strict";
17
+
18
+ CodeMirror.defineMode("lua", function(config, parserConfig) {
19
+ var indentUnit = config.indentUnit;
20
+
21
+ function prefixRE(words) {
22
+ return new RegExp("^(?:" + words.join("|") + ")", "i");
23
+ }
24
+ function wordRE(words) {
25
+ return new RegExp("^(?:" + words.join("|") + ")$", "i");
26
+ }
27
+ var specials = wordRE(parserConfig.specials || []);
28
+
29
+ // long list of standard functions from lua manual
30
+ var builtins = wordRE([
31
+ "_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load",
32
+ "loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require",
33
+ "select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall",
34
+
35
+ "coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
36
+
37
+ "debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable",
38
+ "debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable",
39
+ "debug.setupvalue","debug.traceback",
40
+
41
+ "close","flush","lines","read","seek","setvbuf","write",
42
+
43
+ "io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin",
44
+ "io.stdout","io.tmpfile","io.type","io.write",
45
+
46
+ "math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg",
47
+ "math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max",
48
+ "math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh",
49
+ "math.sqrt","math.tan","math.tanh",
50
+
51
+ "os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale",
52
+ "os.time","os.tmpname",
53
+
54
+ "package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload",
55
+ "package.seeall",
56
+
57
+ "string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub",
58
+ "string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",
59
+
60
+ "table.concat","table.insert","table.maxn","table.remove","table.sort"
61
+ ]);
62
+ var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
63
+ "true","function", "end", "if", "then", "else", "do",
64
+ "while", "repeat", "until", "for", "in", "local" ]);
65
+
66
+ var indentTokens = wordRE(["function", "if","repeat","do", "\\(", "{"]);
67
+ var dedentTokens = wordRE(["end", "until", "\\)", "}"]);
68
+ var dedentPartial = prefixRE(["end", "until", "\\)", "}", "else", "elseif"]);
69
+
70
+ function readBracket(stream) {
71
+ var level = 0;
72
+ while (stream.eat("=")) ++level;
73
+ stream.eat("[");
74
+ return level;
75
+ }
76
+
77
+ function normal(stream, state) {
78
+ var ch = stream.next();
79
+ if (ch == "-" && stream.eat("-")) {
80
+ if (stream.eat("[") && stream.eat("["))
81
+ return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state);
82
+ stream.skipToEnd();
83
+ return "comment";
84
+ }
85
+ if (ch == "\"" || ch == "'")
86
+ return (state.cur = string(ch))(stream, state);
87
+ if (ch == "[" && /[\[=]/.test(stream.peek()))
88
+ return (state.cur = bracketed(readBracket(stream), "string"))(stream, state);
89
+ if (/\d/.test(ch)) {
90
+ stream.eatWhile(/[\w.%]/);
91
+ return "number";
92
+ }
93
+ if (/[\w_]/.test(ch)) {
94
+ stream.eatWhile(/[\w\\\-_.]/);
95
+ return "variable";
96
+ }
97
+ return null;
98
+ }
99
+
100
+ function bracketed(level, style) {
101
+ return function(stream, state) {
102
+ var curlev = null, ch;
103
+ while ((ch = stream.next()) != null) {
104
+ if (curlev == null) {if (ch == "]") curlev = 0;}
105
+ else if (ch == "=") ++curlev;
106
+ else if (ch == "]" && curlev == level) { state.cur = normal; break; }
107
+ else curlev = null;
108
+ }
109
+ return style;
110
+ };
111
+ }
112
+
113
+ function string(quote) {
114
+ return function(stream, state) {
115
+ var escaped = false, ch;
116
+ while ((ch = stream.next()) != null) {
117
+ if (ch == quote && !escaped) break;
118
+ escaped = !escaped && ch == "\\";
119
+ }
120
+ if (!escaped) state.cur = normal;
121
+ return "string";
122
+ };
123
+ }
124
+
125
+ return {
126
+ startState: function(basecol) {
127
+ return {basecol: basecol || 0, indentDepth: 0, cur: normal};
128
+ },
129
+
130
+ token: function(stream, state) {
131
+ if (stream.eatSpace()) return null;
132
+ var style = state.cur(stream, state);
133
+ var word = stream.current();
134
+ if (style == "variable") {
135
+ if (keywords.test(word)) style = "keyword";
136
+ else if (builtins.test(word)) style = "builtin";
137
+ else if (specials.test(word)) style = "variable-2";
138
+ }
139
+ if ((style != "comment") && (style != "string")){
140
+ if (indentTokens.test(word)) ++state.indentDepth;
141
+ else if (dedentTokens.test(word)) --state.indentDepth;
142
+ }
143
+ return style;
144
+ },
145
+
146
+ indent: function(state, textAfter) {
147
+ var closing = dedentPartial.test(textAfter);
148
+ return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0));
149
+ },
150
+
151
+ lineComment: "--",
152
+ blockCommentStart: "--[[",
153
+ blockCommentEnd: "]]"
154
+ };
155
+ });
156
+
157
+ CodeMirror.defineMIME("text/x-lua", "lua");
158
+
159
+ });
@@ -0,0 +1,765 @@
1
+ // CodeMirror, copyright (c) by Marijn Haverbeke and others
2
+ // Distributed under an MIT license: http://codemirror.net/LICENSE
3
+
4
+ (function(mod) {
5
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
6
+ mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta"));
7
+ else if (typeof define == "function" && define.amd) // AMD
8
+ define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
9
+ else // Plain browser env
10
+ mod(CodeMirror);
11
+ })(function(CodeMirror) {
12
+ "use strict";
13
+
14
+ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
15
+
16
+ var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
17
+ var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
18
+
19
+ function getMode(name) {
20
+ if (CodeMirror.findModeByName) {
21
+ var found = CodeMirror.findModeByName(name);
22
+ if (found) name = found.mime || found.mimes[0];
23
+ }
24
+ var mode = CodeMirror.getMode(cmCfg, name);
25
+ return mode.name == "null" ? null : mode;
26
+ }
27
+
28
+ // Should characters that affect highlighting be highlighted separate?
29
+ // Does not include characters that will be output (such as `1.` and `-` for lists)
30
+ if (modeCfg.highlightFormatting === undefined)
31
+ modeCfg.highlightFormatting = false;
32
+
33
+ // Maximum number of nested blockquotes. Set to 0 for infinite nesting.
34
+ // Excess `>` will emit `error` token.
35
+ if (modeCfg.maxBlockquoteDepth === undefined)
36
+ modeCfg.maxBlockquoteDepth = 0;
37
+
38
+ // Should underscores in words open/close em/strong?
39
+ if (modeCfg.underscoresBreakWords === undefined)
40
+ modeCfg.underscoresBreakWords = true;
41
+
42
+ // Turn on fenced code blocks? ("```" to start/end)
43
+ if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
44
+
45
+ // Turn on task lists? ("- [ ] " and "- [x] ")
46
+ if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
47
+
48
+ // Turn on strikethrough syntax
49
+ if (modeCfg.strikethrough === undefined)
50
+ modeCfg.strikethrough = false;
51
+
52
+ var codeDepth = 0;
53
+
54
+ var header = 'header'
55
+ , code = 'comment'
56
+ , quote = 'quote'
57
+ , list1 = 'variable-2'
58
+ , list2 = 'variable-3'
59
+ , list3 = 'keyword'
60
+ , hr = 'hr'
61
+ , image = 'tag'
62
+ , formatting = 'formatting'
63
+ , linkinline = 'link'
64
+ , linkemail = 'link'
65
+ , linktext = 'link'
66
+ , linkhref = 'string'
67
+ , em = 'em'
68
+ , strong = 'strong'
69
+ , strikethrough = 'strikethrough';
70
+
71
+ var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
72
+ , ulRE = /^[*\-+]\s+/
73
+ , olRE = /^[0-9]+\.\s+/
74
+ , taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
75
+ , atxHeaderRE = /^#+/
76
+ , setextHeaderRE = /^(?:\={1,}|-{1,})$/
77
+ , textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
78
+
79
+ function switchInline(stream, state, f) {
80
+ state.f = state.inline = f;
81
+ return f(stream, state);
82
+ }
83
+
84
+ function switchBlock(stream, state, f) {
85
+ state.f = state.block = f;
86
+ return f(stream, state);
87
+ }
88
+
89
+
90
+ // Blocks
91
+
92
+ function blankLine(state) {
93
+ // Reset linkTitle state
94
+ state.linkTitle = false;
95
+ // Reset EM state
96
+ state.em = false;
97
+ // Reset STRONG state
98
+ state.strong = false;
99
+ // Reset strikethrough state
100
+ state.strikethrough = false;
101
+ // Reset state.quote
102
+ state.quote = 0;
103
+ if (!htmlFound && state.f == htmlBlock) {
104
+ state.f = inlineNormal;
105
+ state.block = blockNormal;
106
+ }
107
+ // Reset state.trailingSpace
108
+ state.trailingSpace = 0;
109
+ state.trailingSpaceNewLine = false;
110
+ // Mark this line as blank
111
+ state.thisLineHasContent = false;
112
+ return null;
113
+ }
114
+
115
+ function blockNormal(stream, state) {
116
+
117
+ var sol = stream.sol();
118
+
119
+ var prevLineIsList = (state.list !== false);
120
+ if (state.list !== false && state.indentationDiff >= 0) { // Continued list
121
+ if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
122
+ state.indentation -= state.indentationDiff;
123
+ }
124
+ state.list = null;
125
+ } else if (state.list !== false && state.indentation > 0) {
126
+ state.list = null;
127
+ state.listDepth = Math.floor(state.indentation / 4);
128
+ } else if (state.list !== false) { // No longer a list
129
+ state.list = false;
130
+ state.listDepth = 0;
131
+ }
132
+
133
+ var match = null;
134
+ if (state.indentationDiff >= 4) {
135
+ state.indentation -= 4;
136
+ stream.skipToEnd();
137
+ return code;
138
+ } else if (stream.eatSpace()) {
139
+ return null;
140
+ } else if (match = stream.match(atxHeaderRE)) {
141
+ state.header = match[0].length <= 6 ? match[0].length : 6;
142
+ if (modeCfg.highlightFormatting) state.formatting = "header";
143
+ state.f = state.inline;
144
+ return getType(state);
145
+ } else if (state.prevLineHasContent && (match = stream.match(setextHeaderRE))) {
146
+ state.header = match[0].charAt(0) == '=' ? 1 : 2;
147
+ if (modeCfg.highlightFormatting) state.formatting = "header";
148
+ state.f = state.inline;
149
+ return getType(state);
150
+ } else if (stream.eat('>')) {
151
+ state.indentation++;
152
+ state.quote = sol ? 1 : state.quote + 1;
153
+ if (modeCfg.highlightFormatting) state.formatting = "quote";
154
+ stream.eatSpace();
155
+ return getType(state);
156
+ } else if (stream.peek() === '[') {
157
+ return switchInline(stream, state, footnoteLink);
158
+ } else if (stream.match(hrRE, true)) {
159
+ return hr;
160
+ } else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
161
+ var listType = null;
162
+ if (stream.match(ulRE, true)) {
163
+ listType = 'ul';
164
+ } else {
165
+ stream.match(olRE, true);
166
+ listType = 'ol';
167
+ }
168
+ state.indentation += 4;
169
+ state.list = true;
170
+ state.listDepth++;
171
+ if (modeCfg.taskLists && stream.match(taskListRE, false)) {
172
+ state.taskList = true;
173
+ }
174
+ state.f = state.inline;
175
+ if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
176
+ return getType(state);
177
+ } else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
178
+ // try switching mode
179
+ state.localMode = getMode(RegExp.$1);
180
+ if (state.localMode) state.localState = state.localMode.startState();
181
+ state.f = state.block = local;
182
+ if (modeCfg.highlightFormatting) state.formatting = "code-block";
183
+ state.code = true;
184
+ return getType(state);
185
+ }
186
+
187
+ return switchInline(stream, state, state.inline);
188
+ }
189
+
190
+ function htmlBlock(stream, state) {
191
+ var style = htmlMode.token(stream, state.htmlState);
192
+ if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
193
+ (state.md_inside && stream.current().indexOf(">") > -1)) {
194
+ state.f = inlineNormal;
195
+ state.block = blockNormal;
196
+ state.htmlState = null;
197
+ }
198
+ return style;
199
+ }
200
+
201
+ function local(stream, state) {
202
+ if (stream.sol() && stream.match("```", false)) {
203
+ state.localMode = state.localState = null;
204
+ state.f = state.block = leavingLocal;
205
+ return null;
206
+ } else if (state.localMode) {
207
+ return state.localMode.token(stream, state.localState);
208
+ } else {
209
+ stream.skipToEnd();
210
+ return code;
211
+ }
212
+ }
213
+
214
+ function leavingLocal(stream, state) {
215
+ stream.match("```");
216
+ state.block = blockNormal;
217
+ state.f = inlineNormal;
218
+ if (modeCfg.highlightFormatting) state.formatting = "code-block";
219
+ state.code = true;
220
+ var returnType = getType(state);
221
+ state.code = false;
222
+ return returnType;
223
+ }
224
+
225
+ // Inline
226
+ function getType(state) {
227
+ var styles = [];
228
+
229
+ if (state.formatting) {
230
+ styles.push(formatting);
231
+
232
+ if (typeof state.formatting === "string") state.formatting = [state.formatting];
233
+
234
+ for (var i = 0; i < state.formatting.length; i++) {
235
+ styles.push(formatting + "-" + state.formatting[i]);
236
+
237
+ if (state.formatting[i] === "header") {
238
+ styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
239
+ }
240
+
241
+ // Add `formatting-quote` and `formatting-quote-#` for blockquotes
242
+ // Add `error` instead if the maximum blockquote nesting depth is passed
243
+ if (state.formatting[i] === "quote") {
244
+ if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
245
+ styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
246
+ } else {
247
+ styles.push("error");
248
+ }
249
+ }
250
+ }
251
+ }
252
+
253
+ if (state.taskOpen) {
254
+ styles.push("meta");
255
+ return styles.length ? styles.join(' ') : null;
256
+ }
257
+ if (state.taskClosed) {
258
+ styles.push("property");
259
+ return styles.length ? styles.join(' ') : null;
260
+ }
261
+
262
+ if (state.linkHref) {
263
+ styles.push(linkhref);
264
+ return styles.length ? styles.join(' ') : null;
265
+ }
266
+
267
+ if (state.strong) { styles.push(strong); }
268
+ if (state.em) { styles.push(em); }
269
+ if (state.strikethrough) { styles.push(strikethrough); }
270
+
271
+ if (state.linkText) { styles.push(linktext); }
272
+
273
+ if (state.code) { styles.push(code); }
274
+
275
+ if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
276
+
277
+ if (state.quote) {
278
+ styles.push(quote);
279
+
280
+ // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
281
+ if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
282
+ styles.push(quote + "-" + state.quote);
283
+ } else {
284
+ styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
285
+ }
286
+ }
287
+
288
+ if (state.list !== false) {
289
+ var listMod = (state.listDepth - 1) % 3;
290
+ if (!listMod) {
291
+ styles.push(list1);
292
+ } else if (listMod === 1) {
293
+ styles.push(list2);
294
+ } else {
295
+ styles.push(list3);
296
+ }
297
+ }
298
+
299
+ if (state.trailingSpaceNewLine) {
300
+ styles.push("trailing-space-new-line");
301
+ } else if (state.trailingSpace) {
302
+ styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
303
+ }
304
+
305
+ return styles.length ? styles.join(' ') : null;
306
+ }
307
+
308
+ function handleText(stream, state) {
309
+ if (stream.match(textRE, true)) {
310
+ return getType(state);
311
+ }
312
+ return undefined;
313
+ }
314
+
315
+ function inlineNormal(stream, state) {
316
+ var style = state.text(stream, state);
317
+ if (typeof style !== 'undefined')
318
+ return style;
319
+
320
+ if (state.list) { // List marker (*, +, -, 1., etc)
321
+ state.list = null;
322
+ return getType(state);
323
+ }
324
+
325
+ if (state.taskList) {
326
+ var taskOpen = stream.match(taskListRE, true)[1] !== "x";
327
+ if (taskOpen) state.taskOpen = true;
328
+ else state.taskClosed = true;
329
+ if (modeCfg.highlightFormatting) state.formatting = "task";
330
+ state.taskList = false;
331
+ return getType(state);
332
+ }
333
+
334
+ state.taskOpen = false;
335
+ state.taskClosed = false;
336
+
337
+ if (state.header && stream.match(/^#+$/, true)) {
338
+ if (modeCfg.highlightFormatting) state.formatting = "header";
339
+ return getType(state);
340
+ }
341
+
342
+ // Get sol() value now, before character is consumed
343
+ var sol = stream.sol();
344
+
345
+ var ch = stream.next();
346
+
347
+ if (ch === '\\') {
348
+ stream.next();
349
+ if (modeCfg.highlightFormatting) {
350
+ var type = getType(state);
351
+ return type ? type + " formatting-escape" : "formatting-escape";
352
+ }
353
+ }
354
+
355
+ // Matches link titles present on next line
356
+ if (state.linkTitle) {
357
+ state.linkTitle = false;
358
+ var matchCh = ch;
359
+ if (ch === '(') {
360
+ matchCh = ')';
361
+ }
362
+ matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
363
+ var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
364
+ if (stream.match(new RegExp(regex), true)) {
365
+ return linkhref;
366
+ }
367
+ }
368
+
369
+ // If this block is changed, it may need to be updated in GFM mode
370
+ if (ch === '`') {
371
+ var previousFormatting = state.formatting;
372
+ if (modeCfg.highlightFormatting) state.formatting = "code";
373
+ var t = getType(state);
374
+ var before = stream.pos;
375
+ stream.eatWhile('`');
376
+ var difference = 1 + stream.pos - before;
377
+ if (!state.code) {
378
+ codeDepth = difference;
379
+ state.code = true;
380
+ return getType(state);
381
+ } else {
382
+ if (difference === codeDepth) { // Must be exact
383
+ state.code = false;
384
+ return t;
385
+ }
386
+ state.formatting = previousFormatting;
387
+ return getType(state);
388
+ }
389
+ } else if (state.code) {
390
+ return getType(state);
391
+ }
392
+
393
+ if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
394
+ stream.match(/\[[^\]]*\]/);
395
+ state.inline = state.f = linkHref;
396
+ return image;
397
+ }
398
+
399
+ if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
400
+ state.linkText = true;
401
+ if (modeCfg.highlightFormatting) state.formatting = "link";
402
+ return getType(state);
403
+ }
404
+
405
+ if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
406
+ if (modeCfg.highlightFormatting) state.formatting = "link";
407
+ var type = getType(state);
408
+ state.linkText = false;
409
+ state.inline = state.f = linkHref;
410
+ return type;
411
+ }
412
+
413
+ if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
414
+ state.f = state.inline = linkInline;
415
+ if (modeCfg.highlightFormatting) state.formatting = "link";
416
+ var type = getType(state);
417
+ if (type){
418
+ type += " ";
419
+ } else {
420
+ type = "";
421
+ }
422
+ return type + linkinline;
423
+ }
424
+
425
+ if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
426
+ state.f = state.inline = linkInline;
427
+ if (modeCfg.highlightFormatting) state.formatting = "link";
428
+ var type = getType(state);
429
+ if (type){
430
+ type += " ";
431
+ } else {
432
+ type = "";
433
+ }
434
+ return type + linkemail;
435
+ }
436
+
437
+ if (ch === '<' && stream.match(/^\w/, false)) {
438
+ if (stream.string.indexOf(">") != -1) {
439
+ var atts = stream.string.substring(1,stream.string.indexOf(">"));
440
+ if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
441
+ state.md_inside = true;
442
+ }
443
+ }
444
+ stream.backUp(1);
445
+ state.htmlState = CodeMirror.startState(htmlMode);
446
+ return switchBlock(stream, state, htmlBlock);
447
+ }
448
+
449
+ if (ch === '<' && stream.match(/^\/\w*?>/)) {
450
+ state.md_inside = false;
451
+ return "tag";
452
+ }
453
+
454
+ var ignoreUnderscore = false;
455
+ if (!modeCfg.underscoresBreakWords) {
456
+ if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
457
+ var prevPos = stream.pos - 2;
458
+ if (prevPos >= 0) {
459
+ var prevCh = stream.string.charAt(prevPos);
460
+ if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
461
+ ignoreUnderscore = true;
462
+ }
463
+ }
464
+ }
465
+ }
466
+ if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
467
+ if (sol && stream.peek() === ' ') {
468
+ // Do nothing, surrounded by newline and space
469
+ } else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
470
+ if (modeCfg.highlightFormatting) state.formatting = "strong";
471
+ var t = getType(state);
472
+ state.strong = false;
473
+ return t;
474
+ } else if (!state.strong && stream.eat(ch)) { // Add STRONG
475
+ state.strong = ch;
476
+ if (modeCfg.highlightFormatting) state.formatting = "strong";
477
+ return getType(state);
478
+ } else if (state.em === ch) { // Remove EM
479
+ if (modeCfg.highlightFormatting) state.formatting = "em";
480
+ var t = getType(state);
481
+ state.em = false;
482
+ return t;
483
+ } else if (!state.em) { // Add EM
484
+ state.em = ch;
485
+ if (modeCfg.highlightFormatting) state.formatting = "em";
486
+ return getType(state);
487
+ }
488
+ } else if (ch === ' ') {
489
+ if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
490
+ if (stream.peek() === ' ') { // Surrounded by spaces, ignore
491
+ return getType(state);
492
+ } else { // Not surrounded by spaces, back up pointer
493
+ stream.backUp(1);
494
+ }
495
+ }
496
+ }
497
+
498
+ if (modeCfg.strikethrough) {
499
+ if (ch === '~' && stream.eatWhile(ch)) {
500
+ if (state.strikethrough) {// Remove strikethrough
501
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
502
+ var t = getType(state);
503
+ state.strikethrough = false;
504
+ return t;
505
+ } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
506
+ state.strikethrough = true;
507
+ if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
508
+ return getType(state);
509
+ }
510
+ } else if (ch === ' ') {
511
+ if (stream.match(/^~~/, true)) { // Probably surrounded by space
512
+ if (stream.peek() === ' ') { // Surrounded by spaces, ignore
513
+ return getType(state);
514
+ } else { // Not surrounded by spaces, back up pointer
515
+ stream.backUp(2);
516
+ }
517
+ }
518
+ }
519
+ }
520
+
521
+ if (ch === ' ') {
522
+ if (stream.match(/ +$/, false)) {
523
+ state.trailingSpace++;
524
+ } else if (state.trailingSpace) {
525
+ state.trailingSpaceNewLine = true;
526
+ }
527
+ }
528
+
529
+ return getType(state);
530
+ }
531
+
532
+ function linkInline(stream, state) {
533
+ var ch = stream.next();
534
+
535
+ if (ch === ">") {
536
+ state.f = state.inline = inlineNormal;
537
+ if (modeCfg.highlightFormatting) state.formatting = "link";
538
+ var type = getType(state);
539
+ if (type){
540
+ type += " ";
541
+ } else {
542
+ type = "";
543
+ }
544
+ return type + linkinline;
545
+ }
546
+
547
+ stream.match(/^[^>]+/, true);
548
+
549
+ return linkinline;
550
+ }
551
+
552
+ function linkHref(stream, state) {
553
+ // Check if space, and return NULL if so (to avoid marking the space)
554
+ if(stream.eatSpace()){
555
+ return null;
556
+ }
557
+ var ch = stream.next();
558
+ if (ch === '(' || ch === '[') {
559
+ state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
560
+ if (modeCfg.highlightFormatting) state.formatting = "link-string";
561
+ state.linkHref = true;
562
+ return getType(state);
563
+ }
564
+ return 'error';
565
+ }
566
+
567
+ function getLinkHrefInside(endChar) {
568
+ return function(stream, state) {
569
+ var ch = stream.next();
570
+
571
+ if (ch === endChar) {
572
+ state.f = state.inline = inlineNormal;
573
+ if (modeCfg.highlightFormatting) state.formatting = "link-string";
574
+ var returnState = getType(state);
575
+ state.linkHref = false;
576
+ return returnState;
577
+ }
578
+
579
+ if (stream.match(inlineRE(endChar), true)) {
580
+ stream.backUp(1);
581
+ }
582
+
583
+ state.linkHref = true;
584
+ return getType(state);
585
+ };
586
+ }
587
+
588
+ function footnoteLink(stream, state) {
589
+ if (stream.match(/^[^\]]*\]:/, false)) {
590
+ state.f = footnoteLinkInside;
591
+ stream.next(); // Consume [
592
+ if (modeCfg.highlightFormatting) state.formatting = "link";
593
+ state.linkText = true;
594
+ return getType(state);
595
+ }
596
+ return switchInline(stream, state, inlineNormal);
597
+ }
598
+
599
+ function footnoteLinkInside(stream, state) {
600
+ if (stream.match(/^\]:/, true)) {
601
+ state.f = state.inline = footnoteUrl;
602
+ if (modeCfg.highlightFormatting) state.formatting = "link";
603
+ var returnType = getType(state);
604
+ state.linkText = false;
605
+ return returnType;
606
+ }
607
+
608
+ stream.match(/^[^\]]+/, true);
609
+
610
+ return linktext;
611
+ }
612
+
613
+ function footnoteUrl(stream, state) {
614
+ // Check if space, and return NULL if so (to avoid marking the space)
615
+ if(stream.eatSpace()){
616
+ return null;
617
+ }
618
+ // Match URL
619
+ stream.match(/^[^\s]+/, true);
620
+ // Check for link title
621
+ if (stream.peek() === undefined) { // End of line, set flag to check next line
622
+ state.linkTitle = true;
623
+ } else { // More content on line, check if link title
624
+ stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
625
+ }
626
+ state.f = state.inline = inlineNormal;
627
+ return linkhref;
628
+ }
629
+
630
+ var savedInlineRE = [];
631
+ function inlineRE(endChar) {
632
+ if (!savedInlineRE[endChar]) {
633
+ // Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
634
+ endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
635
+ // Match any non-endChar, escaped character, as well as the closing
636
+ // endChar.
637
+ savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
638
+ }
639
+ return savedInlineRE[endChar];
640
+ }
641
+
642
+ var mode = {
643
+ startState: function() {
644
+ return {
645
+ f: blockNormal,
646
+
647
+ prevLineHasContent: false,
648
+ thisLineHasContent: false,
649
+
650
+ block: blockNormal,
651
+ htmlState: null,
652
+ indentation: 0,
653
+
654
+ inline: inlineNormal,
655
+ text: handleText,
656
+
657
+ formatting: false,
658
+ linkText: false,
659
+ linkHref: false,
660
+ linkTitle: false,
661
+ em: false,
662
+ strong: false,
663
+ header: 0,
664
+ taskList: false,
665
+ list: false,
666
+ listDepth: 0,
667
+ quote: 0,
668
+ trailingSpace: 0,
669
+ trailingSpaceNewLine: false,
670
+ strikethrough: false
671
+ };
672
+ },
673
+
674
+ copyState: function(s) {
675
+ return {
676
+ f: s.f,
677
+
678
+ prevLineHasContent: s.prevLineHasContent,
679
+ thisLineHasContent: s.thisLineHasContent,
680
+
681
+ block: s.block,
682
+ htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
683
+ indentation: s.indentation,
684
+
685
+ localMode: s.localMode,
686
+ localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
687
+
688
+ inline: s.inline,
689
+ text: s.text,
690
+ formatting: false,
691
+ linkTitle: s.linkTitle,
692
+ em: s.em,
693
+ strong: s.strong,
694
+ strikethrough: s.strikethrough,
695
+ header: s.header,
696
+ taskList: s.taskList,
697
+ list: s.list,
698
+ listDepth: s.listDepth,
699
+ quote: s.quote,
700
+ trailingSpace: s.trailingSpace,
701
+ trailingSpaceNewLine: s.trailingSpaceNewLine,
702
+ md_inside: s.md_inside
703
+ };
704
+ },
705
+
706
+ token: function(stream, state) {
707
+
708
+ // Reset state.formatting
709
+ state.formatting = false;
710
+
711
+ if (stream.sol()) {
712
+ var forceBlankLine = !!state.header;
713
+
714
+ // Reset state.header
715
+ state.header = 0;
716
+
717
+ if (stream.match(/^\s*$/, true) || forceBlankLine) {
718
+ state.prevLineHasContent = false;
719
+ blankLine(state);
720
+ return forceBlankLine ? this.token(stream, state) : null;
721
+ } else {
722
+ state.prevLineHasContent = state.thisLineHasContent;
723
+ state.thisLineHasContent = true;
724
+ }
725
+
726
+ // Reset state.taskList
727
+ state.taskList = false;
728
+
729
+ // Reset state.code
730
+ state.code = false;
731
+
732
+ // Reset state.trailingSpace
733
+ state.trailingSpace = 0;
734
+ state.trailingSpaceNewLine = false;
735
+
736
+ state.f = state.block;
737
+ var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
738
+ var difference = Math.floor((indentation - state.indentation) / 4) * 4;
739
+ if (difference > 4) difference = 4;
740
+ var adjustedIndentation = state.indentation + difference;
741
+ state.indentationDiff = adjustedIndentation - state.indentation;
742
+ state.indentation = adjustedIndentation;
743
+ if (indentation > 0) return null;
744
+ }
745
+ return state.f(stream, state);
746
+ },
747
+
748
+ innerMode: function(state) {
749
+ if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
750
+ if (state.localState) return {state: state.localState, mode: state.localMode};
751
+ return {state: state, mode: mode};
752
+ },
753
+
754
+ blankLine: blankLine,
755
+
756
+ getType: getType,
757
+
758
+ fold: "markdown"
759
+ };
760
+ return mode;
761
+ }, "xml");
762
+
763
+ CodeMirror.defineMIME("text/x-markdown", "markdown");
764
+
765
+ });