jekyll-theme-anc 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +1 -0
- data/_includes/disqus.html +42 -0
- data/_includes/facebook_share_btn.html +1 -0
- data/_includes/footer.html +79 -0
- data/_includes/go2top.html +22 -0
- data/_includes/google-analytics.html +11 -0
- data/_includes/head.html +50 -0
- data/_includes/header.html +13 -0
- data/_includes/jspdf.html +41 -0
- data/_includes/nav.html +25 -0
- data/_includes/pageloginpoper.html +59 -0
- data/_includes/post-categories.html +8 -0
- data/_includes/post_seo.html +59 -0
- data/_includes/youtube_video.html +11 -0
- data/_layouts/blog.html +33 -0
- data/_layouts/default.html +151 -0
- data/_layouts/home.html +26 -0
- data/_layouts/page.html +5 -0
- data/_layouts/post.html +83 -0
- data/_sass/anc.scss +9 -0
- data/_sass/anc/_base.scss +144 -0
- data/_sass/anc/_layout.scss +0 -0
- data/_sass/anc/_materialize.scss +38 -0
- data/_sass/anc/_syntax-highlighting.scss +78 -0
- data/_sass/anc/components/_variables.scss +343 -0
- data/_sass/materialize-css/components/_badges.scss +47 -0
- data/_sass/materialize-css/components/_buttons.scss +291 -0
- data/_sass/materialize-css/components/_cards.scss +196 -0
- data/_sass/materialize-css/components/_carousel.scss +90 -0
- data/_sass/materialize-css/components/_chips.scss +89 -0
- data/_sass/materialize-css/components/_collapsible.scss +84 -0
- data/_sass/materialize-css/components/_color.scss +412 -0
- data/_sass/materialize-css/components/_dropdown.scss +68 -0
- data/_sass/materialize-css/components/_global.scss +734 -0
- data/_sass/materialize-css/components/_grid.scss +156 -0
- data/_sass/materialize-css/components/_icons-material-design.scss +5 -0
- data/_sass/materialize-css/components/_materialbox.scss +43 -0
- data/_sass/materialize-css/components/_modal.scss +90 -0
- data/_sass/materialize-css/components/_navbar.scss +208 -0
- data/_sass/materialize-css/components/_normalize.scss +424 -0
- data/_sass/materialize-css/components/_preloader.scss +334 -0
- data/_sass/materialize-css/components/_pulse.scss +34 -0
- data/_sass/materialize-css/components/_roboto.scss +39 -0
- data/_sass/materialize-css/components/_sideNav.scss +214 -0
- data/_sass/materialize-css/components/_slider.scss +92 -0
- data/_sass/materialize-css/components/_table_of_contents.scss +33 -0
- data/_sass/materialize-css/components/_tabs.scss +93 -0
- data/_sass/materialize-css/components/_tapTarget.scss +103 -0
- data/_sass/materialize-css/components/_toast.scss +59 -0
- data/_sass/materialize-css/components/_tooltip.scss +31 -0
- data/_sass/materialize-css/components/_transitions.scss +13 -0
- data/_sass/materialize-css/components/_typography.scss +61 -0
- data/_sass/materialize-css/components/_variables.scss +343 -0
- data/_sass/materialize-css/components/_waves.scss +114 -0
- data/_sass/materialize-css/components/date_picker/_default.date.scss +456 -0
- data/_sass/materialize-css/components/date_picker/_default.scss +212 -0
- data/_sass/materialize-css/components/date_picker/_default.time.scss +267 -0
- data/_sass/materialize-css/components/forms/_checkboxes.scss +210 -0
- data/_sass/materialize-css/components/forms/_file-input.scss +44 -0
- data/_sass/materialize-css/components/forms/_forms.scss +22 -0
- data/_sass/materialize-css/components/forms/_input-fields.scss +333 -0
- data/_sass/materialize-css/components/forms/_radio-buttons.scss +115 -0
- data/_sass/materialize-css/components/forms/_range.scss +160 -0
- data/_sass/materialize-css/components/forms/_select.scss +182 -0
- data/_sass/materialize-css/components/forms/_switches.scss +89 -0
- data/_sass/materialize-css/materialize.scss +42 -0
- data/_sass/materialize/components/_badges.scss +47 -0
- data/_sass/materialize/components/_buttons.scss +291 -0
- data/_sass/materialize/components/_cards.scss +196 -0
- data/_sass/materialize/components/_carousel.scss +90 -0
- data/_sass/materialize/components/_chips.scss +89 -0
- data/_sass/materialize/components/_collapsible.scss +84 -0
- data/_sass/materialize/components/_color.scss +412 -0
- data/_sass/materialize/components/_dropdown.scss +68 -0
- data/_sass/materialize/components/_global.scss +734 -0
- data/_sass/materialize/components/_grid.scss +156 -0
- data/_sass/materialize/components/_icons-material-design.scss +5 -0
- data/_sass/materialize/components/_materialbox.scss +43 -0
- data/_sass/materialize/components/_modal.scss +90 -0
- data/_sass/materialize/components/_navbar.scss +208 -0
- data/_sass/materialize/components/_normalize.scss +424 -0
- data/_sass/materialize/components/_preloader.scss +334 -0
- data/_sass/materialize/components/_pulse.scss +34 -0
- data/_sass/materialize/components/_roboto.scss +39 -0
- data/_sass/materialize/components/_sideNav.scss +214 -0
- data/_sass/materialize/components/_slider.scss +92 -0
- data/_sass/materialize/components/_table_of_contents.scss +33 -0
- data/_sass/materialize/components/_tabs.scss +93 -0
- data/_sass/materialize/components/_tapTarget.scss +103 -0
- data/_sass/materialize/components/_toast.scss +59 -0
- data/_sass/materialize/components/_tooltip.scss +31 -0
- data/_sass/materialize/components/_transitions.scss +13 -0
- data/_sass/materialize/components/_typography.scss +61 -0
- data/_sass/materialize/components/_variables.scss +343 -0
- data/_sass/materialize/components/_waves.scss +114 -0
- data/_sass/materialize/components/date_picker/_default.date.scss +456 -0
- data/_sass/materialize/components/date_picker/_default.scss +212 -0
- data/_sass/materialize/components/date_picker/_default.time.scss +267 -0
- data/_sass/materialize/components/forms/_checkboxes.scss +210 -0
- data/_sass/materialize/components/forms/_file-input.scss +44 -0
- data/_sass/materialize/components/forms/_forms.scss +22 -0
- data/_sass/materialize/components/forms/_input-fields.scss +333 -0
- data/_sass/materialize/components/forms/_radio-buttons.scss +115 -0
- data/_sass/materialize/components/forms/_range.scss +160 -0
- data/_sass/materialize/components/forms/_select.scss +182 -0
- data/_sass/materialize/components/forms/_switches.scss +89 -0
- data/_sass/materialize/materialize.scss +42 -0
- data/assets/fonts/FontAwesome.otf +0 -0
- data/assets/fonts/fontawesome-webfont.eot +0 -0
- data/assets/fonts/fontawesome-webfont.svg +2671 -0
- data/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/assets/fonts/fontawesome-webfont.woff +0 -0
- data/assets/fonts/fontawesome-webfont.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/assets/images/close.png +0 -0
- data/assets/images/loader.gif +0 -0
- data/assets/img/icons/facebook-square.png +0 -0
- data/assets/img/icons/github-square.png +0 -0
- data/assets/img/icons/twitter-square.png +0 -0
- data/assets/img/icons/youtube-square.png +0 -0
- data/assets/img/jubayed11.37-16.jpg +0 -0
- data/assets/img/parallax1.jpg +0 -0
- data/assets/img/sample-1.jpg +0 -0
- data/assets/js/custom_script.js +200 -0
- data/assets/js/highlight.pack.js +2 -0
- data/assets/js/materialize.min.js +6 -0
- data/assets/js/mode/apl/apl.js +174 -0
- data/assets/js/mode/asciiarmor/asciiarmor.js +74 -0
- data/assets/js/mode/asn.1/asn.1.js +204 -0
- data/assets/js/mode/asterisk/asterisk.js +196 -0
- data/assets/js/mode/brainfuck/brainfuck.js +85 -0
- data/assets/js/mode/clike/clike.js +789 -0
- data/assets/js/mode/clojure/clojure.js +306 -0
- data/assets/js/mode/cmake/cmake.js +97 -0
- data/assets/js/mode/cobol/cobol.js +255 -0
- data/assets/js/mode/coffeescript/coffeescript.js +359 -0
- data/assets/js/mode/commonlisp/commonlisp.js +124 -0
- data/assets/js/mode/crystal/crystal.js +433 -0
- data/assets/js/mode/css/css.js +831 -0
- data/assets/js/mode/cypher/cypher.js +150 -0
- data/assets/js/mode/d/d.js +218 -0
- data/assets/js/mode/dart/dart.js +157 -0
- data/assets/js/mode/diff/diff.js +47 -0
- data/assets/js/mode/django/django.js +356 -0
- data/assets/js/mode/dockerfile/dockerfile.js +79 -0
- data/assets/js/mode/dtd/dtd.js +142 -0
- data/assets/js/mode/dylan/dylan.js +352 -0
- data/assets/js/mode/ebnf/ebnf.js +195 -0
- data/assets/js/mode/ecl/ecl.js +206 -0
- data/assets/js/mode/eiffel/eiffel.js +160 -0
- data/assets/js/mode/elm/elm.js +205 -0
- data/assets/js/mode/erlang/erlang.js +619 -0
- data/assets/js/mode/factor/factor.js +85 -0
- data/assets/js/mode/fcl/fcl.js +173 -0
- data/assets/js/mode/forth/forth.js +180 -0
- data/assets/js/mode/fortran/fortran.js +188 -0
- data/assets/js/mode/gas/gas.js +345 -0
- data/assets/js/mode/gfm/gfm.js +129 -0
- data/assets/js/mode/gherkin/gherkin.js +178 -0
- data/assets/js/mode/go/go.js +187 -0
- data/assets/js/mode/groovy/groovy.js +230 -0
- data/assets/js/mode/haml/haml.js +161 -0
- data/assets/js/mode/handlebars/handlebars.js +62 -0
- data/assets/js/mode/haskell-literate/haskell-literate.js +43 -0
- data/assets/js/mode/haskell/haskell.js +267 -0
- data/assets/js/mode/haxe/haxe.js +515 -0
- data/assets/js/mode/htmlembedded/htmlembedded.js +28 -0
- data/assets/js/mode/htmlmixed/htmlmixed.js +152 -0
- data/assets/js/mode/http/http.js +113 -0
- data/assets/js/mode/idl/idl.js +290 -0
- data/assets/js/mode/javascript/javascript.js +838 -0
- data/assets/js/mode/jinja2/jinja2.js +142 -0
- data/assets/js/mode/jsx/jsx.js +148 -0
- data/assets/js/mode/julia/julia.js +418 -0
- data/assets/js/mode/livescript/livescript.js +280 -0
- data/assets/js/mode/lua/lua.js +159 -0
- data/assets/js/mode/markdown/markdown.js +859 -0
- data/assets/js/mode/mathematica/mathematica.js +176 -0
- data/assets/js/mode/mbox/mbox.js +129 -0
- data/assets/js/mode/meta.js +215 -0
- data/assets/js/mode/mirc/mirc.js +193 -0
- data/assets/js/mode/mllike/mllike.js +208 -0
- data/assets/js/mode/modelica/modelica.js +245 -0
- data/assets/js/mode/mscgen/mscgen.js +175 -0
- data/assets/js/mode/mumps/mumps.js +148 -0
- data/assets/js/mode/nginx/nginx.js +178 -0
- data/assets/js/mode/nsis/nsis.js +95 -0
- data/assets/js/mode/ntriples/ntriples.js +195 -0
- data/assets/js/mode/octave/octave.js +139 -0
- data/assets/js/mode/oz/oz.js +252 -0
- data/assets/js/mode/pascal/pascal.js +109 -0
- data/assets/js/mode/pegjs/pegjs.js +114 -0
- data/assets/js/mode/perl/perl.js +837 -0
- data/assets/js/mode/php/php.js +234 -0
- data/assets/js/mode/pig/pig.js +178 -0
- data/assets/js/mode/powershell/powershell.js +398 -0
- data/assets/js/mode/properties/properties.js +78 -0
- data/assets/js/mode/protobuf/protobuf.js +68 -0
- data/assets/js/mode/pug/pug.js +591 -0
- data/assets/js/mode/puppet/puppet.js +220 -0
- data/assets/js/mode/python/python.js +334 -0
- data/assets/js/mode/q/q.js +139 -0
- data/assets/js/mode/r/r.js +183 -0
- data/assets/js/mode/rpm/changes/index.html +66 -0
- data/assets/js/mode/rpm/rpm.js +109 -0
- data/assets/js/mode/rst/rst.js +557 -0
- data/assets/js/mode/ruby/ruby.js +295 -0
- data/assets/js/mode/rust/rust.js +72 -0
- data/assets/js/mode/sas/sas.js +303 -0
- data/assets/js/mode/sass/sass.js +454 -0
- data/assets/js/mode/scheme/scheme.js +249 -0
- data/assets/js/mode/shell/shell.js +142 -0
- data/assets/js/mode/sieve/sieve.js +193 -0
- data/assets/js/mode/slim/slim.js +575 -0
- data/assets/js/mode/smalltalk/smalltalk.js +168 -0
- data/assets/js/mode/smarty/smarty.js +225 -0
- data/assets/js/mode/solr/solr.js +104 -0
- data/assets/js/mode/soy/soy.js +342 -0
- data/assets/js/mode/sparql/sparql.js +180 -0
- data/assets/js/mode/spreadsheet/spreadsheet.js +112 -0
- data/assets/js/mode/sql/sql.js +475 -0
- data/assets/js/mode/stex/stex.js +251 -0
- data/assets/js/mode/stylus/stylus.js +771 -0
- data/assets/js/mode/swift/swift.js +210 -0
- data/assets/js/mode/tcl/tcl.js +139 -0
- data/assets/js/mode/textile/textile.js +469 -0
- data/assets/js/mode/tiddlywiki/tiddlywiki.css +14 -0
- data/assets/js/mode/tiddlywiki/tiddlywiki.js +308 -0
- data/assets/js/mode/tiki/tiki.css +26 -0
- data/assets/js/mode/tiki/tiki.js +312 -0
- data/assets/js/mode/toml/toml.js +88 -0
- data/assets/js/mode/tornado/tornado.js +68 -0
- data/assets/js/mode/troff/troff.js +84 -0
- data/assets/js/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- data/assets/js/mode/ttcn/ttcn.js +283 -0
- data/assets/js/mode/turtle/turtle.js +162 -0
- data/assets/js/mode/twig/twig.js +141 -0
- data/assets/js/mode/vb/vb.js +275 -0
- data/assets/js/mode/vbscript/vbscript.js +350 -0
- data/assets/js/mode/velocity/velocity.js +201 -0
- data/assets/js/mode/verilog/verilog.js +675 -0
- data/assets/js/mode/vhdl/vhdl.js +189 -0
- data/assets/js/mode/vue/vue.js +70 -0
- data/assets/js/mode/webidl/webidl.js +195 -0
- data/assets/js/mode/xml/xml.js +394 -0
- data/assets/js/mode/xquery/xquery.js +448 -0
- data/assets/js/mode/yacas/yacas.js +204 -0
- data/assets/js/mode/yaml-frontmatter/yaml-frontmatter.js +68 -0
- data/assets/js/mode/yaml/yaml.js +118 -0
- data/assets/js/mode/z80/z80.js +116 -0
- data/assets/main.scss +5 -0
- metadata +347 -0
@@ -0,0 +1,394 @@
|
|
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"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
var htmlConfig = {
|
15
|
+
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
16
|
+
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
17
|
+
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
18
|
+
'track': true, 'wbr': true, 'menuitem': true},
|
19
|
+
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
20
|
+
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
21
|
+
'th': true, 'tr': true},
|
22
|
+
contextGrabbers: {
|
23
|
+
'dd': {'dd': true, 'dt': true},
|
24
|
+
'dt': {'dd': true, 'dt': true},
|
25
|
+
'li': {'li': true},
|
26
|
+
'option': {'option': true, 'optgroup': true},
|
27
|
+
'optgroup': {'optgroup': true},
|
28
|
+
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
29
|
+
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
30
|
+
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
31
|
+
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
32
|
+
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
33
|
+
'rp': {'rp': true, 'rt': true},
|
34
|
+
'rt': {'rp': true, 'rt': true},
|
35
|
+
'tbody': {'tbody': true, 'tfoot': true},
|
36
|
+
'td': {'td': true, 'th': true},
|
37
|
+
'tfoot': {'tbody': true},
|
38
|
+
'th': {'td': true, 'th': true},
|
39
|
+
'thead': {'tbody': true, 'tfoot': true},
|
40
|
+
'tr': {'tr': true}
|
41
|
+
},
|
42
|
+
doNotIndent: {"pre": true},
|
43
|
+
allowUnquoted: true,
|
44
|
+
allowMissing: true,
|
45
|
+
caseFold: true
|
46
|
+
}
|
47
|
+
|
48
|
+
var xmlConfig = {
|
49
|
+
autoSelfClosers: {},
|
50
|
+
implicitlyClosed: {},
|
51
|
+
contextGrabbers: {},
|
52
|
+
doNotIndent: {},
|
53
|
+
allowUnquoted: false,
|
54
|
+
allowMissing: false,
|
55
|
+
caseFold: false
|
56
|
+
}
|
57
|
+
|
58
|
+
CodeMirror.defineMode("xml", function(editorConf, config_) {
|
59
|
+
var indentUnit = editorConf.indentUnit
|
60
|
+
var config = {}
|
61
|
+
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
|
62
|
+
for (var prop in defaults) config[prop] = defaults[prop]
|
63
|
+
for (var prop in config_) config[prop] = config_[prop]
|
64
|
+
|
65
|
+
// Return variables for tokenizers
|
66
|
+
var type, setStyle;
|
67
|
+
|
68
|
+
function inText(stream, state) {
|
69
|
+
function chain(parser) {
|
70
|
+
state.tokenize = parser;
|
71
|
+
return parser(stream, state);
|
72
|
+
}
|
73
|
+
|
74
|
+
var ch = stream.next();
|
75
|
+
if (ch == "<") {
|
76
|
+
if (stream.eat("!")) {
|
77
|
+
if (stream.eat("[")) {
|
78
|
+
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
79
|
+
else return null;
|
80
|
+
} else if (stream.match("--")) {
|
81
|
+
return chain(inBlock("comment", "-->"));
|
82
|
+
} else if (stream.match("DOCTYPE", true, true)) {
|
83
|
+
stream.eatWhile(/[\w\._\-]/);
|
84
|
+
return chain(doctype(1));
|
85
|
+
} else {
|
86
|
+
return null;
|
87
|
+
}
|
88
|
+
} else if (stream.eat("?")) {
|
89
|
+
stream.eatWhile(/[\w\._\-]/);
|
90
|
+
state.tokenize = inBlock("meta", "?>");
|
91
|
+
return "meta";
|
92
|
+
} else {
|
93
|
+
type = stream.eat("/") ? "closeTag" : "openTag";
|
94
|
+
state.tokenize = inTag;
|
95
|
+
return "tag bracket";
|
96
|
+
}
|
97
|
+
} else if (ch == "&") {
|
98
|
+
var ok;
|
99
|
+
if (stream.eat("#")) {
|
100
|
+
if (stream.eat("x")) {
|
101
|
+
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
102
|
+
} else {
|
103
|
+
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
104
|
+
}
|
105
|
+
} else {
|
106
|
+
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
107
|
+
}
|
108
|
+
return ok ? "atom" : "error";
|
109
|
+
} else {
|
110
|
+
stream.eatWhile(/[^&<]/);
|
111
|
+
return null;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
inText.isInText = true;
|
115
|
+
|
116
|
+
function inTag(stream, state) {
|
117
|
+
var ch = stream.next();
|
118
|
+
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
119
|
+
state.tokenize = inText;
|
120
|
+
type = ch == ">" ? "endTag" : "selfcloseTag";
|
121
|
+
return "tag bracket";
|
122
|
+
} else if (ch == "=") {
|
123
|
+
type = "equals";
|
124
|
+
return null;
|
125
|
+
} else if (ch == "<") {
|
126
|
+
state.tokenize = inText;
|
127
|
+
state.state = baseState;
|
128
|
+
state.tagName = state.tagStart = null;
|
129
|
+
var next = state.tokenize(stream, state);
|
130
|
+
return next ? next + " tag error" : "tag error";
|
131
|
+
} else if (/[\'\"]/.test(ch)) {
|
132
|
+
state.tokenize = inAttribute(ch);
|
133
|
+
state.stringStartCol = stream.column();
|
134
|
+
return state.tokenize(stream, state);
|
135
|
+
} else {
|
136
|
+
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
137
|
+
return "word";
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
function inAttribute(quote) {
|
142
|
+
var closure = function(stream, state) {
|
143
|
+
while (!stream.eol()) {
|
144
|
+
if (stream.next() == quote) {
|
145
|
+
state.tokenize = inTag;
|
146
|
+
break;
|
147
|
+
}
|
148
|
+
}
|
149
|
+
return "string";
|
150
|
+
};
|
151
|
+
closure.isInAttribute = true;
|
152
|
+
return closure;
|
153
|
+
}
|
154
|
+
|
155
|
+
function inBlock(style, terminator) {
|
156
|
+
return function(stream, state) {
|
157
|
+
while (!stream.eol()) {
|
158
|
+
if (stream.match(terminator)) {
|
159
|
+
state.tokenize = inText;
|
160
|
+
break;
|
161
|
+
}
|
162
|
+
stream.next();
|
163
|
+
}
|
164
|
+
return style;
|
165
|
+
};
|
166
|
+
}
|
167
|
+
function doctype(depth) {
|
168
|
+
return function(stream, state) {
|
169
|
+
var ch;
|
170
|
+
while ((ch = stream.next()) != null) {
|
171
|
+
if (ch == "<") {
|
172
|
+
state.tokenize = doctype(depth + 1);
|
173
|
+
return state.tokenize(stream, state);
|
174
|
+
} else if (ch == ">") {
|
175
|
+
if (depth == 1) {
|
176
|
+
state.tokenize = inText;
|
177
|
+
break;
|
178
|
+
} else {
|
179
|
+
state.tokenize = doctype(depth - 1);
|
180
|
+
return state.tokenize(stream, state);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
return "meta";
|
185
|
+
};
|
186
|
+
}
|
187
|
+
|
188
|
+
function Context(state, tagName, startOfLine) {
|
189
|
+
this.prev = state.context;
|
190
|
+
this.tagName = tagName;
|
191
|
+
this.indent = state.indented;
|
192
|
+
this.startOfLine = startOfLine;
|
193
|
+
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
194
|
+
this.noIndent = true;
|
195
|
+
}
|
196
|
+
function popContext(state) {
|
197
|
+
if (state.context) state.context = state.context.prev;
|
198
|
+
}
|
199
|
+
function maybePopContext(state, nextTagName) {
|
200
|
+
var parentTagName;
|
201
|
+
while (true) {
|
202
|
+
if (!state.context) {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
parentTagName = state.context.tagName;
|
206
|
+
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
|
207
|
+
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
208
|
+
return;
|
209
|
+
}
|
210
|
+
popContext(state);
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
function baseState(type, stream, state) {
|
215
|
+
if (type == "openTag") {
|
216
|
+
state.tagStart = stream.column();
|
217
|
+
return tagNameState;
|
218
|
+
} else if (type == "closeTag") {
|
219
|
+
return closeTagNameState;
|
220
|
+
} else {
|
221
|
+
return baseState;
|
222
|
+
}
|
223
|
+
}
|
224
|
+
function tagNameState(type, stream, state) {
|
225
|
+
if (type == "word") {
|
226
|
+
state.tagName = stream.current();
|
227
|
+
setStyle = "tag";
|
228
|
+
return attrState;
|
229
|
+
} else {
|
230
|
+
setStyle = "error";
|
231
|
+
return tagNameState;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
function closeTagNameState(type, stream, state) {
|
235
|
+
if (type == "word") {
|
236
|
+
var tagName = stream.current();
|
237
|
+
if (state.context && state.context.tagName != tagName &&
|
238
|
+
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
239
|
+
popContext(state);
|
240
|
+
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
|
241
|
+
setStyle = "tag";
|
242
|
+
return closeState;
|
243
|
+
} else {
|
244
|
+
setStyle = "tag error";
|
245
|
+
return closeStateErr;
|
246
|
+
}
|
247
|
+
} else {
|
248
|
+
setStyle = "error";
|
249
|
+
return closeStateErr;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
function closeState(type, _stream, state) {
|
254
|
+
if (type != "endTag") {
|
255
|
+
setStyle = "error";
|
256
|
+
return closeState;
|
257
|
+
}
|
258
|
+
popContext(state);
|
259
|
+
return baseState;
|
260
|
+
}
|
261
|
+
function closeStateErr(type, stream, state) {
|
262
|
+
setStyle = "error";
|
263
|
+
return closeState(type, stream, state);
|
264
|
+
}
|
265
|
+
|
266
|
+
function attrState(type, _stream, state) {
|
267
|
+
if (type == "word") {
|
268
|
+
setStyle = "attribute";
|
269
|
+
return attrEqState;
|
270
|
+
} else if (type == "endTag" || type == "selfcloseTag") {
|
271
|
+
var tagName = state.tagName, tagStart = state.tagStart;
|
272
|
+
state.tagName = state.tagStart = null;
|
273
|
+
if (type == "selfcloseTag" ||
|
274
|
+
config.autoSelfClosers.hasOwnProperty(tagName)) {
|
275
|
+
maybePopContext(state, tagName);
|
276
|
+
} else {
|
277
|
+
maybePopContext(state, tagName);
|
278
|
+
state.context = new Context(state, tagName, tagStart == state.indented);
|
279
|
+
}
|
280
|
+
return baseState;
|
281
|
+
}
|
282
|
+
setStyle = "error";
|
283
|
+
return attrState;
|
284
|
+
}
|
285
|
+
function attrEqState(type, stream, state) {
|
286
|
+
if (type == "equals") return attrValueState;
|
287
|
+
if (!config.allowMissing) setStyle = "error";
|
288
|
+
return attrState(type, stream, state);
|
289
|
+
}
|
290
|
+
function attrValueState(type, stream, state) {
|
291
|
+
if (type == "string") return attrContinuedState;
|
292
|
+
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
|
293
|
+
setStyle = "error";
|
294
|
+
return attrState(type, stream, state);
|
295
|
+
}
|
296
|
+
function attrContinuedState(type, stream, state) {
|
297
|
+
if (type == "string") return attrContinuedState;
|
298
|
+
return attrState(type, stream, state);
|
299
|
+
}
|
300
|
+
|
301
|
+
return {
|
302
|
+
startState: function(baseIndent) {
|
303
|
+
var state = {tokenize: inText,
|
304
|
+
state: baseState,
|
305
|
+
indented: baseIndent || 0,
|
306
|
+
tagName: null, tagStart: null,
|
307
|
+
context: null}
|
308
|
+
if (baseIndent != null) state.baseIndent = baseIndent
|
309
|
+
return state
|
310
|
+
},
|
311
|
+
|
312
|
+
token: function(stream, state) {
|
313
|
+
if (!state.tagName && stream.sol())
|
314
|
+
state.indented = stream.indentation();
|
315
|
+
|
316
|
+
if (stream.eatSpace()) return null;
|
317
|
+
type = null;
|
318
|
+
var style = state.tokenize(stream, state);
|
319
|
+
if ((style || type) && style != "comment") {
|
320
|
+
setStyle = null;
|
321
|
+
state.state = state.state(type || style, stream, state);
|
322
|
+
if (setStyle)
|
323
|
+
style = setStyle == "error" ? style + " error" : setStyle;
|
324
|
+
}
|
325
|
+
return style;
|
326
|
+
},
|
327
|
+
|
328
|
+
indent: function(state, textAfter, fullLine) {
|
329
|
+
var context = state.context;
|
330
|
+
// Indent multi-line strings (e.g. css).
|
331
|
+
if (state.tokenize.isInAttribute) {
|
332
|
+
if (state.tagStart == state.indented)
|
333
|
+
return state.stringStartCol + 1;
|
334
|
+
else
|
335
|
+
return state.indented + indentUnit;
|
336
|
+
}
|
337
|
+
if (context && context.noIndent) return CodeMirror.Pass;
|
338
|
+
if (state.tokenize != inTag && state.tokenize != inText)
|
339
|
+
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
340
|
+
// Indent the starts of attribute names.
|
341
|
+
if (state.tagName) {
|
342
|
+
if (config.multilineTagIndentPastTag !== false)
|
343
|
+
return state.tagStart + state.tagName.length + 2;
|
344
|
+
else
|
345
|
+
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
|
346
|
+
}
|
347
|
+
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
348
|
+
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
349
|
+
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
350
|
+
while (context) {
|
351
|
+
if (context.tagName == tagAfter[2]) {
|
352
|
+
context = context.prev;
|
353
|
+
break;
|
354
|
+
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
355
|
+
context = context.prev;
|
356
|
+
} else {
|
357
|
+
break;
|
358
|
+
}
|
359
|
+
}
|
360
|
+
} else if (tagAfter) { // Opening tag spotted
|
361
|
+
while (context) {
|
362
|
+
var grabbers = config.contextGrabbers[context.tagName];
|
363
|
+
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
364
|
+
context = context.prev;
|
365
|
+
else
|
366
|
+
break;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
while (context && context.prev && !context.startOfLine)
|
370
|
+
context = context.prev;
|
371
|
+
if (context) return context.indent + indentUnit;
|
372
|
+
else return state.baseIndent || 0;
|
373
|
+
},
|
374
|
+
|
375
|
+
electricInput: /<\/[\s\w:]+>$/,
|
376
|
+
blockCommentStart: "<!--",
|
377
|
+
blockCommentEnd: "-->",
|
378
|
+
|
379
|
+
configuration: config.htmlMode ? "html" : "xml",
|
380
|
+
helperType: config.htmlMode ? "html" : "xml",
|
381
|
+
|
382
|
+
skipAttribute: function(state) {
|
383
|
+
if (state.state == attrValueState)
|
384
|
+
state.state = attrState
|
385
|
+
}
|
386
|
+
};
|
387
|
+
});
|
388
|
+
|
389
|
+
CodeMirror.defineMIME("text/xml", "xml");
|
390
|
+
CodeMirror.defineMIME("application/xml", "xml");
|
391
|
+
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
392
|
+
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
393
|
+
|
394
|
+
});
|
@@ -0,0 +1,448 @@
|
|
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"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("xquery", function() {
|
15
|
+
|
16
|
+
// The keywords object is set to the result of this self executing
|
17
|
+
// function. Each keyword is a property of the keywords object whose
|
18
|
+
// value is {type: atype, style: astyle}
|
19
|
+
var keywords = function(){
|
20
|
+
// convenience functions used to build keywords object
|
21
|
+
function kw(type) {return {type: type, style: "keyword"};}
|
22
|
+
var operator = kw("operator")
|
23
|
+
, atom = {type: "atom", style: "atom"}
|
24
|
+
, punctuation = {type: "punctuation", style: null}
|
25
|
+
, qualifier = {type: "axis_specifier", style: "qualifier"};
|
26
|
+
|
27
|
+
// kwObj is what is return from this function at the end
|
28
|
+
var kwObj = {
|
29
|
+
',': punctuation
|
30
|
+
};
|
31
|
+
|
32
|
+
// a list of 'basic' keywords. For each add a property to kwObj with the value of
|
33
|
+
// {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
|
34
|
+
var basic = ['after', 'all', 'allowing', 'ancestor', 'ancestor-or-self', 'any', 'array', 'as',
|
35
|
+
'ascending', 'at', 'attribute', 'base-uri', 'before', 'boundary-space', 'by', 'case', 'cast',
|
36
|
+
'castable', 'catch', 'child', 'collation', 'comment', 'construction', 'contains', 'content',
|
37
|
+
'context', 'copy', 'copy-namespaces', 'count', 'decimal-format', 'declare', 'default', 'delete',
|
38
|
+
'descendant', 'descendant-or-self', 'descending', 'diacritics', 'different', 'distance',
|
39
|
+
'document', 'document-node', 'element', 'else', 'empty', 'empty-sequence', 'encoding', 'end',
|
40
|
+
'entire', 'every', 'exactly', 'except', 'external', 'first', 'following', 'following-sibling',
|
41
|
+
'for', 'from', 'ftand', 'ftnot', 'ft-option', 'ftor', 'function', 'fuzzy', 'greatest', 'group',
|
42
|
+
'if', 'import', 'in', 'inherit', 'insensitive', 'insert', 'instance', 'intersect', 'into',
|
43
|
+
'invoke', 'is', 'item', 'language', 'last', 'lax', 'least', 'let', 'levels', 'lowercase', 'map',
|
44
|
+
'modify', 'module', 'most', 'namespace', 'next', 'no', 'node', 'nodes', 'no-inherit',
|
45
|
+
'no-preserve', 'not', 'occurs', 'of', 'only', 'option', 'order', 'ordered', 'ordering',
|
46
|
+
'paragraph', 'paragraphs', 'parent', 'phrase', 'preceding', 'preceding-sibling', 'preserve',
|
47
|
+
'previous', 'processing-instruction', 'relationship', 'rename', 'replace', 'return',
|
48
|
+
'revalidation', 'same', 'satisfies', 'schema', 'schema-attribute', 'schema-element', 'score',
|
49
|
+
'self', 'sensitive', 'sentence', 'sentences', 'sequence', 'skip', 'sliding', 'some', 'stable',
|
50
|
+
'start', 'stemming', 'stop', 'strict', 'strip', 'switch', 'text', 'then', 'thesaurus', 'times',
|
51
|
+
'to', 'transform', 'treat', 'try', 'tumbling', 'type', 'typeswitch', 'union', 'unordered',
|
52
|
+
'update', 'updating', 'uppercase', 'using', 'validate', 'value', 'variable', 'version',
|
53
|
+
'weight', 'when', 'where', 'wildcards', 'window', 'with', 'without', 'word', 'words', 'xquery'];
|
54
|
+
for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
|
55
|
+
|
56
|
+
// a list of types. For each add a property to kwObj with the value of
|
57
|
+
// {type: "atom", style: "atom"}
|
58
|
+
var types = ['xs:anyAtomicType', 'xs:anySimpleType', 'xs:anyType', 'xs:anyURI',
|
59
|
+
'xs:base64Binary', 'xs:boolean', 'xs:byte', 'xs:date', 'xs:dateTime', 'xs:dateTimeStamp',
|
60
|
+
'xs:dayTimeDuration', 'xs:decimal', 'xs:double', 'xs:duration', 'xs:ENTITIES', 'xs:ENTITY',
|
61
|
+
'xs:float', 'xs:gDay', 'xs:gMonth', 'xs:gMonthDay', 'xs:gYear', 'xs:gYearMonth', 'xs:hexBinary',
|
62
|
+
'xs:ID', 'xs:IDREF', 'xs:IDREFS', 'xs:int', 'xs:integer', 'xs:item', 'xs:java', 'xs:language',
|
63
|
+
'xs:long', 'xs:Name', 'xs:NCName', 'xs:negativeInteger', 'xs:NMTOKEN', 'xs:NMTOKENS',
|
64
|
+
'xs:nonNegativeInteger', 'xs:nonPositiveInteger', 'xs:normalizedString', 'xs:NOTATION',
|
65
|
+
'xs:numeric', 'xs:positiveInteger', 'xs:precisionDecimal', 'xs:QName', 'xs:short', 'xs:string',
|
66
|
+
'xs:time', 'xs:token', 'xs:unsignedByte', 'xs:unsignedInt', 'xs:unsignedLong',
|
67
|
+
'xs:unsignedShort', 'xs:untyped', 'xs:untypedAtomic', 'xs:yearMonthDuration'];
|
68
|
+
for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
|
69
|
+
|
70
|
+
// each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
|
71
|
+
var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
|
72
|
+
for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
|
73
|
+
|
74
|
+
// each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
|
75
|
+
var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
|
76
|
+
"ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
|
77
|
+
for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
|
78
|
+
|
79
|
+
return kwObj;
|
80
|
+
}();
|
81
|
+
|
82
|
+
function chain(stream, state, f) {
|
83
|
+
state.tokenize = f;
|
84
|
+
return f(stream, state);
|
85
|
+
}
|
86
|
+
|
87
|
+
// the primary mode tokenizer
|
88
|
+
function tokenBase(stream, state) {
|
89
|
+
var ch = stream.next(),
|
90
|
+
mightBeFunction = false,
|
91
|
+
isEQName = isEQNameAhead(stream);
|
92
|
+
|
93
|
+
// an XML tag (if not in some sub, chained tokenizer)
|
94
|
+
if (ch == "<") {
|
95
|
+
if(stream.match("!--", true))
|
96
|
+
return chain(stream, state, tokenXMLComment);
|
97
|
+
|
98
|
+
if(stream.match("![CDATA", false)) {
|
99
|
+
state.tokenize = tokenCDATA;
|
100
|
+
return "tag";
|
101
|
+
}
|
102
|
+
|
103
|
+
if(stream.match("?", false)) {
|
104
|
+
return chain(stream, state, tokenPreProcessing);
|
105
|
+
}
|
106
|
+
|
107
|
+
var isclose = stream.eat("/");
|
108
|
+
stream.eatSpace();
|
109
|
+
var tagName = "", c;
|
110
|
+
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
|
111
|
+
|
112
|
+
return chain(stream, state, tokenTag(tagName, isclose));
|
113
|
+
}
|
114
|
+
// start code block
|
115
|
+
else if(ch == "{") {
|
116
|
+
pushStateStack(state, { type: "codeblock"});
|
117
|
+
return null;
|
118
|
+
}
|
119
|
+
// end code block
|
120
|
+
else if(ch == "}") {
|
121
|
+
popStateStack(state);
|
122
|
+
return null;
|
123
|
+
}
|
124
|
+
// if we're in an XML block
|
125
|
+
else if(isInXmlBlock(state)) {
|
126
|
+
if(ch == ">")
|
127
|
+
return "tag";
|
128
|
+
else if(ch == "/" && stream.eat(">")) {
|
129
|
+
popStateStack(state);
|
130
|
+
return "tag";
|
131
|
+
}
|
132
|
+
else
|
133
|
+
return "variable";
|
134
|
+
}
|
135
|
+
// if a number
|
136
|
+
else if (/\d/.test(ch)) {
|
137
|
+
stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
|
138
|
+
return "atom";
|
139
|
+
}
|
140
|
+
// comment start
|
141
|
+
else if (ch === "(" && stream.eat(":")) {
|
142
|
+
pushStateStack(state, { type: "comment"});
|
143
|
+
return chain(stream, state, tokenComment);
|
144
|
+
}
|
145
|
+
// quoted string
|
146
|
+
else if (!isEQName && (ch === '"' || ch === "'"))
|
147
|
+
return chain(stream, state, tokenString(ch));
|
148
|
+
// variable
|
149
|
+
else if(ch === "$") {
|
150
|
+
return chain(stream, state, tokenVariable);
|
151
|
+
}
|
152
|
+
// assignment
|
153
|
+
else if(ch ===":" && stream.eat("=")) {
|
154
|
+
return "keyword";
|
155
|
+
}
|
156
|
+
// open paren
|
157
|
+
else if(ch === "(") {
|
158
|
+
pushStateStack(state, { type: "paren"});
|
159
|
+
return null;
|
160
|
+
}
|
161
|
+
// close paren
|
162
|
+
else if(ch === ")") {
|
163
|
+
popStateStack(state);
|
164
|
+
return null;
|
165
|
+
}
|
166
|
+
// open paren
|
167
|
+
else if(ch === "[") {
|
168
|
+
pushStateStack(state, { type: "bracket"});
|
169
|
+
return null;
|
170
|
+
}
|
171
|
+
// close paren
|
172
|
+
else if(ch === "]") {
|
173
|
+
popStateStack(state);
|
174
|
+
return null;
|
175
|
+
}
|
176
|
+
else {
|
177
|
+
var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
|
178
|
+
|
179
|
+
// if there's a EQName ahead, consume the rest of the string portion, it's likely a function
|
180
|
+
if(isEQName && ch === '\"') while(stream.next() !== '"'){}
|
181
|
+
if(isEQName && ch === '\'') while(stream.next() !== '\''){}
|
182
|
+
|
183
|
+
// gobble up a word if the character is not known
|
184
|
+
if(!known) stream.eatWhile(/[\w\$_-]/);
|
185
|
+
|
186
|
+
// gobble a colon in the case that is a lib func type call fn:doc
|
187
|
+
var foundColon = stream.eat(":");
|
188
|
+
|
189
|
+
// if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
|
190
|
+
// which should get matched as a keyword
|
191
|
+
if(!stream.eat(":") && foundColon) {
|
192
|
+
stream.eatWhile(/[\w\$_-]/);
|
193
|
+
}
|
194
|
+
// if the next non whitespace character is an open paren, this is probably a function (if not a keyword of other sort)
|
195
|
+
if(stream.match(/^[ \t]*\(/, false)) {
|
196
|
+
mightBeFunction = true;
|
197
|
+
}
|
198
|
+
// is the word a keyword?
|
199
|
+
var word = stream.current();
|
200
|
+
known = keywords.propertyIsEnumerable(word) && keywords[word];
|
201
|
+
|
202
|
+
// if we think it's a function call but not yet known,
|
203
|
+
// set style to variable for now for lack of something better
|
204
|
+
if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
|
205
|
+
|
206
|
+
// if the previous word was element, attribute, axis specifier, this word should be the name of that
|
207
|
+
if(isInXmlConstructor(state)) {
|
208
|
+
popStateStack(state);
|
209
|
+
return "variable";
|
210
|
+
}
|
211
|
+
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
|
212
|
+
// push the stack so we know to look for it on the next word
|
213
|
+
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
|
214
|
+
|
215
|
+
// if the word is known, return the details of that else just call this a generic 'word'
|
216
|
+
return known ? known.style : "variable";
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
// handle comments, including nested
|
221
|
+
function tokenComment(stream, state) {
|
222
|
+
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
|
223
|
+
while (ch = stream.next()) {
|
224
|
+
if (ch == ")" && maybeEnd) {
|
225
|
+
if(nestedCount > 0)
|
226
|
+
nestedCount--;
|
227
|
+
else {
|
228
|
+
popStateStack(state);
|
229
|
+
break;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
else if(ch == ":" && maybeNested) {
|
233
|
+
nestedCount++;
|
234
|
+
}
|
235
|
+
maybeEnd = (ch == ":");
|
236
|
+
maybeNested = (ch == "(");
|
237
|
+
}
|
238
|
+
|
239
|
+
return "comment";
|
240
|
+
}
|
241
|
+
|
242
|
+
// tokenizer for string literals
|
243
|
+
// optionally pass a tokenizer function to set state.tokenize back to when finished
|
244
|
+
function tokenString(quote, f) {
|
245
|
+
return function(stream, state) {
|
246
|
+
var ch;
|
247
|
+
|
248
|
+
if(isInString(state) && stream.current() == quote) {
|
249
|
+
popStateStack(state);
|
250
|
+
if(f) state.tokenize = f;
|
251
|
+
return "string";
|
252
|
+
}
|
253
|
+
|
254
|
+
pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
|
255
|
+
|
256
|
+
// if we're in a string and in an XML block, allow an embedded code block
|
257
|
+
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
258
|
+
state.tokenize = tokenBase;
|
259
|
+
return "string";
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
while (ch = stream.next()) {
|
264
|
+
if (ch == quote) {
|
265
|
+
popStateStack(state);
|
266
|
+
if(f) state.tokenize = f;
|
267
|
+
break;
|
268
|
+
}
|
269
|
+
else {
|
270
|
+
// if we're in a string and in an XML block, allow an embedded code block in an attribute
|
271
|
+
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
|
272
|
+
state.tokenize = tokenBase;
|
273
|
+
return "string";
|
274
|
+
}
|
275
|
+
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
return "string";
|
280
|
+
};
|
281
|
+
}
|
282
|
+
|
283
|
+
// tokenizer for variables
|
284
|
+
function tokenVariable(stream, state) {
|
285
|
+
var isVariableChar = /[\w\$_-]/;
|
286
|
+
|
287
|
+
// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
|
288
|
+
if(stream.eat("\"")) {
|
289
|
+
while(stream.next() !== '\"'){};
|
290
|
+
stream.eat(":");
|
291
|
+
} else {
|
292
|
+
stream.eatWhile(isVariableChar);
|
293
|
+
if(!stream.match(":=", false)) stream.eat(":");
|
294
|
+
}
|
295
|
+
stream.eatWhile(isVariableChar);
|
296
|
+
state.tokenize = tokenBase;
|
297
|
+
return "variable";
|
298
|
+
}
|
299
|
+
|
300
|
+
// tokenizer for XML tags
|
301
|
+
function tokenTag(name, isclose) {
|
302
|
+
return function(stream, state) {
|
303
|
+
stream.eatSpace();
|
304
|
+
if(isclose && stream.eat(">")) {
|
305
|
+
popStateStack(state);
|
306
|
+
state.tokenize = tokenBase;
|
307
|
+
return "tag";
|
308
|
+
}
|
309
|
+
// self closing tag without attributes?
|
310
|
+
if(!stream.eat("/"))
|
311
|
+
pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
|
312
|
+
if(!stream.eat(">")) {
|
313
|
+
state.tokenize = tokenAttribute;
|
314
|
+
return "tag";
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
state.tokenize = tokenBase;
|
318
|
+
}
|
319
|
+
return "tag";
|
320
|
+
};
|
321
|
+
}
|
322
|
+
|
323
|
+
// tokenizer for XML attributes
|
324
|
+
function tokenAttribute(stream, state) {
|
325
|
+
var ch = stream.next();
|
326
|
+
|
327
|
+
if(ch == "/" && stream.eat(">")) {
|
328
|
+
if(isInXmlAttributeBlock(state)) popStateStack(state);
|
329
|
+
if(isInXmlBlock(state)) popStateStack(state);
|
330
|
+
return "tag";
|
331
|
+
}
|
332
|
+
if(ch == ">") {
|
333
|
+
if(isInXmlAttributeBlock(state)) popStateStack(state);
|
334
|
+
return "tag";
|
335
|
+
}
|
336
|
+
if(ch == "=")
|
337
|
+
return null;
|
338
|
+
// quoted string
|
339
|
+
if (ch == '"' || ch == "'")
|
340
|
+
return chain(stream, state, tokenString(ch, tokenAttribute));
|
341
|
+
|
342
|
+
if(!isInXmlAttributeBlock(state))
|
343
|
+
pushStateStack(state, { type: "attribute", tokenize: tokenAttribute});
|
344
|
+
|
345
|
+
stream.eat(/[a-zA-Z_:]/);
|
346
|
+
stream.eatWhile(/[-a-zA-Z0-9_:.]/);
|
347
|
+
stream.eatSpace();
|
348
|
+
|
349
|
+
// the case where the attribute has not value and the tag was closed
|
350
|
+
if(stream.match(">", false) || stream.match("/", false)) {
|
351
|
+
popStateStack(state);
|
352
|
+
state.tokenize = tokenBase;
|
353
|
+
}
|
354
|
+
|
355
|
+
return "attribute";
|
356
|
+
}
|
357
|
+
|
358
|
+
// handle comments, including nested
|
359
|
+
function tokenXMLComment(stream, state) {
|
360
|
+
var ch;
|
361
|
+
while (ch = stream.next()) {
|
362
|
+
if (ch == "-" && stream.match("->", true)) {
|
363
|
+
state.tokenize = tokenBase;
|
364
|
+
return "comment";
|
365
|
+
}
|
366
|
+
}
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
// handle CDATA
|
371
|
+
function tokenCDATA(stream, state) {
|
372
|
+
var ch;
|
373
|
+
while (ch = stream.next()) {
|
374
|
+
if (ch == "]" && stream.match("]", true)) {
|
375
|
+
state.tokenize = tokenBase;
|
376
|
+
return "comment";
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
// handle preprocessing instructions
|
382
|
+
function tokenPreProcessing(stream, state) {
|
383
|
+
var ch;
|
384
|
+
while (ch = stream.next()) {
|
385
|
+
if (ch == "?" && stream.match(">", true)) {
|
386
|
+
state.tokenize = tokenBase;
|
387
|
+
return "comment meta";
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|
392
|
+
|
393
|
+
// functions to test the current context of the state
|
394
|
+
function isInXmlBlock(state) { return isIn(state, "tag"); }
|
395
|
+
function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
|
396
|
+
function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
|
397
|
+
function isInString(state) { return isIn(state, "string"); }
|
398
|
+
|
399
|
+
function isEQNameAhead(stream) {
|
400
|
+
// assume we've already eaten a quote (")
|
401
|
+
if(stream.current() === '"')
|
402
|
+
return stream.match(/^[^\"]+\"\:/, false);
|
403
|
+
else if(stream.current() === '\'')
|
404
|
+
return stream.match(/^[^\"]+\'\:/, false);
|
405
|
+
else
|
406
|
+
return false;
|
407
|
+
}
|
408
|
+
|
409
|
+
function isIn(state, type) {
|
410
|
+
return (state.stack.length && state.stack[state.stack.length - 1].type == type);
|
411
|
+
}
|
412
|
+
|
413
|
+
function pushStateStack(state, newState) {
|
414
|
+
state.stack.push(newState);
|
415
|
+
}
|
416
|
+
|
417
|
+
function popStateStack(state) {
|
418
|
+
state.stack.pop();
|
419
|
+
var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
|
420
|
+
state.tokenize = reinstateTokenize || tokenBase;
|
421
|
+
}
|
422
|
+
|
423
|
+
// the interface for the mode API
|
424
|
+
return {
|
425
|
+
startState: function() {
|
426
|
+
return {
|
427
|
+
tokenize: tokenBase,
|
428
|
+
cc: [],
|
429
|
+
stack: []
|
430
|
+
};
|
431
|
+
},
|
432
|
+
|
433
|
+
token: function(stream, state) {
|
434
|
+
if (stream.eatSpace()) return null;
|
435
|
+
var style = state.tokenize(stream, state);
|
436
|
+
return style;
|
437
|
+
},
|
438
|
+
|
439
|
+
blockCommentStart: "(:",
|
440
|
+
blockCommentEnd: ":)"
|
441
|
+
|
442
|
+
};
|
443
|
+
|
444
|
+
});
|
445
|
+
|
446
|
+
CodeMirror.defineMIME("application/xquery", "xquery");
|
447
|
+
|
448
|
+
});
|