swagr 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/swagr +15 -0
- data/examples/examples01/app.rb +6 -2
- data/examples/examples01/coffee/data_port.coffee +2 -0
- data/examples/examples01/static/css/codemirror.css +1247 -0
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +5 -0
- data/examples/examples01/static/js/codemirror/keymap/emacs.js +30 -0
- data/examples/examples01/static/js/codemirror/keymap/vim.js +2298 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.css +239 -0
- data/examples/examples01/static/js/codemirror/lib/codemirror.js +4553 -0
- data/examples/examples01/static/js/codemirror/lib/util/closetag.js +85 -0
- data/examples/examples01/static/js/codemirror/lib/util/colorize.js +29 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/examples/examples01/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.css +32 -0
- data/examples/examples01/static/js/codemirror/lib/util/dialog.js +75 -0
- data/examples/examples01/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/examples/examples01/static/js/codemirror/lib/util/formatting.js +108 -0
- data/examples/examples01/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/examples/examples01/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/examples/examples01/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/examples/examples01/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/examples/examples01/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/examples/examples01/static/js/codemirror/lib/util/overlay.js +59 -0
- data/examples/examples01/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/examples/examples01/static/js/codemirror/lib/util/runmode.js +52 -0
- data/examples/examples01/static/js/codemirror/lib/util/search.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/examples/examples01/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/examples/examples01/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/examples/examples01/static/js/codemirror/mode/clike/clike.js +300 -0
- data/examples/examples01/static/js/codemirror/mode/clike/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/clike/scala.html +767 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/examples/examples01/static/js/codemirror/mode/clojure/index.html +67 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/examples/examples01/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/examples/examples01/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/examples/examples01/static/js/codemirror/mode/css/css.js +465 -0
- data/examples/examples01/static/js/codemirror/mode/css/index.html +58 -0
- data/examples/examples01/static/js/codemirror/mode/css/test.js +501 -0
- data/examples/examples01/static/js/codemirror/mode/diff/diff.js +32 -0
- data/examples/examples01/static/js/codemirror/mode/diff/index.html +105 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/examples/examples01/static/js/codemirror/mode/ecl/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/examples/examples01/static/js/codemirror/mode/erlang/index.html +64 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/index.html +70 -0
- data/examples/examples01/static/js/codemirror/mode/gfm/test.js +225 -0
- data/examples/examples01/static/js/codemirror/mode/go/go.js +165 -0
- data/examples/examples01/static/js/codemirror/mode/go/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/examples/examples01/static/js/codemirror/mode/groovy/index.html +73 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/examples/examples01/static/js/codemirror/mode/haskell/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/examples/examples01/static/js/codemirror/mode/haxe/index.html +90 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/examples/examples01/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/examples/examples01/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/examples/examples01/static/js/codemirror/mode/http/http.js +98 -0
- data/examples/examples01/static/js/codemirror/mode/http/index.html +32 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/examples/examples01/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/examples/examples01/static/js/codemirror/mode/less/index.html +741 -0
- data/examples/examples01/static/js/codemirror/mode/less/less.js +266 -0
- data/examples/examples01/static/js/codemirror/mode/lua/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/lua/lua.js +140 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/index.html +344 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/examples/examples01/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/examples/examples01/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/examples/examples01/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/examples/examples01/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/examples/examples01/static/js/codemirror/mode/perl/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/perl/perl.js +816 -0
- data/examples/examples01/static/js/codemirror/mode/php/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/php/php.js +129 -0
- data/examples/examples01/static/js/codemirror/mode/pig/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/pig/pig.js +171 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/index.html +62 -0
- data/examples/examples01/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/examples/examples01/static/js/codemirror/mode/properties/index.html +41 -0
- data/examples/examples01/static/js/codemirror/mode/properties/properties.js +63 -0
- data/examples/examples01/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/python/index.html +124 -0
- data/examples/examples01/static/js/codemirror/mode/python/python.js +340 -0
- data/examples/examples01/static/js/codemirror/mode/r/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/r/index.html +74 -0
- data/examples/examples01/static/js/codemirror/mode/r/r.js +141 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/examples/examples01/static/js/codemirror/mode/rst/index.html +526 -0
- data/examples/examples01/static/js/codemirror/mode/rst/rst.js +314 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/index.html +173 -0
- data/examples/examples01/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/examples/examples01/static/js/codemirror/mode/rust/index.html +48 -0
- data/examples/examples01/static/js/codemirror/mode/rust/rust.js +432 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/index.html +65 -0
- data/examples/examples01/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/examples/examples01/static/js/codemirror/mode/shell/index.html +51 -0
- data/examples/examples01/static/js/codemirror/mode/shell/shell.js +118 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/examples/examples01/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/index.html +83 -0
- data/examples/examples01/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/examples/examples01/static/js/codemirror/mode/stex/index.html +98 -0
- data/examples/examples01/static/js/codemirror/mode/stex/stex.js +175 -0
- data/examples/examples01/static/js/codemirror/mode/stex/test.js +343 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/index.html +81 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/examples/examples01/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/examples/examples01/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/examples/examples01/static/js/codemirror/mode/vb/index.html +88 -0
- data/examples/examples01/static/js/codemirror/mode/vb/vb.js +260 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/examples/examples01/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/index.html +103 -0
- data/examples/examples01/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/index.html +210 -0
- data/examples/examples01/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/examples/examples01/static/js/codemirror/mode/xml/index.html +45 -0
- data/examples/examples01/static/js/codemirror/mode/xml/xml.js +324 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/index.html +221 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/test.js +77 -0
- data/examples/examples01/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/index.html +68 -0
- data/examples/examples01/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/examples/examples01/static/js/codemirror/mode/z80/index.html +39 -0
- data/examples/examples01/static/js/codemirror/mode/z80/z80.js +113 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/examples/examples01/static/js/codemirror/theme/ambiance.css +76 -0
- data/examples/examples01/static/js/codemirror/theme/blackboard.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/cobalt.css +18 -0
- data/examples/examples01/static/js/codemirror/theme/eclipse.css +25 -0
- data/examples/examples01/static/js/codemirror/theme/elegant.css +10 -0
- data/examples/examples01/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/examples/examples01/static/js/codemirror/theme/monokai.css +28 -0
- data/examples/examples01/static/js/codemirror/theme/neat.css +9 -0
- data/examples/examples01/static/js/codemirror/theme/night.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/rubyblue.css +21 -0
- data/examples/examples01/static/js/codemirror/theme/solarized.css +207 -0
- data/examples/examples01/static/js/codemirror/theme/twilight.css +26 -0
- data/examples/examples01/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/examples/examples01/static/js/codemirror/theme/xq-dark.css +46 -0
- data/examples/examples01/static/js/d3.v3.min.js +2 -2
- data/examples/examples01/static/test/cm.html +33 -0
- data/examples/examples01/views/about.slim +15 -0
- data/examples/examples01/views/index.slim +1 -1
- data/examples/examples01/views/layout.slim +1 -0
- data/examples/examples01/views/layout_cm.slim +17 -0
- data/examples/examples01/views/navbar.slim +4 -4
- data/lib/swagr/version.rb +1 -1
- data/templates/app.rb +4 -0
- data/templates/static/js/codemirror/keymap/emacs.js +30 -0
- data/templates/static/js/codemirror/keymap/vim.js +2298 -0
- data/templates/static/js/codemirror/lib/codemirror.css +239 -0
- data/templates/static/js/codemirror/lib/codemirror.js +4553 -0
- data/templates/static/js/codemirror/lib/util/closetag.js +85 -0
- data/templates/static/js/codemirror/lib/util/colorize.js +29 -0
- data/templates/static/js/codemirror/lib/util/continuecomment.js +36 -0
- data/templates/static/js/codemirror/lib/util/continuelist.js +28 -0
- data/templates/static/js/codemirror/lib/util/dialog.css +32 -0
- data/templates/static/js/codemirror/lib/util/dialog.js +75 -0
- data/templates/static/js/codemirror/lib/util/foldcode.js +182 -0
- data/templates/static/js/codemirror/lib/util/formatting.js +108 -0
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +137 -0
- data/templates/static/js/codemirror/lib/util/loadmode.js +51 -0
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +46 -0
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +63 -0
- data/templates/static/js/codemirror/lib/util/multiplex.js +95 -0
- data/templates/static/js/codemirror/lib/util/overlay.js +59 -0
- data/templates/static/js/codemirror/lib/util/pig-hint.js +117 -0
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
- data/templates/static/js/codemirror/lib/util/runmode.js +52 -0
- data/templates/static/js/codemirror/lib/util/search.js +119 -0
- data/templates/static/js/codemirror/lib/util/searchcursor.js +119 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.css +16 -0
- data/templates/static/js/codemirror/lib/util/simple-hint.js +102 -0
- data/templates/static/js/codemirror/lib/util/xml-hint.js +131 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +300 -0
- data/templates/static/js/codemirror/mode/clike/index.html +103 -0
- data/templates/static/js/codemirror/mode/clike/scala.html +767 -0
- data/templates/static/js/codemirror/mode/clojure/clojure.js +206 -0
- data/templates/static/js/codemirror/mode/clojure/index.html +67 -0
- data/templates/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
- data/templates/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
- data/templates/static/js/codemirror/mode/coffeescript/index.html +728 -0
- data/templates/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
- data/templates/static/js/codemirror/mode/commonlisp/index.html +165 -0
- data/templates/static/js/codemirror/mode/css/css.js +465 -0
- data/templates/static/js/codemirror/mode/css/index.html +58 -0
- data/templates/static/js/codemirror/mode/css/test.js +501 -0
- data/templates/static/js/codemirror/mode/diff/diff.js +32 -0
- data/templates/static/js/codemirror/mode/diff/index.html +105 -0
- data/templates/static/js/codemirror/mode/ecl/ecl.js +192 -0
- data/templates/static/js/codemirror/mode/ecl/index.html +39 -0
- data/templates/static/js/codemirror/mode/erlang/erlang.js +463 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +64 -0
- data/templates/static/js/codemirror/mode/gfm/gfm.js +94 -0
- data/templates/static/js/codemirror/mode/gfm/index.html +70 -0
- data/templates/static/js/codemirror/mode/gfm/test.js +225 -0
- data/templates/static/js/codemirror/mode/go/go.js +165 -0
- data/templates/static/js/codemirror/mode/go/index.html +74 -0
- data/templates/static/js/codemirror/mode/groovy/groovy.js +210 -0
- data/templates/static/js/codemirror/mode/groovy/index.html +73 -0
- data/templates/static/js/codemirror/mode/haskell/haskell.js +242 -0
- data/templates/static/js/codemirror/mode/haskell/index.html +62 -0
- data/templates/static/js/codemirror/mode/haxe/haxe.js +429 -0
- data/templates/static/js/codemirror/mode/haxe/index.html +90 -0
- data/templates/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
- data/templates/static/js/codemirror/mode/htmlembedded/index.html +49 -0
- data/templates/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
- data/templates/static/js/codemirror/mode/htmlmixed/index.html +52 -0
- data/templates/static/js/codemirror/mode/http/http.js +98 -0
- data/templates/static/js/codemirror/mode/http/index.html +32 -0
- data/templates/static/js/codemirror/mode/javascript/index.html +88 -0
- data/templates/static/js/codemirror/mode/javascript/javascript.js +411 -0
- data/templates/static/js/codemirror/mode/javascript/typescript.html +48 -0
- data/templates/static/js/codemirror/mode/jinja2/index.html +38 -0
- data/templates/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
- data/templates/static/js/codemirror/mode/less/index.html +741 -0
- data/templates/static/js/codemirror/mode/less/less.js +266 -0
- data/templates/static/js/codemirror/mode/lua/index.html +74 -0
- data/templates/static/js/codemirror/mode/lua/lua.js +140 -0
- data/templates/static/js/codemirror/mode/markdown/index.html +344 -0
- data/templates/static/js/codemirror/mode/markdown/markdown.js +474 -0
- data/templates/static/js/codemirror/mode/markdown/test.js +1266 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +41 -0
- data/templates/static/js/codemirror/mode/mysql/mysql.js +203 -0
- data/templates/static/js/codemirror/mode/ntriples/index.html +33 -0
- data/templates/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +131 -0
- data/templates/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
- data/templates/static/js/codemirror/mode/pascal/LICENSE +7 -0
- data/templates/static/js/codemirror/mode/pascal/index.html +48 -0
- data/templates/static/js/codemirror/mode/pascal/pascal.js +94 -0
- data/templates/static/js/codemirror/mode/perl/LICENSE +19 -0
- data/templates/static/js/codemirror/mode/perl/index.html +62 -0
- data/templates/static/js/codemirror/mode/perl/perl.js +816 -0
- data/templates/static/js/codemirror/mode/php/index.html +51 -0
- data/templates/static/js/codemirror/mode/php/php.js +129 -0
- data/templates/static/js/codemirror/mode/pig/index.html +42 -0
- data/templates/static/js/codemirror/mode/pig/pig.js +171 -0
- data/templates/static/js/codemirror/mode/plsql/index.html +62 -0
- data/templates/static/js/codemirror/mode/plsql/plsql.js +216 -0
- data/templates/static/js/codemirror/mode/properties/index.html +41 -0
- data/templates/static/js/codemirror/mode/properties/properties.js +63 -0
- data/templates/static/js/codemirror/mode/python/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/python/index.html +124 -0
- data/templates/static/js/codemirror/mode/python/python.js +340 -0
- data/templates/static/js/codemirror/mode/r/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/r/index.html +74 -0
- data/templates/static/js/codemirror/mode/r/r.js +141 -0
- data/templates/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
- data/templates/static/js/codemirror/mode/rpm/changes/index.html +53 -0
- data/templates/static/js/codemirror/mode/rpm/spec/index.html +99 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
- data/templates/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
- data/templates/static/js/codemirror/mode/rst/index.html +526 -0
- data/templates/static/js/codemirror/mode/rst/rst.js +314 -0
- data/templates/static/js/codemirror/mode/ruby/LICENSE +24 -0
- data/templates/static/js/codemirror/mode/ruby/index.html +173 -0
- data/templates/static/js/codemirror/mode/ruby/ruby.js +195 -0
- data/templates/static/js/codemirror/mode/rust/index.html +48 -0
- data/templates/static/js/codemirror/mode/rust/rust.js +432 -0
- data/templates/static/js/codemirror/mode/scheme/index.html +65 -0
- data/templates/static/js/codemirror/mode/scheme/scheme.js +230 -0
- data/templates/static/js/codemirror/mode/shell/index.html +51 -0
- data/templates/static/js/codemirror/mode/shell/shell.js +118 -0
- data/templates/static/js/codemirror/mode/sieve/LICENSE +23 -0
- data/templates/static/js/codemirror/mode/sieve/index.html +81 -0
- data/templates/static/js/codemirror/mode/sieve/sieve.js +156 -0
- data/templates/static/js/codemirror/mode/smalltalk/index.html +57 -0
- data/templates/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
- data/templates/static/js/codemirror/mode/smarty/index.html +83 -0
- data/templates/static/js/codemirror/mode/smarty/smarty.js +148 -0
- data/templates/static/js/codemirror/mode/sparql/index.html +42 -0
- data/templates/static/js/codemirror/mode/sparql/sparql.js +143 -0
- data/templates/static/js/codemirror/mode/stex/index.html +98 -0
- data/templates/static/js/codemirror/mode/stex/stex.js +175 -0
- data/templates/static/js/codemirror/mode/stex/test.js +343 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
- data/templates/static/js/codemirror/mode/tiki/index.html +81 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.css +26 -0
- data/templates/static/js/codemirror/mode/tiki/tiki.js +309 -0
- data/templates/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
- data/templates/static/js/codemirror/mode/vb/index.html +88 -0
- data/templates/static/js/codemirror/mode/vb/vb.js +260 -0
- data/templates/static/js/codemirror/mode/vbscript/index.html +42 -0
- data/templates/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
- data/templates/static/js/codemirror/mode/velocity/index.html +103 -0
- data/templates/static/js/codemirror/mode/velocity/velocity.js +144 -0
- data/templates/static/js/codemirror/mode/verilog/index.html +210 -0
- data/templates/static/js/codemirror/mode/verilog/verilog.js +182 -0
- data/templates/static/js/codemirror/mode/xml/index.html +45 -0
- data/templates/static/js/codemirror/mode/xml/xml.js +324 -0
- data/templates/static/js/codemirror/mode/xquery/LICENSE +20 -0
- data/templates/static/js/codemirror/mode/xquery/index.html +221 -0
- data/templates/static/js/codemirror/mode/xquery/test.js +77 -0
- data/templates/static/js/codemirror/mode/xquery/xquery.js +450 -0
- data/templates/static/js/codemirror/mode/yaml/index.html +68 -0
- data/templates/static/js/codemirror/mode/yaml/yaml.js +95 -0
- data/templates/static/js/codemirror/mode/z80/index.html +39 -0
- data/templates/static/js/codemirror/mode/z80/z80.js +113 -0
- data/templates/static/js/codemirror/theme/ambiance-mobile.css +6 -0
- data/templates/static/js/codemirror/theme/ambiance.css +76 -0
- data/templates/static/js/codemirror/theme/blackboard.css +25 -0
- data/templates/static/js/codemirror/theme/cobalt.css +18 -0
- data/templates/static/js/codemirror/theme/eclipse.css +25 -0
- data/templates/static/js/codemirror/theme/elegant.css +10 -0
- data/templates/static/js/codemirror/theme/erlang-dark.css +21 -0
- data/templates/static/js/codemirror/theme/lesser-dark.css +44 -0
- data/templates/static/js/codemirror/theme/monokai.css +28 -0
- data/templates/static/js/codemirror/theme/neat.css +9 -0
- data/templates/static/js/codemirror/theme/night.css +21 -0
- data/templates/static/js/codemirror/theme/rubyblue.css +21 -0
- data/templates/static/js/codemirror/theme/solarized.css +207 -0
- data/templates/static/js/codemirror/theme/twilight.css +26 -0
- data/templates/static/js/codemirror/theme/vibrant-ink.css +27 -0
- data/templates/static/js/codemirror/theme/xq-dark.css +46 -0
- data/templates/static/js/d3.v3.min.js +2 -2
- data/templates/static/test/cm.html +33 -0
- data/templates/views/about.slim +15 -0
- data/templates/views/index.slim +1 -1
- data/templates/views/layout.slim +1 -0
- data/templates/views/navbar.slim +4 -4
- metadata +347 -2
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2011 by MarkLogic Corporation
|
2
|
+
Author: Mike Brevoort <mike@brevoort.com>
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
THE SOFTWARE.
|
@@ -0,0 +1,221 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<!--
|
4
|
+
/*
|
5
|
+
Copyright (C) 2011 by MarkLogic Corporation
|
6
|
+
Author: Mike Brevoort <mike@brevoort.com>
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
10
|
+
in the Software without restriction, including without limitation the rights
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
13
|
+
furnished to do so, subject to the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
16
|
+
all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
+
THE SOFTWARE.
|
25
|
+
*/
|
26
|
+
-->
|
27
|
+
<head>
|
28
|
+
<meta charset="utf-8">
|
29
|
+
<title>CodeMirror: XQuery mode</title>
|
30
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
31
|
+
<script src="../../lib/codemirror.js"></script>
|
32
|
+
<script src="xquery.js"></script>
|
33
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
34
|
+
<link rel="stylesheet" href="../../theme/xq-dark.css">
|
35
|
+
<style type="text/css">
|
36
|
+
.CodeMirror {
|
37
|
+
border-top: 1px solid black; border-bottom: 1px solid black;
|
38
|
+
height:400px;
|
39
|
+
}
|
40
|
+
</style>
|
41
|
+
</head>
|
42
|
+
<body>
|
43
|
+
<h1>CodeMirror: XQuery mode</h1>
|
44
|
+
|
45
|
+
<div class="cm-s-default">
|
46
|
+
<textarea id="code" name="code">
|
47
|
+
xquery version "1.0-ml";
|
48
|
+
(: this is
|
49
|
+
: a
|
50
|
+
"comment" :)
|
51
|
+
let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x>
|
52
|
+
let $joe:=1
|
53
|
+
return element element {
|
54
|
+
attribute attribute { 1 },
|
55
|
+
element test { 'a' },
|
56
|
+
attribute foo { "bar" },
|
57
|
+
fn:doc()[ foo/@bar eq $let ],
|
58
|
+
//x }
|
59
|
+
|
60
|
+
(: a more 'evil' test :)
|
61
|
+
(: Modified Blakeley example (: with nested comment :) ... :)
|
62
|
+
declare private function local:declare() {()};
|
63
|
+
declare private function local:private() {()};
|
64
|
+
declare private function local:function() {()};
|
65
|
+
declare private function local:local() {()};
|
66
|
+
let $let := <let>let $let := "let"</let>
|
67
|
+
return element element {
|
68
|
+
attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
|
69
|
+
attribute fn:doc { "bar" castable as xs:string },
|
70
|
+
element text { text { "text" } },
|
71
|
+
fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
|
72
|
+
//fn:doc
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
xquery version "1.0-ml";
|
78
|
+
|
79
|
+
(: Copyright 2006-2010 Mark Logic Corporation. :)
|
80
|
+
|
81
|
+
(:
|
82
|
+
: Licensed under the Apache License, Version 2.0 (the "License");
|
83
|
+
: you may not use this file except in compliance with the License.
|
84
|
+
: You may obtain a copy of the License at
|
85
|
+
:
|
86
|
+
: http://www.apache.org/licenses/LICENSE-2.0
|
87
|
+
:
|
88
|
+
: Unless required by applicable law or agreed to in writing, software
|
89
|
+
: distributed under the License is distributed on an "AS IS" BASIS,
|
90
|
+
: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
91
|
+
: See the License for the specific language governing permissions and
|
92
|
+
: limitations under the License.
|
93
|
+
:)
|
94
|
+
|
95
|
+
module namespace json = "http://marklogic.com/json";
|
96
|
+
declare default function namespace "http://www.w3.org/2005/xpath-functions";
|
97
|
+
|
98
|
+
(: Need to backslash escape any double quotes, backslashes, and newlines :)
|
99
|
+
declare function json:escape($s as xs:string) as xs:string {
|
100
|
+
let $s := replace($s, "\\", "\\\\")
|
101
|
+
let $s := replace($s, """", "\\""")
|
102
|
+
let $s := replace($s, codepoints-to-string((13, 10)), "\\n")
|
103
|
+
let $s := replace($s, codepoints-to-string(13), "\\n")
|
104
|
+
let $s := replace($s, codepoints-to-string(10), "\\n")
|
105
|
+
return $s
|
106
|
+
};
|
107
|
+
|
108
|
+
declare function json:atomize($x as element()) as xs:string {
|
109
|
+
if (count($x/node()) = 0) then 'null'
|
110
|
+
else if ($x/@type = "number") then
|
111
|
+
let $castable := $x castable as xs:float or
|
112
|
+
$x castable as xs:double or
|
113
|
+
$x castable as xs:decimal
|
114
|
+
return
|
115
|
+
if ($castable) then xs:string($x)
|
116
|
+
else error(concat("Not a number: ", xdmp:describe($x)))
|
117
|
+
else if ($x/@type = "boolean") then
|
118
|
+
let $castable := $x castable as xs:boolean
|
119
|
+
return
|
120
|
+
if ($castable) then xs:string(xs:boolean($x))
|
121
|
+
else error(concat("Not a boolean: ", xdmp:describe($x)))
|
122
|
+
else concat('"', json:escape($x), '"')
|
123
|
+
};
|
124
|
+
|
125
|
+
(: Print the thing that comes after the colon :)
|
126
|
+
declare function json:print-value($x as element()) as xs:string {
|
127
|
+
if (count($x/*) = 0) then
|
128
|
+
json:atomize($x)
|
129
|
+
else if ($x/@quote = "true") then
|
130
|
+
concat('"', json:escape(xdmp:quote($x/node())), '"')
|
131
|
+
else
|
132
|
+
string-join(('{',
|
133
|
+
string-join(for $i in $x/* return json:print-name-value($i), ","),
|
134
|
+
'}'), "")
|
135
|
+
};
|
136
|
+
|
137
|
+
(: Print the name and value both :)
|
138
|
+
declare function json:print-name-value($x as element()) as xs:string? {
|
139
|
+
let $name := name($x)
|
140
|
+
let $first-in-array :=
|
141
|
+
count($x/preceding-sibling::*[name(.) = $name]) = 0 and
|
142
|
+
(count($x/following-sibling::*[name(.) = $name]) > 0 or $x/@array = "true")
|
143
|
+
let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) > 0
|
144
|
+
return
|
145
|
+
|
146
|
+
if ($later-in-array) then
|
147
|
+
() (: I was handled previously :)
|
148
|
+
else if ($first-in-array) then
|
149
|
+
string-join(('"', json:escape($name), '":[',
|
150
|
+
string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), ","),
|
151
|
+
']'), "")
|
152
|
+
else
|
153
|
+
string-join(('"', json:escape($name), '":', json:print-value($x)), "")
|
154
|
+
};
|
155
|
+
|
156
|
+
(:~
|
157
|
+
Transforms an XML element into a JSON string representation. See http://json.org.
|
158
|
+
<p/>
|
159
|
+
Sample usage:
|
160
|
+
<pre>
|
161
|
+
xquery version "1.0-ml";
|
162
|
+
import module namespace json="http://marklogic.com/json" at "json.xqy";
|
163
|
+
json:serialize(&lt;foo&gt;&lt;bar&gt;kid&lt;/bar&gt;&lt;/foo&gt;)
|
164
|
+
</pre>
|
165
|
+
Sample transformations:
|
166
|
+
<pre>
|
167
|
+
&lt;e/&gt; becomes {"e":null}
|
168
|
+
&lt;e&gt;text&lt;/e&gt; becomes {"e":"text"}
|
169
|
+
&lt;e&gt;quote " escaping&lt;/e&gt; becomes {"e":"quote \" escaping"}
|
170
|
+
&lt;e&gt;backslash \ escaping&lt;/e&gt; becomes {"e":"backslash \\ escaping"}
|
171
|
+
&lt;e&gt;&lt;a&gt;text1&lt;/a&gt;&lt;b&gt;text2&lt;/b&gt;&lt;/e&gt; becomes {"e":{"a":"text1","b":"text2"}}
|
172
|
+
&lt;e&gt;&lt;a&gt;text1&lt;/a&gt;&lt;a&gt;text2&lt;/a&gt;&lt;/e&gt; becomes {"e":{"a":["text1","text2"]}}
|
173
|
+
&lt;e&gt;&lt;a array="true"&gt;text1&lt;/a&gt;&lt;/e&gt; becomes {"e":{"a":["text1"]}}
|
174
|
+
&lt;e&gt;&lt;a type="boolean"&gt;false&lt;/a&gt;&lt;/e&gt; becomes {"e":{"a":false}}
|
175
|
+
&lt;e&gt;&lt;a type="number"&gt;123.5&lt;/a&gt;&lt;/e&gt; becomes {"e":{"a":123.5}}
|
176
|
+
&lt;e quote="true"&gt;&lt;div attrib="value"/&gt;&lt;/e&gt; becomes {"e":"&lt;div attrib=\"value\"/&gt;"}
|
177
|
+
</pre>
|
178
|
+
<p/>
|
179
|
+
Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
|
180
|
+
<p/>
|
181
|
+
Attributes are ignored, except for the special attribute @array="true" that
|
182
|
+
indicates the JSON serialization should write the node, even if single, as an
|
183
|
+
array, and the attribute @type that can be set to "boolean" or "number" to
|
184
|
+
dictate the value should be written as that type (unquoted). There's also
|
185
|
+
an @quote attribute that when set to true writes the inner content as text
|
186
|
+
rather than as structured JSON, useful for sending some XHTML over the
|
187
|
+
wire.
|
188
|
+
<p/>
|
189
|
+
Text nodes within mixed content are ignored.
|
190
|
+
|
191
|
+
@param $x Element node to convert
|
192
|
+
@return String holding JSON serialized representation of $x
|
193
|
+
|
194
|
+
@author Jason Hunter
|
195
|
+
@version 1.0.1
|
196
|
+
|
197
|
+
Ported to xquery 1.0-ml; double escaped backslashes in json:escape
|
198
|
+
:)
|
199
|
+
declare function json:serialize($x as element()) as xs:string {
|
200
|
+
string-join(('{', json:print-name-value($x), '}'), "")
|
201
|
+
};
|
202
|
+
</textarea>
|
203
|
+
</div>
|
204
|
+
|
205
|
+
<script>
|
206
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
207
|
+
lineNumbers: true,
|
208
|
+
matchBrackets: true,
|
209
|
+
theme: "xq-dark"
|
210
|
+
});
|
211
|
+
</script>
|
212
|
+
|
213
|
+
<p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
|
214
|
+
|
215
|
+
<p>Development of the CodeMirror XQuery mode was sponsored by
|
216
|
+
<a href="http://marklogic.com">MarkLogic</a> and developed by
|
217
|
+
<a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
|
218
|
+
</p>
|
219
|
+
|
220
|
+
</body>
|
221
|
+
</html>
|
@@ -0,0 +1,77 @@
|
|
1
|
+
// Initiate ModeTest and set defaults
|
2
|
+
var MT = ModeTest;
|
3
|
+
MT.modeName = "xquery";
|
4
|
+
MT.modeOptions = {};
|
5
|
+
|
6
|
+
MT.testMode("eviltest",
|
7
|
+
'xquery version "1.0-ml";\
|
8
|
+
(: this is\
|
9
|
+
: a \
|
10
|
+
"comment" :)\
|
11
|
+
let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x>\
|
12
|
+
let $joe:=1\
|
13
|
+
return element element {\
|
14
|
+
attribute attribute { 1 },\
|
15
|
+
element test { 'a' }, \
|
16
|
+
attribute foo { "bar" },\
|
17
|
+
fn:doc()[ foo/@bar eq $let ],\
|
18
|
+
//x } \
|
19
|
+
\
|
20
|
+
(: a more \'evil\' test :)\
|
21
|
+
(: Modified Blakeley example (: with nested comment :) ... :)\
|
22
|
+
declare private function local:declare() {()};\
|
23
|
+
declare private function local:private() {()};\
|
24
|
+
declare private function local:function() {()};\
|
25
|
+
declare private function local:local() {()};\
|
26
|
+
let $let := <let>let $let := "let"</let>\
|
27
|
+
return element element {\
|
28
|
+
attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },\
|
29
|
+
attribute fn:doc { "bar" castable as xs:string },\
|
30
|
+
element text { text { "text" } },\
|
31
|
+
fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],\
|
32
|
+
//fn:doc\
|
33
|
+
}', ["keyword","xquery",null," ","keyword","version",null," ","variable",""1","keyword",".","atom","0","keyword","-","variable","ml"","def variable",";",null," ","comment","(: this is : a \"comment\" :)",null," ","keyword","let",null," ","variable","$let",null," ","keyword",":=",null," ","variable","<x",null," ","variable","attr","keyword","=","variable",""value">"test"<func>","def variable",";function","","()",null," ","variable","$var",null," ","","{","keyword","function","","()}",null," ","","{","variable","$var","","}","variable","<","keyword","/","variable","func><","keyword","/","variable","x>",null," ","keyword","let",null," ","variable","$joe","keyword",":=","atom","1",null," ","keyword","return",null," ","keyword","element",null," ","variable","element",null," ","","{",null," ","keyword","attribute",null," ","variable","attribute",null," ","","{",null," ","atom","1",null," ","","},",null," ","keyword","element",null," ","variable","test",null," ","","{",null," ","variable","'a'",null," ","","},",null," ","keyword","attribute",null," ","variable","foo",null," ","","{",null," ","variable",""bar"",null," ","","},",null," ","def variable","fn:doc","","()[",null," ","variable","foo","keyword","/","variable","@bar",null," ","keyword","eq",null," ","variable","$let",null," ","","],",null," ","keyword","//","variable","x",null," ","","}",null," ","comment","(: a more 'evil' test :)",null," ","comment","(: Modified Blakeley example (: with nested comment :) ... :)",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:declare","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:private","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:function","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:local","","()",null," ","","{()}","variable",";",null," ","keyword","let",null," ","variable","$let",null," ","keyword",":=",null," ","variable","<let>let",null," ","variable","$let",null," ","keyword",":=",null," ","variable",""let"<","keyword","/let","variable",">",null," ","keyword","return",null," ","keyword","element",null," ","variable","element",null," ","","{",null," ","keyword","attribute",null," ","variable","attribute",null," ","","{",null," ","keyword","try",null," ","","{",null," ","def variable","xdmp:version","","()",null," ","","}",null," ","keyword","catch","","(","variable","$e","",")",null," ","","{",null," ","def variable","xdmp:log","","(","variable","$e","",")",null," ","","}",null," ","","},",null," ","keyword","attribute",null," ","variable","fn:doc",null," ","","{",null," ","variable",""bar"",null," ","variable","castable",null," ","keyword","as",null," ","atom","xs:string",null," ","","},",null," ","keyword","element",null," ","variable","text",null," ","","{",null," ","keyword","text",null," ","","{",null," ","variable",""text"",null," ","","}",null," ","","},",null," ","def variable","fn:doc","","()[",null," ","qualifier","child::","variable","eq","keyword","/","","(","variable","@bar",null," ","keyword","|",null," ","qualifier","attribute::","variable","attribute","",")",null," ","keyword","eq",null," ","variable","$let",null," ","","],",null," ","keyword","//","variable","fn:doc",null," ","","}"]);
|
34
|
+
|
35
|
+
MT.testMode("testEmptySequenceKeyword",
|
36
|
+
'"foo" instance of empty-sequence()',
|
37
|
+
["string","\"foo\"",null," ","keyword","instance",null," ","keyword","of",null," ","keyword","empty-sequence","","()"]);
|
38
|
+
|
39
|
+
|
40
|
+
MT.testMode("testMultiAttr",
|
41
|
+
'<p a1="foo" a2="bar">hello world</p>',
|
42
|
+
["tag","<p ","attribute","a1","","=","string","\"foo\"",null," ","attribute","a2","","=","string","\"bar\"","tag",">","variable","hello",null," ","variable","world","tag","</p>"]);
|
43
|
+
|
44
|
+
MT.testMode("test namespaced variable",
|
45
|
+
'declare namespace e = "http://example.com/ANamespace";\
|
46
|
+
declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;',
|
47
|
+
["keyword","declare",null," ","keyword","namespace",null," ","variable","e",null," ","keyword","=",null," ","string","\"http://example.com/ANamespace\"","variable",";declare",null," ","keyword","variable",null," ","variable","$e:exampleComThisVarIsNotRecognized",null," ","keyword","as",null," ","keyword","element","","(","keyword","*","",")",null," ","variable","external;"]);
|
48
|
+
|
49
|
+
MT.testMode("test EQName variable",
|
50
|
+
'declare variable $"http://www.example.com/ns/my":var := 12;\
|
51
|
+
<out>{$"http://www.example.com/ns/my":var}</out>',
|
52
|
+
["keyword","declare",null," ","keyword","variable",null," ","variable","$\"http://www.example.com/ns/my\":var",null," ","keyword",":=",null," ","atom","12","variable",";","tag","<out>","","{","variable","$\"http://www.example.com/ns/my\":var","","}","tag","</out>"]);
|
53
|
+
|
54
|
+
MT.testMode("test EQName function",
|
55
|
+
'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer {\
|
56
|
+
$a + 2\
|
57
|
+
};\
|
58
|
+
<out>{"http://www.example.com/ns/my":fn(12)}</out>',
|
59
|
+
["keyword","declare",null," ","keyword","function",null," ","def variable","\"http://www.example.com/ns/my\":fn",null," ","","(","variable","$a",null," ","keyword","as",null," ","atom","xs:integer","",")",null," ","keyword","as",null," ","atom","xs:integer",null," ","","{",null," ","variable","$a",null," ","keyword","+",null," ","atom","2","","}","variable",";","tag","<out>","","{","def variable","\"http://www.example.com/ns/my\":fn","","(","atom","12","",")}","tag","</out>"]);
|
60
|
+
|
61
|
+
MT.testMode("test EQName function with single quotes",
|
62
|
+
'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer {\
|
63
|
+
$a + 2\
|
64
|
+
};\
|
65
|
+
<out>{\'http://www.example.com/ns/my\':fn(12)}</out>',
|
66
|
+
["keyword","declare",null," ","keyword","function",null," ","def variable","'http://www.example.com/ns/my':fn",null," ","","(","variable","$a",null," ","keyword","as",null," ","atom","xs:integer","",")",null," ","keyword","as",null," ","atom","xs:integer",null," ","","{",null," ","variable","$a",null," ","keyword","+",null," ","atom","2","","}","variable",";","tag","<out>","","{","def variable","'http://www.example.com/ns/my':fn","","(","atom","12","",")}","tag","</out>"]);
|
67
|
+
|
68
|
+
MT.testMode("testProcessingInstructions",
|
69
|
+
'data(<?target content?>) instance of xs:string',
|
70
|
+
["def variable","data","","(","comment meta","<?target content?>","",")",null," ","keyword","instance",null," ","keyword","of",null," ","atom","xs:string"]);
|
71
|
+
|
72
|
+
MT.testMode("testQuoteEscapeDouble",
|
73
|
+
'let $rootfolder := "c:\\builds\\winnt\\HEAD\\qa\\scripts\\"\
|
74
|
+
let $keysfolder := concat($rootfolder, "keys\\")\
|
75
|
+
return\
|
76
|
+
$keysfolder',
|
77
|
+
["keyword","let",null," ","variable","$rootfolder",null," ","keyword",":=",null," ","string","\"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"","keyword","let",null," ","variable","$keysfolder",null," ","keyword",":=",null," ","def variable","concat","","(","variable","$rootfolder","",",",null," ","string","\"keys\\\"","",")","variable","return$keysfolder"]);
|
@@ -0,0 +1,450 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2011 by MarkLogic Corporation
|
3
|
+
Author: Mike Brevoort <mike@brevoort.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
CodeMirror.defineMode("xquery", function() {
|
24
|
+
|
25
|
+
// The keywords object is set to the result of this self executing
|
26
|
+
// function. Each keyword is a property of the keywords object whose
|
27
|
+
// value is {type: atype, style: astyle}
|
28
|
+
var keywords = function(){
|
29
|
+
// conveinence functions used to build keywords object
|
30
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
31
|
+
var A = kw("keyword a")
|
32
|
+
, B = kw("keyword b")
|
33
|
+
, C = kw("keyword c")
|
34
|
+
, operator = kw("operator")
|
35
|
+
, atom = {type: "atom", style: "atom"}
|
36
|
+
, punctuation = {type: "punctuation", style: ""}
|
37
|
+
, qualifier = {type: "axis_specifier", style: "qualifier"};
|
38
|
+
|
39
|
+
// kwObj is what is return from this function at the end
|
40
|
+
var kwObj = {
|
41
|
+
'if': A, 'switch': A, 'while': A, 'for': A,
|
42
|
+
'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
|
43
|
+
'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
|
44
|
+
'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
|
45
|
+
',': punctuation,
|
46
|
+
'null': atom, 'fn:false()': atom, 'fn:true()': atom
|
47
|
+
};
|
48
|
+
|
49
|
+
// a list of 'basic' keywords. For each add a property to kwObj with the value of
|
50
|
+
// {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
|
51
|
+
var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before',
|
52
|
+
'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self',
|
53
|
+
'descending','document','document-node','element','else','eq','every','except','external','following',
|
54
|
+
'following-sibling','follows','for','function','if','import','in','instance','intersect','item',
|
55
|
+
'let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding',
|
56
|
+
'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element',
|
57
|
+
'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
|
58
|
+
'xquery', 'empty-sequence'];
|
59
|
+
for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
|
60
|
+
|
61
|
+
// a list of types. For each add a property to kwObj with the value of
|
62
|
+
// {type: "atom", style: "atom"}
|
63
|
+
var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
|
64
|
+
'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
|
65
|
+
'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'];
|
66
|
+
for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
|
67
|
+
|
68
|
+
// each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
|
69
|
+
var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
|
70
|
+
for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
|
71
|
+
|
72
|
+
// each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
|
73
|
+
var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
|
74
|
+
"ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
|
75
|
+
for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
|
76
|
+
|
77
|
+
return kwObj;
|
78
|
+
}();
|
79
|
+
|
80
|
+
// Used as scratch variables to communicate multiple values without
|
81
|
+
// consing up tons of objects.
|
82
|
+
var type, content;
|
83
|
+
|
84
|
+
function ret(tp, style, cont) {
|
85
|
+
type = tp; content = cont;
|
86
|
+
return style;
|
87
|
+
}
|
88
|
+
|
89
|
+
function chain(stream, state, f) {
|
90
|
+
state.tokenize = f;
|
91
|
+
return f(stream, state);
|
92
|
+
}
|
93
|
+
|
94
|
+
// the primary mode tokenizer
|
95
|
+
function tokenBase(stream, state) {
|
96
|
+
var ch = stream.next(),
|
97
|
+
mightBeFunction = false,
|
98
|
+
isEQName = isEQNameAhead(stream);
|
99
|
+
|
100
|
+
// an XML tag (if not in some sub, chained tokenizer)
|
101
|
+
if (ch == "<") {
|
102
|
+
if(stream.match("!--", true))
|
103
|
+
return chain(stream, state, tokenXMLComment);
|
104
|
+
|
105
|
+
if(stream.match("![CDATA", false)) {
|
106
|
+
state.tokenize = tokenCDATA;
|
107
|
+
return ret("tag", "tag");
|
108
|
+
}
|
109
|
+
|
110
|
+
if(stream.match("?", false)) {
|
111
|
+
return chain(stream, state, tokenPreProcessing);
|
112
|
+
}
|
113
|
+
|
114
|
+
var isclose = stream.eat("/");
|
115
|
+
stream.eatSpace();
|
116
|
+
var tagName = "", c;
|
117
|
+
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
118
|
+
|
119
|
+
return chain(stream, state, tokenTag(tagName, isclose));
|
120
|
+
}
|
121
|
+
// start code block
|
122
|
+
else if(ch == "{") {
|
123
|
+
pushStateStack(state,{ type: "codeblock"});
|
124
|
+
return ret("", "");
|
125
|
+
}
|
126
|
+
// end code block
|
127
|
+
else if(ch == "}") {
|
128
|
+
popStateStack(state);
|
129
|
+
return ret("", "");
|
130
|
+
}
|
131
|
+
// if we're in an XML block
|
132
|
+
else if(isInXmlBlock(state)) {
|
133
|
+
if(ch == ">")
|
134
|
+
return ret("tag", "tag");
|
135
|
+
else if(ch == "/" && stream.eat(">")) {
|
136
|
+
popStateStack(state);
|
137
|
+
return ret("tag", "tag");
|
138
|
+
}
|
139
|
+
else
|
140
|
+
return ret("word", "variable");
|
141
|
+
}
|
142
|
+
// if a number
|
143
|
+
else if (/\d/.test(ch)) {
|
144
|
+
stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
|
145
|
+
return ret("number", "atom");
|
146
|
+
}
|
147
|
+
// comment start
|
148
|
+
else if (ch === "(" && stream.eat(":")) {
|
149
|
+
pushStateStack(state, { type: "comment"});
|
150
|
+
return chain(stream, state, tokenComment);
|
151
|
+
}
|
152
|
+
// quoted string
|
153
|
+
else if ( !isEQName && (ch === '"' || ch === "'"))
|
154
|
+
return chain(stream, state, tokenString(ch));
|
155
|
+
// variable
|
156
|
+
else if(ch === "$") {
|
157
|
+
return chain(stream, state, tokenVariable);
|
158
|
+
}
|
159
|
+
// assignment
|
160
|
+
else if(ch ===":" && stream.eat("=")) {
|
161
|
+
return ret("operator", "keyword");
|
162
|
+
}
|
163
|
+
// open paren
|
164
|
+
else if(ch === "(") {
|
165
|
+
pushStateStack(state, { type: "paren"});
|
166
|
+
return ret("", "");
|
167
|
+
}
|
168
|
+
// close paren
|
169
|
+
else if(ch === ")") {
|
170
|
+
popStateStack(state);
|
171
|
+
return ret("", "");
|
172
|
+
}
|
173
|
+
// open paren
|
174
|
+
else if(ch === "[") {
|
175
|
+
pushStateStack(state, { type: "bracket"});
|
176
|
+
return ret("", "");
|
177
|
+
}
|
178
|
+
// close paren
|
179
|
+
else if(ch === "]") {
|
180
|
+
popStateStack(state);
|
181
|
+
return ret("", "");
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
|
185
|
+
|
186
|
+
// if there's a EQName ahead, consume the rest of the string portion, it's likely a function
|
187
|
+
if(isEQName && ch === '\"') while(stream.next() !== '"'){}
|
188
|
+
if(isEQName && ch === '\'') while(stream.next() !== '\''){}
|
189
|
+
|
190
|
+
// gobble up a word if the character is not known
|
191
|
+
if(!known) stream.eatWhile(/[\w\$_-]/);
|
192
|
+
|
193
|
+
// gobble a colon in the case that is a lib func type call fn:doc
|
194
|
+
var foundColon = stream.eat(":");
|
195
|
+
|
196
|
+
// if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
|
197
|
+
// which should get matched as a keyword
|
198
|
+
if(!stream.eat(":") && foundColon) {
|
199
|
+
stream.eatWhile(/[\w\$_-]/);
|
200
|
+
}
|
201
|
+
// if the next non whitespace character is an open paren, this is probably a function (if not a keyword of other sort)
|
202
|
+
if(stream.match(/^[ \t]*\(/, false)) {
|
203
|
+
mightBeFunction = true;
|
204
|
+
}
|
205
|
+
// is the word a keyword?
|
206
|
+
var word = stream.current();
|
207
|
+
known = keywords.propertyIsEnumerable(word) && keywords[word];
|
208
|
+
|
209
|
+
// if we think it's a function call but not yet known,
|
210
|
+
// set style to variable for now for lack of something better
|
211
|
+
if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
|
212
|
+
|
213
|
+
// if the previous word was element, attribute, axis specifier, this word should be the name of that
|
214
|
+
if(isInXmlConstructor(state)) {
|
215
|
+
popStateStack(state);
|
216
|
+
return ret("word", "variable", word);
|
217
|
+
}
|
218
|
+
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
|
219
|
+
// push the stack so we know to look for it on the next word
|
220
|
+
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
|
221
|
+
|
222
|
+
// if the word is known, return the details of that else just call this a generic 'word'
|
223
|
+
return known ? ret(known.type, known.style, word) :
|
224
|
+
ret("word", "variable", word);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
// handle comments, including nested
|
229
|
+
function tokenComment(stream, state) {
|
230
|
+
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
|
231
|
+
while (ch = stream.next()) {
|
232
|
+
if (ch == ")" && maybeEnd) {
|
233
|
+
if(nestedCount > 0)
|
234
|
+
nestedCount--;
|
235
|
+
else {
|
236
|
+
popStateStack(state);
|
237
|
+
break;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
else if(ch == ":" && maybeNested) {
|
241
|
+
nestedCount++;
|
242
|
+
}
|
243
|
+
maybeEnd = (ch == ":");
|
244
|
+
maybeNested = (ch == "(");
|
245
|
+
}
|
246
|
+
|
247
|
+
return ret("comment", "comment");
|
248
|
+
}
|
249
|
+
|
250
|
+
// tokenizer for string literals
|
251
|
+
// optionally pass a tokenizer function to set state.tokenize back to when finished
|
252
|
+
function tokenString(quote, f) {
|
253
|
+
return function(stream, state) {
|
254
|
+
var ch;
|
255
|
+
|
256
|
+
if(isInString(state) && stream.current() == quote) {
|
257
|
+
popStateStack(state);
|
258
|
+
if(f) state.tokenize = f;
|
259
|
+
return ret("string", "string");
|
260
|
+
}
|
261
|
+
|
262
|
+
pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
|
263
|
+
|
264
|
+
// if we're in a string and in an XML block, allow an embedded code block
|
265
|
+
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
266
|
+
state.tokenize = tokenBase;
|
267
|
+
return ret("string", "string");
|
268
|
+
}
|
269
|
+
|
270
|
+
|
271
|
+
while (ch = stream.next()) {
|
272
|
+
if (ch == quote) {
|
273
|
+
popStateStack(state);
|
274
|
+
if(f) state.tokenize = f;
|
275
|
+
break;
|
276
|
+
}
|
277
|
+
else {
|
278
|
+
// if we're in a string and in an XML block, allow an embedded code block in an attribute
|
279
|
+
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
280
|
+
state.tokenize = tokenBase;
|
281
|
+
return ret("string", "string");
|
282
|
+
}
|
283
|
+
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
return ret("string", "string");
|
288
|
+
};
|
289
|
+
}
|
290
|
+
|
291
|
+
// tokenizer for variables
|
292
|
+
function tokenVariable(stream, state) {
|
293
|
+
var isVariableChar = /[\w\$_-]/;
|
294
|
+
|
295
|
+
// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
|
296
|
+
if(stream.eat("\"")) {
|
297
|
+
while(stream.next() !== '\"'){};
|
298
|
+
stream.eat(":");
|
299
|
+
} else {
|
300
|
+
stream.eatWhile(isVariableChar);
|
301
|
+
if(!stream.match(":=", false)) stream.eat(":");
|
302
|
+
}
|
303
|
+
stream.eatWhile(isVariableChar);
|
304
|
+
state.tokenize = tokenBase;
|
305
|
+
return ret("variable", "variable");
|
306
|
+
}
|
307
|
+
|
308
|
+
// tokenizer for XML tags
|
309
|
+
function tokenTag(name, isclose) {
|
310
|
+
return function(stream, state) {
|
311
|
+
stream.eatSpace();
|
312
|
+
if(isclose && stream.eat(">")) {
|
313
|
+
popStateStack(state);
|
314
|
+
state.tokenize = tokenBase;
|
315
|
+
return ret("tag", "tag");
|
316
|
+
}
|
317
|
+
// self closing tag without attributes?
|
318
|
+
if(!stream.eat("/"))
|
319
|
+
pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
|
320
|
+
if(!stream.eat(">")) {
|
321
|
+
state.tokenize = tokenAttribute;
|
322
|
+
return ret("tag", "tag");
|
323
|
+
}
|
324
|
+
else {
|
325
|
+
state.tokenize = tokenBase;
|
326
|
+
}
|
327
|
+
return ret("tag", "tag");
|
328
|
+
};
|
329
|
+
}
|
330
|
+
|
331
|
+
// tokenizer for XML attributes
|
332
|
+
function tokenAttribute(stream, state) {
|
333
|
+
var ch = stream.next();
|
334
|
+
|
335
|
+
if(ch == "/" && stream.eat(">")) {
|
336
|
+
if(isInXmlAttributeBlock(state)) popStateStack(state);
|
337
|
+
if(isInXmlBlock(state)) popStateStack(state);
|
338
|
+
return ret("tag", "tag");
|
339
|
+
}
|
340
|
+
if(ch == ">") {
|
341
|
+
if(isInXmlAttributeBlock(state)) popStateStack(state);
|
342
|
+
return ret("tag", "tag");
|
343
|
+
}
|
344
|
+
if(ch == "=")
|
345
|
+
return ret("", "");
|
346
|
+
// quoted string
|
347
|
+
if (ch == '"' || ch == "'")
|
348
|
+
return chain(stream, state, tokenString(ch, tokenAttribute));
|
349
|
+
|
350
|
+
if(!isInXmlAttributeBlock(state))
|
351
|
+
pushStateStack(state, { type: "attribute", name: name, tokenize: tokenAttribute});
|
352
|
+
|
353
|
+
stream.eat(/[a-zA-Z_:]/);
|
354
|
+
stream.eatWhile(/[-a-zA-Z0-9_:.]/);
|
355
|
+
stream.eatSpace();
|
356
|
+
|
357
|
+
// the case where the attribute has not value and the tag was closed
|
358
|
+
if(stream.match(">", false) || stream.match("/", false)) {
|
359
|
+
popStateStack(state);
|
360
|
+
state.tokenize = tokenBase;
|
361
|
+
}
|
362
|
+
|
363
|
+
return ret("attribute", "attribute");
|
364
|
+
}
|
365
|
+
|
366
|
+
// handle comments, including nested
|
367
|
+
function tokenXMLComment(stream, state) {
|
368
|
+
var ch;
|
369
|
+
while (ch = stream.next()) {
|
370
|
+
if (ch == "-" && stream.match("->", true)) {
|
371
|
+
state.tokenize = tokenBase;
|
372
|
+
return ret("comment", "comment");
|
373
|
+
}
|
374
|
+
}
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
// handle CDATA
|
379
|
+
function tokenCDATA(stream, state) {
|
380
|
+
var ch;
|
381
|
+
while (ch = stream.next()) {
|
382
|
+
if (ch == "]" && stream.match("]", true)) {
|
383
|
+
state.tokenize = tokenBase;
|
384
|
+
return ret("comment", "comment");
|
385
|
+
}
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
// handle preprocessing instructions
|
390
|
+
function tokenPreProcessing(stream, state) {
|
391
|
+
var ch;
|
392
|
+
while (ch = stream.next()) {
|
393
|
+
if (ch == "?" && stream.match(">", true)) {
|
394
|
+
state.tokenize = tokenBase;
|
395
|
+
return ret("comment", "comment meta");
|
396
|
+
}
|
397
|
+
}
|
398
|
+
}
|
399
|
+
|
400
|
+
|
401
|
+
// functions to test the current context of the state
|
402
|
+
function isInXmlBlock(state) { return isIn(state, "tag"); }
|
403
|
+
function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
|
404
|
+
function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
|
405
|
+
function isInString(state) { return isIn(state, "string"); }
|
406
|
+
|
407
|
+
function isEQNameAhead(stream) {
|
408
|
+
// assume we've already eaten a quote (")
|
409
|
+
if(stream.current() === '"')
|
410
|
+
return stream.match(/^[^\"]+\"\:/, false);
|
411
|
+
else if(stream.current() === '\'')
|
412
|
+
return stream.match(/^[^\"]+\'\:/, false);
|
413
|
+
else
|
414
|
+
return false;
|
415
|
+
}
|
416
|
+
|
417
|
+
function isIn(state, type) {
|
418
|
+
return (state.stack.length && state.stack[state.stack.length - 1].type == type);
|
419
|
+
}
|
420
|
+
|
421
|
+
function pushStateStack(state, newState) {
|
422
|
+
state.stack.push(newState);
|
423
|
+
}
|
424
|
+
|
425
|
+
function popStateStack(state) {
|
426
|
+
state.stack.pop();
|
427
|
+
var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
|
428
|
+
state.tokenize = reinstateTokenize || tokenBase;
|
429
|
+
}
|
430
|
+
|
431
|
+
// the interface for the mode API
|
432
|
+
return {
|
433
|
+
startState: function() {
|
434
|
+
return {
|
435
|
+
tokenize: tokenBase,
|
436
|
+
cc: [],
|
437
|
+
stack: []
|
438
|
+
};
|
439
|
+
},
|
440
|
+
|
441
|
+
token: function(stream, state) {
|
442
|
+
if (stream.eatSpace()) return null;
|
443
|
+
var style = state.tokenize(stream, state);
|
444
|
+
return style;
|
445
|
+
}
|
446
|
+
};
|
447
|
+
|
448
|
+
});
|
449
|
+
|
450
|
+
CodeMirror.defineMIME("application/xquery", "xquery");
|