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,280 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Link to the project's GitHub page:
|
6
|
+
* https://github.com/duralog/CodeMirror
|
7
|
+
*/
|
8
|
+
|
9
|
+
(function(mod) {
|
10
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
11
|
+
mod(require("../../lib/codemirror"));
|
12
|
+
else if (typeof define == "function" && define.amd) // AMD
|
13
|
+
define(["../../lib/codemirror"], mod);
|
14
|
+
else // Plain browser env
|
15
|
+
mod(CodeMirror);
|
16
|
+
})(function(CodeMirror) {
|
17
|
+
"use strict";
|
18
|
+
|
19
|
+
CodeMirror.defineMode('livescript', function(){
|
20
|
+
var tokenBase = function(stream, state) {
|
21
|
+
var next_rule = state.next || "start";
|
22
|
+
if (next_rule) {
|
23
|
+
state.next = state.next;
|
24
|
+
var nr = Rules[next_rule];
|
25
|
+
if (nr.splice) {
|
26
|
+
for (var i$ = 0; i$ < nr.length; ++i$) {
|
27
|
+
var r = nr[i$];
|
28
|
+
if (r.regex && stream.match(r.regex)) {
|
29
|
+
state.next = r.next || state.next;
|
30
|
+
return r.token;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
stream.next();
|
34
|
+
return 'error';
|
35
|
+
}
|
36
|
+
if (stream.match(r = Rules[next_rule])) {
|
37
|
+
if (r.regex && stream.match(r.regex)) {
|
38
|
+
state.next = r.next;
|
39
|
+
return r.token;
|
40
|
+
} else {
|
41
|
+
stream.next();
|
42
|
+
return 'error';
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
stream.next();
|
47
|
+
return 'error';
|
48
|
+
};
|
49
|
+
var external = {
|
50
|
+
startState: function(){
|
51
|
+
return {
|
52
|
+
next: 'start',
|
53
|
+
lastToken: {style: null, indent: 0, content: ""}
|
54
|
+
};
|
55
|
+
},
|
56
|
+
token: function(stream, state){
|
57
|
+
while (stream.pos == stream.start)
|
58
|
+
var style = tokenBase(stream, state);
|
59
|
+
state.lastToken = {
|
60
|
+
style: style,
|
61
|
+
indent: stream.indentation(),
|
62
|
+
content: stream.current()
|
63
|
+
};
|
64
|
+
return style.replace(/\./g, ' ');
|
65
|
+
},
|
66
|
+
indent: function(state){
|
67
|
+
var indentation = state.lastToken.indent;
|
68
|
+
if (state.lastToken.content.match(indenter)) {
|
69
|
+
indentation += 2;
|
70
|
+
}
|
71
|
+
return indentation;
|
72
|
+
}
|
73
|
+
};
|
74
|
+
return external;
|
75
|
+
});
|
76
|
+
|
77
|
+
var identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
|
78
|
+
var indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
|
79
|
+
var keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
|
80
|
+
var stringfill = {
|
81
|
+
token: 'string',
|
82
|
+
regex: '.+'
|
83
|
+
};
|
84
|
+
var Rules = {
|
85
|
+
start: [
|
86
|
+
{
|
87
|
+
token: 'comment.doc',
|
88
|
+
regex: '/\\*',
|
89
|
+
next: 'comment'
|
90
|
+
}, {
|
91
|
+
token: 'comment',
|
92
|
+
regex: '#.*'
|
93
|
+
}, {
|
94
|
+
token: 'keyword',
|
95
|
+
regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
|
96
|
+
}, {
|
97
|
+
token: 'constant.language',
|
98
|
+
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
|
99
|
+
}, {
|
100
|
+
token: 'invalid.illegal',
|
101
|
+
regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
|
102
|
+
}, {
|
103
|
+
token: 'language.support.class',
|
104
|
+
regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
|
105
|
+
}, {
|
106
|
+
token: 'language.support.function',
|
107
|
+
regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
|
108
|
+
}, {
|
109
|
+
token: 'variable.language',
|
110
|
+
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
|
111
|
+
}, {
|
112
|
+
token: 'identifier',
|
113
|
+
regex: identifier + '\\s*:(?![:=])'
|
114
|
+
}, {
|
115
|
+
token: 'variable',
|
116
|
+
regex: identifier
|
117
|
+
}, {
|
118
|
+
token: 'keyword.operator',
|
119
|
+
regex: '(?:\\.{3}|\\s+\\?)'
|
120
|
+
}, {
|
121
|
+
token: 'keyword.variable',
|
122
|
+
regex: '(?:@+|::|\\.\\.)',
|
123
|
+
next: 'key'
|
124
|
+
}, {
|
125
|
+
token: 'keyword.operator',
|
126
|
+
regex: '\\.\\s*',
|
127
|
+
next: 'key'
|
128
|
+
}, {
|
129
|
+
token: 'string',
|
130
|
+
regex: '\\\\\\S[^\\s,;)}\\]]*'
|
131
|
+
}, {
|
132
|
+
token: 'string.doc',
|
133
|
+
regex: '\'\'\'',
|
134
|
+
next: 'qdoc'
|
135
|
+
}, {
|
136
|
+
token: 'string.doc',
|
137
|
+
regex: '"""',
|
138
|
+
next: 'qqdoc'
|
139
|
+
}, {
|
140
|
+
token: 'string',
|
141
|
+
regex: '\'',
|
142
|
+
next: 'qstring'
|
143
|
+
}, {
|
144
|
+
token: 'string',
|
145
|
+
regex: '"',
|
146
|
+
next: 'qqstring'
|
147
|
+
}, {
|
148
|
+
token: 'string',
|
149
|
+
regex: '`',
|
150
|
+
next: 'js'
|
151
|
+
}, {
|
152
|
+
token: 'string',
|
153
|
+
regex: '<\\[',
|
154
|
+
next: 'words'
|
155
|
+
}, {
|
156
|
+
token: 'string.regex',
|
157
|
+
regex: '//',
|
158
|
+
next: 'heregex'
|
159
|
+
}, {
|
160
|
+
token: 'string.regex',
|
161
|
+
regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
|
162
|
+
next: 'key'
|
163
|
+
}, {
|
164
|
+
token: 'constant.numeric',
|
165
|
+
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
|
166
|
+
}, {
|
167
|
+
token: 'lparen',
|
168
|
+
regex: '[({[]'
|
169
|
+
}, {
|
170
|
+
token: 'rparen',
|
171
|
+
regex: '[)}\\]]',
|
172
|
+
next: 'key'
|
173
|
+
}, {
|
174
|
+
token: 'keyword.operator',
|
175
|
+
regex: '\\S+'
|
176
|
+
}, {
|
177
|
+
token: 'text',
|
178
|
+
regex: '\\s+'
|
179
|
+
}
|
180
|
+
],
|
181
|
+
heregex: [
|
182
|
+
{
|
183
|
+
token: 'string.regex',
|
184
|
+
regex: '.*?//[gimy$?]{0,4}',
|
185
|
+
next: 'start'
|
186
|
+
}, {
|
187
|
+
token: 'string.regex',
|
188
|
+
regex: '\\s*#{'
|
189
|
+
}, {
|
190
|
+
token: 'comment.regex',
|
191
|
+
regex: '\\s+(?:#.*)?'
|
192
|
+
}, {
|
193
|
+
token: 'string.regex',
|
194
|
+
regex: '\\S+'
|
195
|
+
}
|
196
|
+
],
|
197
|
+
key: [
|
198
|
+
{
|
199
|
+
token: 'keyword.operator',
|
200
|
+
regex: '[.?@!]+'
|
201
|
+
}, {
|
202
|
+
token: 'identifier',
|
203
|
+
regex: identifier,
|
204
|
+
next: 'start'
|
205
|
+
}, {
|
206
|
+
token: 'text',
|
207
|
+
regex: '',
|
208
|
+
next: 'start'
|
209
|
+
}
|
210
|
+
],
|
211
|
+
comment: [
|
212
|
+
{
|
213
|
+
token: 'comment.doc',
|
214
|
+
regex: '.*?\\*/',
|
215
|
+
next: 'start'
|
216
|
+
}, {
|
217
|
+
token: 'comment.doc',
|
218
|
+
regex: '.+'
|
219
|
+
}
|
220
|
+
],
|
221
|
+
qdoc: [
|
222
|
+
{
|
223
|
+
token: 'string',
|
224
|
+
regex: ".*?'''",
|
225
|
+
next: 'key'
|
226
|
+
}, stringfill
|
227
|
+
],
|
228
|
+
qqdoc: [
|
229
|
+
{
|
230
|
+
token: 'string',
|
231
|
+
regex: '.*?"""',
|
232
|
+
next: 'key'
|
233
|
+
}, stringfill
|
234
|
+
],
|
235
|
+
qstring: [
|
236
|
+
{
|
237
|
+
token: 'string',
|
238
|
+
regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
|
239
|
+
next: 'key'
|
240
|
+
}, stringfill
|
241
|
+
],
|
242
|
+
qqstring: [
|
243
|
+
{
|
244
|
+
token: 'string',
|
245
|
+
regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
|
246
|
+
next: 'key'
|
247
|
+
}, stringfill
|
248
|
+
],
|
249
|
+
js: [
|
250
|
+
{
|
251
|
+
token: 'string',
|
252
|
+
regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
|
253
|
+
next: 'key'
|
254
|
+
}, stringfill
|
255
|
+
],
|
256
|
+
words: [
|
257
|
+
{
|
258
|
+
token: 'string',
|
259
|
+
regex: '.*?\\]>',
|
260
|
+
next: 'key'
|
261
|
+
}, stringfill
|
262
|
+
]
|
263
|
+
};
|
264
|
+
for (var idx in Rules) {
|
265
|
+
var r = Rules[idx];
|
266
|
+
if (r.splice) {
|
267
|
+
for (var i = 0, len = r.length; i < len; ++i) {
|
268
|
+
var rr = r[i];
|
269
|
+
if (typeof rr.regex === 'string') {
|
270
|
+
Rules[idx][i].regex = new RegExp('^' + rr.regex);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
} else if (typeof rr.regex === 'string') {
|
274
|
+
Rules[idx].regex = new RegExp('^' + r.regex);
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
CodeMirror.defineMIME('text/x-livescript', 'livescript');
|
279
|
+
|
280
|
+
});
|
@@ -0,0 +1,159 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's
|
5
|
+
// CodeMirror 1 mode.
|
6
|
+
// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
|
7
|
+
|
8
|
+
(function(mod) {
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
10
|
+
mod(require("../../lib/codemirror"));
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
12
|
+
define(["../../lib/codemirror"], mod);
|
13
|
+
else // Plain browser env
|
14
|
+
mod(CodeMirror);
|
15
|
+
})(function(CodeMirror) {
|
16
|
+
"use strict";
|
17
|
+
|
18
|
+
CodeMirror.defineMode("lua", function(config, parserConfig) {
|
19
|
+
var indentUnit = config.indentUnit;
|
20
|
+
|
21
|
+
function prefixRE(words) {
|
22
|
+
return new RegExp("^(?:" + words.join("|") + ")", "i");
|
23
|
+
}
|
24
|
+
function wordRE(words) {
|
25
|
+
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
26
|
+
}
|
27
|
+
var specials = wordRE(parserConfig.specials || []);
|
28
|
+
|
29
|
+
// long list of standard functions from lua manual
|
30
|
+
var builtins = wordRE([
|
31
|
+
"_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load",
|
32
|
+
"loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require",
|
33
|
+
"select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall",
|
34
|
+
|
35
|
+
"coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield",
|
36
|
+
|
37
|
+
"debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable",
|
38
|
+
"debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable",
|
39
|
+
"debug.setupvalue","debug.traceback",
|
40
|
+
|
41
|
+
"close","flush","lines","read","seek","setvbuf","write",
|
42
|
+
|
43
|
+
"io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin",
|
44
|
+
"io.stdout","io.tmpfile","io.type","io.write",
|
45
|
+
|
46
|
+
"math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg",
|
47
|
+
"math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max",
|
48
|
+
"math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh",
|
49
|
+
"math.sqrt","math.tan","math.tanh",
|
50
|
+
|
51
|
+
"os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale",
|
52
|
+
"os.time","os.tmpname",
|
53
|
+
|
54
|
+
"package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload",
|
55
|
+
"package.seeall",
|
56
|
+
|
57
|
+
"string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub",
|
58
|
+
"string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper",
|
59
|
+
|
60
|
+
"table.concat","table.insert","table.maxn","table.remove","table.sort"
|
61
|
+
]);
|
62
|
+
var keywords = wordRE(["and","break","elseif","false","nil","not","or","return",
|
63
|
+
"true","function", "end", "if", "then", "else", "do",
|
64
|
+
"while", "repeat", "until", "for", "in", "local" ]);
|
65
|
+
|
66
|
+
var indentTokens = wordRE(["function", "if","repeat","do", "\\(", "{"]);
|
67
|
+
var dedentTokens = wordRE(["end", "until", "\\)", "}"]);
|
68
|
+
var dedentPartial = prefixRE(["end", "until", "\\)", "}", "else", "elseif"]);
|
69
|
+
|
70
|
+
function readBracket(stream) {
|
71
|
+
var level = 0;
|
72
|
+
while (stream.eat("=")) ++level;
|
73
|
+
stream.eat("[");
|
74
|
+
return level;
|
75
|
+
}
|
76
|
+
|
77
|
+
function normal(stream, state) {
|
78
|
+
var ch = stream.next();
|
79
|
+
if (ch == "-" && stream.eat("-")) {
|
80
|
+
if (stream.eat("[") && stream.eat("["))
|
81
|
+
return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state);
|
82
|
+
stream.skipToEnd();
|
83
|
+
return "comment";
|
84
|
+
}
|
85
|
+
if (ch == "\"" || ch == "'")
|
86
|
+
return (state.cur = string(ch))(stream, state);
|
87
|
+
if (ch == "[" && /[\[=]/.test(stream.peek()))
|
88
|
+
return (state.cur = bracketed(readBracket(stream), "string"))(stream, state);
|
89
|
+
if (/\d/.test(ch)) {
|
90
|
+
stream.eatWhile(/[\w.%]/);
|
91
|
+
return "number";
|
92
|
+
}
|
93
|
+
if (/[\w_]/.test(ch)) {
|
94
|
+
stream.eatWhile(/[\w\\\-_.]/);
|
95
|
+
return "variable";
|
96
|
+
}
|
97
|
+
return null;
|
98
|
+
}
|
99
|
+
|
100
|
+
function bracketed(level, style) {
|
101
|
+
return function(stream, state) {
|
102
|
+
var curlev = null, ch;
|
103
|
+
while ((ch = stream.next()) != null) {
|
104
|
+
if (curlev == null) {if (ch == "]") curlev = 0;}
|
105
|
+
else if (ch == "=") ++curlev;
|
106
|
+
else if (ch == "]" && curlev == level) { state.cur = normal; break; }
|
107
|
+
else curlev = null;
|
108
|
+
}
|
109
|
+
return style;
|
110
|
+
};
|
111
|
+
}
|
112
|
+
|
113
|
+
function string(quote) {
|
114
|
+
return function(stream, state) {
|
115
|
+
var escaped = false, ch;
|
116
|
+
while ((ch = stream.next()) != null) {
|
117
|
+
if (ch == quote && !escaped) break;
|
118
|
+
escaped = !escaped && ch == "\\";
|
119
|
+
}
|
120
|
+
if (!escaped) state.cur = normal;
|
121
|
+
return "string";
|
122
|
+
};
|
123
|
+
}
|
124
|
+
|
125
|
+
return {
|
126
|
+
startState: function(basecol) {
|
127
|
+
return {basecol: basecol || 0, indentDepth: 0, cur: normal};
|
128
|
+
},
|
129
|
+
|
130
|
+
token: function(stream, state) {
|
131
|
+
if (stream.eatSpace()) return null;
|
132
|
+
var style = state.cur(stream, state);
|
133
|
+
var word = stream.current();
|
134
|
+
if (style == "variable") {
|
135
|
+
if (keywords.test(word)) style = "keyword";
|
136
|
+
else if (builtins.test(word)) style = "builtin";
|
137
|
+
else if (specials.test(word)) style = "variable-2";
|
138
|
+
}
|
139
|
+
if ((style != "comment") && (style != "string")){
|
140
|
+
if (indentTokens.test(word)) ++state.indentDepth;
|
141
|
+
else if (dedentTokens.test(word)) --state.indentDepth;
|
142
|
+
}
|
143
|
+
return style;
|
144
|
+
},
|
145
|
+
|
146
|
+
indent: function(state, textAfter) {
|
147
|
+
var closing = dedentPartial.test(textAfter);
|
148
|
+
return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0));
|
149
|
+
},
|
150
|
+
|
151
|
+
lineComment: "--",
|
152
|
+
blockCommentStart: "--[[",
|
153
|
+
blockCommentEnd: "]]"
|
154
|
+
};
|
155
|
+
});
|
156
|
+
|
157
|
+
CodeMirror.defineMIME("text/x-lua", "lua");
|
158
|
+
|
159
|
+
});
|
@@ -0,0 +1,859 @@
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
2
|
+
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
3
|
+
|
4
|
+
(function(mod) {
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
6
|
+
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta"));
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
8
|
+
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
|
9
|
+
else // Plain browser env
|
10
|
+
mod(CodeMirror);
|
11
|
+
})(function(CodeMirror) {
|
12
|
+
"use strict";
|
13
|
+
|
14
|
+
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
15
|
+
|
16
|
+
var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
|
17
|
+
var htmlModeMissing = htmlMode.name == "null"
|
18
|
+
|
19
|
+
function getMode(name) {
|
20
|
+
if (CodeMirror.findModeByName) {
|
21
|
+
var found = CodeMirror.findModeByName(name);
|
22
|
+
if (found) name = found.mime || found.mimes[0];
|
23
|
+
}
|
24
|
+
var mode = CodeMirror.getMode(cmCfg, name);
|
25
|
+
return mode.name == "null" ? null : mode;
|
26
|
+
}
|
27
|
+
|
28
|
+
// Should characters that affect highlighting be highlighted separate?
|
29
|
+
// Does not include characters that will be output (such as `1.` and `-` for lists)
|
30
|
+
if (modeCfg.highlightFormatting === undefined)
|
31
|
+
modeCfg.highlightFormatting = false;
|
32
|
+
|
33
|
+
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
|
34
|
+
// Excess `>` will emit `error` token.
|
35
|
+
if (modeCfg.maxBlockquoteDepth === undefined)
|
36
|
+
modeCfg.maxBlockquoteDepth = 0;
|
37
|
+
|
38
|
+
// Turn on task lists? ("- [ ] " and "- [x] ")
|
39
|
+
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
40
|
+
|
41
|
+
// Turn on strikethrough syntax
|
42
|
+
if (modeCfg.strikethrough === undefined)
|
43
|
+
modeCfg.strikethrough = false;
|
44
|
+
|
45
|
+
if (modeCfg.emoji === undefined)
|
46
|
+
modeCfg.emoji = false;
|
47
|
+
|
48
|
+
if (modeCfg.fencedCodeBlockHighlighting === undefined)
|
49
|
+
modeCfg.fencedCodeBlockHighlighting = true;
|
50
|
+
|
51
|
+
if (modeCfg.xml === undefined)
|
52
|
+
modeCfg.xml = true;
|
53
|
+
|
54
|
+
// Allow token types to be overridden by user-provided token types.
|
55
|
+
if (modeCfg.tokenTypeOverrides === undefined)
|
56
|
+
modeCfg.tokenTypeOverrides = {};
|
57
|
+
|
58
|
+
var tokenTypes = {
|
59
|
+
header: "header",
|
60
|
+
code: "comment",
|
61
|
+
quote: "quote",
|
62
|
+
list1: "variable-2",
|
63
|
+
list2: "variable-3",
|
64
|
+
list3: "keyword",
|
65
|
+
hr: "hr",
|
66
|
+
image: "image",
|
67
|
+
imageAltText: "image-alt-text",
|
68
|
+
imageMarker: "image-marker",
|
69
|
+
formatting: "formatting",
|
70
|
+
linkInline: "link",
|
71
|
+
linkEmail: "link",
|
72
|
+
linkText: "link",
|
73
|
+
linkHref: "string",
|
74
|
+
em: "em",
|
75
|
+
strong: "strong",
|
76
|
+
strikethrough: "strikethrough",
|
77
|
+
emoji: "builtin"
|
78
|
+
};
|
79
|
+
|
80
|
+
for (var tokenType in tokenTypes) {
|
81
|
+
if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
|
82
|
+
tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
87
|
+
, listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/
|
88
|
+
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow listRE
|
89
|
+
, atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
|
90
|
+
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
91
|
+
, textRE = /^[^#!\[\]*_\\<>` "'(~:]+/
|
92
|
+
, fencedCodeRE = /^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/
|
93
|
+
, linkDefRE = /^\s*\[[^\]]+?\]:\s*\S+(\s*\S*\s*)?$/ // naive link-definition
|
94
|
+
, punctuation = /[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/
|
95
|
+
, expandedTab = " " // CommonMark specifies tab as 4 spaces
|
96
|
+
|
97
|
+
function switchInline(stream, state, f) {
|
98
|
+
state.f = state.inline = f;
|
99
|
+
return f(stream, state);
|
100
|
+
}
|
101
|
+
|
102
|
+
function switchBlock(stream, state, f) {
|
103
|
+
state.f = state.block = f;
|
104
|
+
return f(stream, state);
|
105
|
+
}
|
106
|
+
|
107
|
+
function lineIsEmpty(line) {
|
108
|
+
return !line || !/\S/.test(line.string)
|
109
|
+
}
|
110
|
+
|
111
|
+
// Blocks
|
112
|
+
|
113
|
+
function blankLine(state) {
|
114
|
+
// Reset linkTitle state
|
115
|
+
state.linkTitle = false;
|
116
|
+
// Reset EM state
|
117
|
+
state.em = false;
|
118
|
+
// Reset STRONG state
|
119
|
+
state.strong = false;
|
120
|
+
// Reset strikethrough state
|
121
|
+
state.strikethrough = false;
|
122
|
+
// Reset state.quote
|
123
|
+
state.quote = 0;
|
124
|
+
// Reset state.indentedCode
|
125
|
+
state.indentedCode = false;
|
126
|
+
if (state.f == htmlBlock) {
|
127
|
+
state.f = inlineNormal;
|
128
|
+
state.block = blockNormal;
|
129
|
+
}
|
130
|
+
// Reset state.trailingSpace
|
131
|
+
state.trailingSpace = 0;
|
132
|
+
state.trailingSpaceNewLine = false;
|
133
|
+
// Mark this line as blank
|
134
|
+
state.prevLine = state.thisLine
|
135
|
+
state.thisLine = {stream: null}
|
136
|
+
return null;
|
137
|
+
}
|
138
|
+
|
139
|
+
function blockNormal(stream, state) {
|
140
|
+
var firstTokenOnLine = stream.column() === state.indentation;
|
141
|
+
var prevLineLineIsEmpty = lineIsEmpty(state.prevLine.stream);
|
142
|
+
var prevLineIsIndentedCode = state.indentedCode;
|
143
|
+
var prevLineIsHr = state.prevLine.hr;
|
144
|
+
var prevLineIsList = state.list !== false;
|
145
|
+
var maxNonCodeIndentation = (state.listStack[state.listStack.length - 1] || 0) + 3;
|
146
|
+
|
147
|
+
state.indentedCode = false;
|
148
|
+
|
149
|
+
var lineIndentation = state.indentation;
|
150
|
+
// compute once per line (on first token)
|
151
|
+
if (state.indentationDiff === null) {
|
152
|
+
state.indentationDiff = state.indentation;
|
153
|
+
if (prevLineIsList) {
|
154
|
+
state.list = null;
|
155
|
+
// While this list item's marker's indentation is less than the deepest
|
156
|
+
// list item's content's indentation,pop the deepest list item
|
157
|
+
// indentation off the stack, and update block indentation state
|
158
|
+
while (lineIndentation < state.listStack[state.listStack.length - 1]) {
|
159
|
+
state.listStack.pop();
|
160
|
+
if (state.listStack.length) {
|
161
|
+
state.indentation = state.listStack[state.listStack.length - 1];
|
162
|
+
// less than the first list's indent -> the line is no longer a list
|
163
|
+
} else {
|
164
|
+
state.list = false;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
if (state.list !== false) {
|
168
|
+
state.indentationDiff = lineIndentation - state.listStack[state.listStack.length - 1]
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
// not comprehensive (currently only for setext detection purposes)
|
174
|
+
var allowsInlineContinuation = (
|
175
|
+
!prevLineLineIsEmpty && !prevLineIsHr && !state.prevLine.header &&
|
176
|
+
(!prevLineIsList || !prevLineIsIndentedCode) &&
|
177
|
+
!state.prevLine.fencedCodeEnd
|
178
|
+
);
|
179
|
+
|
180
|
+
var isHr = (state.list === false || prevLineIsHr || prevLineLineIsEmpty) &&
|
181
|
+
state.indentation <= maxNonCodeIndentation && stream.match(hrRE);
|
182
|
+
|
183
|
+
var match = null;
|
184
|
+
if (state.indentationDiff >= 4 && (prevLineIsIndentedCode || state.prevLine.fencedCodeEnd ||
|
185
|
+
state.prevLine.header || prevLineLineIsEmpty)) {
|
186
|
+
stream.skipToEnd();
|
187
|
+
state.indentedCode = true;
|
188
|
+
return tokenTypes.code;
|
189
|
+
} else if (stream.eatSpace()) {
|
190
|
+
return null;
|
191
|
+
} else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
|
192
|
+
state.quote = 0;
|
193
|
+
state.header = match[1].length;
|
194
|
+
state.thisLine.header = true;
|
195
|
+
if (modeCfg.highlightFormatting) state.formatting = "header";
|
196
|
+
state.f = state.inline;
|
197
|
+
return getType(state);
|
198
|
+
} else if (state.indentation <= maxNonCodeIndentation && stream.eat('>')) {
|
199
|
+
state.quote = firstTokenOnLine ? 1 : state.quote + 1;
|
200
|
+
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
201
|
+
stream.eatSpace();
|
202
|
+
return getType(state);
|
203
|
+
} else if (!isHr && !state.setext && firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(listRE))) {
|
204
|
+
var listType = match[1] ? "ol" : "ul";
|
205
|
+
|
206
|
+
state.indentation = lineIndentation + stream.current().length;
|
207
|
+
state.list = true;
|
208
|
+
state.quote = 0;
|
209
|
+
|
210
|
+
// Add this list item's content's indentation to the stack
|
211
|
+
state.listStack.push(state.indentation);
|
212
|
+
|
213
|
+
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
214
|
+
state.taskList = true;
|
215
|
+
}
|
216
|
+
state.f = state.inline;
|
217
|
+
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
218
|
+
return getType(state);
|
219
|
+
} else if (firstTokenOnLine && state.indentation <= maxNonCodeIndentation && (match = stream.match(fencedCodeRE, true))) {
|
220
|
+
state.quote = 0;
|
221
|
+
state.fencedEndRE = new RegExp(match[1] + "+ *$");
|
222
|
+
// try switching mode
|
223
|
+
state.localMode = modeCfg.fencedCodeBlockHighlighting && getMode(match[2]);
|
224
|
+
if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
|
225
|
+
state.f = state.block = local;
|
226
|
+
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
227
|
+
state.code = -1
|
228
|
+
return getType(state);
|
229
|
+
// SETEXT has lowest block-scope precedence after HR, so check it after
|
230
|
+
// the others (code, blockquote, list...)
|
231
|
+
} else if (
|
232
|
+
// if setext set, indicates line after ---/===
|
233
|
+
state.setext || (
|
234
|
+
// line before ---/===
|
235
|
+
(!allowsInlineContinuation || !prevLineIsList) && !state.quote && state.list === false &&
|
236
|
+
!state.code && !isHr && !linkDefRE.test(stream.string) &&
|
237
|
+
(match = stream.lookAhead(1)) && (match = match.match(setextHeaderRE))
|
238
|
+
)
|
239
|
+
) {
|
240
|
+
if ( !state.setext ) {
|
241
|
+
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
242
|
+
state.setext = state.header;
|
243
|
+
} else {
|
244
|
+
state.header = state.setext;
|
245
|
+
// has no effect on type so we can reset it now
|
246
|
+
state.setext = 0;
|
247
|
+
stream.skipToEnd();
|
248
|
+
if (modeCfg.highlightFormatting) state.formatting = "header";
|
249
|
+
}
|
250
|
+
state.thisLine.header = true;
|
251
|
+
state.f = state.inline;
|
252
|
+
return getType(state);
|
253
|
+
} else if (isHr) {
|
254
|
+
stream.skipToEnd();
|
255
|
+
state.hr = true;
|
256
|
+
state.thisLine.hr = true;
|
257
|
+
return tokenTypes.hr;
|
258
|
+
} else if (stream.peek() === '[') {
|
259
|
+
return switchInline(stream, state, footnoteLink);
|
260
|
+
}
|
261
|
+
|
262
|
+
return switchInline(stream, state, state.inline);
|
263
|
+
}
|
264
|
+
|
265
|
+
function htmlBlock(stream, state) {
|
266
|
+
var style = htmlMode.token(stream, state.htmlState);
|
267
|
+
if (!htmlModeMissing) {
|
268
|
+
var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
|
269
|
+
if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
|
270
|
+
(!inner.state.context && inner.state.tokenize.isInText)) ||
|
271
|
+
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
272
|
+
state.f = inlineNormal;
|
273
|
+
state.block = blockNormal;
|
274
|
+
state.htmlState = null;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
return style;
|
278
|
+
}
|
279
|
+
|
280
|
+
function local(stream, state) {
|
281
|
+
var currListInd = state.listStack[state.listStack.length - 1] || 0;
|
282
|
+
var hasExitedList = state.indentation < currListInd;
|
283
|
+
var maxFencedEndInd = currListInd + 3;
|
284
|
+
if (state.fencedEndRE && state.indentation <= maxFencedEndInd && (hasExitedList || stream.match(state.fencedEndRE))) {
|
285
|
+
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
286
|
+
var returnType;
|
287
|
+
if (!hasExitedList) returnType = getType(state)
|
288
|
+
state.localMode = state.localState = null;
|
289
|
+
state.block = blockNormal;
|
290
|
+
state.f = inlineNormal;
|
291
|
+
state.fencedEndRE = null;
|
292
|
+
state.code = 0
|
293
|
+
state.thisLine.fencedCodeEnd = true;
|
294
|
+
if (hasExitedList) return switchBlock(stream, state, state.block);
|
295
|
+
return returnType;
|
296
|
+
} else if (state.localMode) {
|
297
|
+
return state.localMode.token(stream, state.localState);
|
298
|
+
} else {
|
299
|
+
stream.skipToEnd();
|
300
|
+
return tokenTypes.code;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
// Inline
|
305
|
+
function getType(state) {
|
306
|
+
var styles = [];
|
307
|
+
|
308
|
+
if (state.formatting) {
|
309
|
+
styles.push(tokenTypes.formatting);
|
310
|
+
|
311
|
+
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
312
|
+
|
313
|
+
for (var i = 0; i < state.formatting.length; i++) {
|
314
|
+
styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
|
315
|
+
|
316
|
+
if (state.formatting[i] === "header") {
|
317
|
+
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
|
318
|
+
}
|
319
|
+
|
320
|
+
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
321
|
+
// Add `error` instead if the maximum blockquote nesting depth is passed
|
322
|
+
if (state.formatting[i] === "quote") {
|
323
|
+
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
324
|
+
styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
|
325
|
+
} else {
|
326
|
+
styles.push("error");
|
327
|
+
}
|
328
|
+
}
|
329
|
+
}
|
330
|
+
}
|
331
|
+
|
332
|
+
if (state.taskOpen) {
|
333
|
+
styles.push("meta");
|
334
|
+
return styles.length ? styles.join(' ') : null;
|
335
|
+
}
|
336
|
+
if (state.taskClosed) {
|
337
|
+
styles.push("property");
|
338
|
+
return styles.length ? styles.join(' ') : null;
|
339
|
+
}
|
340
|
+
|
341
|
+
if (state.linkHref) {
|
342
|
+
styles.push(tokenTypes.linkHref, "url");
|
343
|
+
} else { // Only apply inline styles to non-url text
|
344
|
+
if (state.strong) { styles.push(tokenTypes.strong); }
|
345
|
+
if (state.em) { styles.push(tokenTypes.em); }
|
346
|
+
if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
|
347
|
+
if (state.emoji) { styles.push(tokenTypes.emoji); }
|
348
|
+
if (state.linkText) { styles.push(tokenTypes.linkText); }
|
349
|
+
if (state.code) { styles.push(tokenTypes.code); }
|
350
|
+
if (state.image) { styles.push(tokenTypes.image); }
|
351
|
+
if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
|
352
|
+
if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
|
353
|
+
}
|
354
|
+
|
355
|
+
if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
|
356
|
+
|
357
|
+
if (state.quote) {
|
358
|
+
styles.push(tokenTypes.quote);
|
359
|
+
|
360
|
+
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
361
|
+
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
362
|
+
styles.push(tokenTypes.quote + "-" + state.quote);
|
363
|
+
} else {
|
364
|
+
styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
|
368
|
+
if (state.list !== false) {
|
369
|
+
var listMod = (state.listStack.length - 1) % 3;
|
370
|
+
if (!listMod) {
|
371
|
+
styles.push(tokenTypes.list1);
|
372
|
+
} else if (listMod === 1) {
|
373
|
+
styles.push(tokenTypes.list2);
|
374
|
+
} else {
|
375
|
+
styles.push(tokenTypes.list3);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
if (state.trailingSpaceNewLine) {
|
380
|
+
styles.push("trailing-space-new-line");
|
381
|
+
} else if (state.trailingSpace) {
|
382
|
+
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
383
|
+
}
|
384
|
+
|
385
|
+
return styles.length ? styles.join(' ') : null;
|
386
|
+
}
|
387
|
+
|
388
|
+
function handleText(stream, state) {
|
389
|
+
if (stream.match(textRE, true)) {
|
390
|
+
return getType(state);
|
391
|
+
}
|
392
|
+
return undefined;
|
393
|
+
}
|
394
|
+
|
395
|
+
function inlineNormal(stream, state) {
|
396
|
+
var style = state.text(stream, state);
|
397
|
+
if (typeof style !== 'undefined')
|
398
|
+
return style;
|
399
|
+
|
400
|
+
if (state.list) { // List marker (*, +, -, 1., etc)
|
401
|
+
state.list = null;
|
402
|
+
return getType(state);
|
403
|
+
}
|
404
|
+
|
405
|
+
if (state.taskList) {
|
406
|
+
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
|
407
|
+
if (taskOpen) state.taskOpen = true;
|
408
|
+
else state.taskClosed = true;
|
409
|
+
if (modeCfg.highlightFormatting) state.formatting = "task";
|
410
|
+
state.taskList = false;
|
411
|
+
return getType(state);
|
412
|
+
}
|
413
|
+
|
414
|
+
state.taskOpen = false;
|
415
|
+
state.taskClosed = false;
|
416
|
+
|
417
|
+
if (state.header && stream.match(/^#+$/, true)) {
|
418
|
+
if (modeCfg.highlightFormatting) state.formatting = "header";
|
419
|
+
return getType(state);
|
420
|
+
}
|
421
|
+
|
422
|
+
var ch = stream.next();
|
423
|
+
|
424
|
+
// Matches link titles present on next line
|
425
|
+
if (state.linkTitle) {
|
426
|
+
state.linkTitle = false;
|
427
|
+
var matchCh = ch;
|
428
|
+
if (ch === '(') {
|
429
|
+
matchCh = ')';
|
430
|
+
}
|
431
|
+
matchCh = (matchCh+'').replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1");
|
432
|
+
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
433
|
+
if (stream.match(new RegExp(regex), true)) {
|
434
|
+
return tokenTypes.linkHref;
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
// If this block is changed, it may need to be updated in GFM mode
|
439
|
+
if (ch === '`') {
|
440
|
+
var previousFormatting = state.formatting;
|
441
|
+
if (modeCfg.highlightFormatting) state.formatting = "code";
|
442
|
+
stream.eatWhile('`');
|
443
|
+
var count = stream.current().length
|
444
|
+
if (state.code == 0 && (!state.quote || count == 1)) {
|
445
|
+
state.code = count
|
446
|
+
return getType(state)
|
447
|
+
} else if (count == state.code) { // Must be exact
|
448
|
+
var t = getType(state)
|
449
|
+
state.code = 0
|
450
|
+
return t
|
451
|
+
} else {
|
452
|
+
state.formatting = previousFormatting
|
453
|
+
return getType(state)
|
454
|
+
}
|
455
|
+
} else if (state.code) {
|
456
|
+
return getType(state);
|
457
|
+
}
|
458
|
+
|
459
|
+
if (ch === '\\') {
|
460
|
+
stream.next();
|
461
|
+
if (modeCfg.highlightFormatting) {
|
462
|
+
var type = getType(state);
|
463
|
+
var formattingEscape = tokenTypes.formatting + "-escape";
|
464
|
+
return type ? type + " " + formattingEscape : formattingEscape;
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
469
|
+
state.imageMarker = true;
|
470
|
+
state.image = true;
|
471
|
+
if (modeCfg.highlightFormatting) state.formatting = "image";
|
472
|
+
return getType(state);
|
473
|
+
}
|
474
|
+
|
475
|
+
if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) {
|
476
|
+
state.imageMarker = false;
|
477
|
+
state.imageAltText = true
|
478
|
+
if (modeCfg.highlightFormatting) state.formatting = "image";
|
479
|
+
return getType(state);
|
480
|
+
}
|
481
|
+
|
482
|
+
if (ch === ']' && state.imageAltText) {
|
483
|
+
if (modeCfg.highlightFormatting) state.formatting = "image";
|
484
|
+
var type = getType(state);
|
485
|
+
state.imageAltText = false;
|
486
|
+
state.image = false;
|
487
|
+
state.inline = state.f = linkHref;
|
488
|
+
return type;
|
489
|
+
}
|
490
|
+
|
491
|
+
if (ch === '[' && !state.image) {
|
492
|
+
state.linkText = true;
|
493
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
494
|
+
return getType(state);
|
495
|
+
}
|
496
|
+
|
497
|
+
if (ch === ']' && state.linkText) {
|
498
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
499
|
+
var type = getType(state);
|
500
|
+
state.linkText = false;
|
501
|
+
state.inline = state.f = stream.match(/\(.*?\)| ?\[.*?\]/, false) ? linkHref : inlineNormal
|
502
|
+
return type;
|
503
|
+
}
|
504
|
+
|
505
|
+
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
506
|
+
state.f = state.inline = linkInline;
|
507
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
508
|
+
var type = getType(state);
|
509
|
+
if (type){
|
510
|
+
type += " ";
|
511
|
+
} else {
|
512
|
+
type = "";
|
513
|
+
}
|
514
|
+
return type + tokenTypes.linkInline;
|
515
|
+
}
|
516
|
+
|
517
|
+
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
518
|
+
state.f = state.inline = linkInline;
|
519
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
520
|
+
var type = getType(state);
|
521
|
+
if (type){
|
522
|
+
type += " ";
|
523
|
+
} else {
|
524
|
+
type = "";
|
525
|
+
}
|
526
|
+
return type + tokenTypes.linkEmail;
|
527
|
+
}
|
528
|
+
|
529
|
+
if (modeCfg.xml && ch === '<' && stream.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i, false)) {
|
530
|
+
var end = stream.string.indexOf(">", stream.pos);
|
531
|
+
if (end != -1) {
|
532
|
+
var atts = stream.string.substring(stream.start, end);
|
533
|
+
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
|
534
|
+
}
|
535
|
+
stream.backUp(1);
|
536
|
+
state.htmlState = CodeMirror.startState(htmlMode);
|
537
|
+
return switchBlock(stream, state, htmlBlock);
|
538
|
+
}
|
539
|
+
|
540
|
+
if (modeCfg.xml && ch === '<' && stream.match(/^\/\w*?>/)) {
|
541
|
+
state.md_inside = false;
|
542
|
+
return "tag";
|
543
|
+
} else if (ch === "*" || ch === "_") {
|
544
|
+
var len = 1, before = stream.pos == 1 ? " " : stream.string.charAt(stream.pos - 2)
|
545
|
+
while (len < 3 && stream.eat(ch)) len++
|
546
|
+
var after = stream.peek() || " "
|
547
|
+
// See http://spec.commonmark.org/0.27/#emphasis-and-strong-emphasis
|
548
|
+
var leftFlanking = !/\s/.test(after) && (!punctuation.test(after) || /\s/.test(before) || punctuation.test(before))
|
549
|
+
var rightFlanking = !/\s/.test(before) && (!punctuation.test(before) || /\s/.test(after) || punctuation.test(after))
|
550
|
+
var setEm = null, setStrong = null
|
551
|
+
if (len % 2) { // Em
|
552
|
+
if (!state.em && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before)))
|
553
|
+
setEm = true
|
554
|
+
else if (state.em == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after)))
|
555
|
+
setEm = false
|
556
|
+
}
|
557
|
+
if (len > 1) { // Strong
|
558
|
+
if (!state.strong && leftFlanking && (ch === "*" || !rightFlanking || punctuation.test(before)))
|
559
|
+
setStrong = true
|
560
|
+
else if (state.strong == ch && rightFlanking && (ch === "*" || !leftFlanking || punctuation.test(after)))
|
561
|
+
setStrong = false
|
562
|
+
}
|
563
|
+
if (setStrong != null || setEm != null) {
|
564
|
+
if (modeCfg.highlightFormatting) state.formatting = setEm == null ? "strong" : setStrong == null ? "em" : "strong em"
|
565
|
+
if (setEm === true) state.em = ch
|
566
|
+
if (setStrong === true) state.strong = ch
|
567
|
+
var t = getType(state)
|
568
|
+
if (setEm === false) state.em = false
|
569
|
+
if (setStrong === false) state.strong = false
|
570
|
+
return t
|
571
|
+
}
|
572
|
+
} else if (ch === ' ') {
|
573
|
+
if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
|
574
|
+
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
575
|
+
return getType(state);
|
576
|
+
} else { // Not surrounded by spaces, back up pointer
|
577
|
+
stream.backUp(1);
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
if (modeCfg.strikethrough) {
|
583
|
+
if (ch === '~' && stream.eatWhile(ch)) {
|
584
|
+
if (state.strikethrough) {// Remove strikethrough
|
585
|
+
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
586
|
+
var t = getType(state);
|
587
|
+
state.strikethrough = false;
|
588
|
+
return t;
|
589
|
+
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
|
590
|
+
state.strikethrough = true;
|
591
|
+
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
592
|
+
return getType(state);
|
593
|
+
}
|
594
|
+
} else if (ch === ' ') {
|
595
|
+
if (stream.match(/^~~/, true)) { // Probably surrounded by space
|
596
|
+
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
597
|
+
return getType(state);
|
598
|
+
} else { // Not surrounded by spaces, back up pointer
|
599
|
+
stream.backUp(2);
|
600
|
+
}
|
601
|
+
}
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
if (modeCfg.emoji && ch === ":" && stream.match(/^[a-z_\d+-]+:/)) {
|
606
|
+
state.emoji = true;
|
607
|
+
if (modeCfg.highlightFormatting) state.formatting = "emoji";
|
608
|
+
var retType = getType(state);
|
609
|
+
state.emoji = false;
|
610
|
+
return retType;
|
611
|
+
}
|
612
|
+
|
613
|
+
if (ch === ' ') {
|
614
|
+
if (stream.match(/ +$/, false)) {
|
615
|
+
state.trailingSpace++;
|
616
|
+
} else if (state.trailingSpace) {
|
617
|
+
state.trailingSpaceNewLine = true;
|
618
|
+
}
|
619
|
+
}
|
620
|
+
|
621
|
+
return getType(state);
|
622
|
+
}
|
623
|
+
|
624
|
+
function linkInline(stream, state) {
|
625
|
+
var ch = stream.next();
|
626
|
+
|
627
|
+
if (ch === ">") {
|
628
|
+
state.f = state.inline = inlineNormal;
|
629
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
630
|
+
var type = getType(state);
|
631
|
+
if (type){
|
632
|
+
type += " ";
|
633
|
+
} else {
|
634
|
+
type = "";
|
635
|
+
}
|
636
|
+
return type + tokenTypes.linkInline;
|
637
|
+
}
|
638
|
+
|
639
|
+
stream.match(/^[^>]+/, true);
|
640
|
+
|
641
|
+
return tokenTypes.linkInline;
|
642
|
+
}
|
643
|
+
|
644
|
+
function linkHref(stream, state) {
|
645
|
+
// Check if space, and return NULL if so (to avoid marking the space)
|
646
|
+
if(stream.eatSpace()){
|
647
|
+
return null;
|
648
|
+
}
|
649
|
+
var ch = stream.next();
|
650
|
+
if (ch === '(' || ch === '[') {
|
651
|
+
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
652
|
+
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
653
|
+
state.linkHref = true;
|
654
|
+
return getType(state);
|
655
|
+
}
|
656
|
+
return 'error';
|
657
|
+
}
|
658
|
+
|
659
|
+
var linkRE = {
|
660
|
+
")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
|
661
|
+
"]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/
|
662
|
+
}
|
663
|
+
|
664
|
+
function getLinkHrefInside(endChar) {
|
665
|
+
return function(stream, state) {
|
666
|
+
var ch = stream.next();
|
667
|
+
|
668
|
+
if (ch === endChar) {
|
669
|
+
state.f = state.inline = inlineNormal;
|
670
|
+
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
671
|
+
var returnState = getType(state);
|
672
|
+
state.linkHref = false;
|
673
|
+
return returnState;
|
674
|
+
}
|
675
|
+
|
676
|
+
stream.match(linkRE[endChar])
|
677
|
+
state.linkHref = true;
|
678
|
+
return getType(state);
|
679
|
+
};
|
680
|
+
}
|
681
|
+
|
682
|
+
function footnoteLink(stream, state) {
|
683
|
+
if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
|
684
|
+
state.f = footnoteLinkInside;
|
685
|
+
stream.next(); // Consume [
|
686
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
687
|
+
state.linkText = true;
|
688
|
+
return getType(state);
|
689
|
+
}
|
690
|
+
return switchInline(stream, state, inlineNormal);
|
691
|
+
}
|
692
|
+
|
693
|
+
function footnoteLinkInside(stream, state) {
|
694
|
+
if (stream.match(/^\]:/, true)) {
|
695
|
+
state.f = state.inline = footnoteUrl;
|
696
|
+
if (modeCfg.highlightFormatting) state.formatting = "link";
|
697
|
+
var returnType = getType(state);
|
698
|
+
state.linkText = false;
|
699
|
+
return returnType;
|
700
|
+
}
|
701
|
+
|
702
|
+
stream.match(/^([^\]\\]|\\.)+/, true);
|
703
|
+
|
704
|
+
return tokenTypes.linkText;
|
705
|
+
}
|
706
|
+
|
707
|
+
function footnoteUrl(stream, state) {
|
708
|
+
// Check if space, and return NULL if so (to avoid marking the space)
|
709
|
+
if(stream.eatSpace()){
|
710
|
+
return null;
|
711
|
+
}
|
712
|
+
// Match URL
|
713
|
+
stream.match(/^[^\s]+/, true);
|
714
|
+
// Check for link title
|
715
|
+
if (stream.peek() === undefined) { // End of line, set flag to check next line
|
716
|
+
state.linkTitle = true;
|
717
|
+
} else { // More content on line, check if link title
|
718
|
+
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
719
|
+
}
|
720
|
+
state.f = state.inline = inlineNormal;
|
721
|
+
return tokenTypes.linkHref + " url";
|
722
|
+
}
|
723
|
+
|
724
|
+
var mode = {
|
725
|
+
startState: function() {
|
726
|
+
return {
|
727
|
+
f: blockNormal,
|
728
|
+
|
729
|
+
prevLine: {stream: null},
|
730
|
+
thisLine: {stream: null},
|
731
|
+
|
732
|
+
block: blockNormal,
|
733
|
+
htmlState: null,
|
734
|
+
indentation: 0,
|
735
|
+
|
736
|
+
inline: inlineNormal,
|
737
|
+
text: handleText,
|
738
|
+
|
739
|
+
formatting: false,
|
740
|
+
linkText: false,
|
741
|
+
linkHref: false,
|
742
|
+
linkTitle: false,
|
743
|
+
code: 0,
|
744
|
+
em: false,
|
745
|
+
strong: false,
|
746
|
+
header: 0,
|
747
|
+
setext: 0,
|
748
|
+
hr: false,
|
749
|
+
taskList: false,
|
750
|
+
list: false,
|
751
|
+
listStack: [],
|
752
|
+
quote: 0,
|
753
|
+
trailingSpace: 0,
|
754
|
+
trailingSpaceNewLine: false,
|
755
|
+
strikethrough: false,
|
756
|
+
emoji: false,
|
757
|
+
fencedEndRE: null
|
758
|
+
};
|
759
|
+
},
|
760
|
+
|
761
|
+
copyState: function(s) {
|
762
|
+
return {
|
763
|
+
f: s.f,
|
764
|
+
|
765
|
+
prevLine: s.prevLine,
|
766
|
+
thisLine: s.thisLine,
|
767
|
+
|
768
|
+
block: s.block,
|
769
|
+
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
770
|
+
indentation: s.indentation,
|
771
|
+
|
772
|
+
localMode: s.localMode,
|
773
|
+
localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
|
774
|
+
|
775
|
+
inline: s.inline,
|
776
|
+
text: s.text,
|
777
|
+
formatting: false,
|
778
|
+
linkText: s.linkText,
|
779
|
+
linkTitle: s.linkTitle,
|
780
|
+
code: s.code,
|
781
|
+
em: s.em,
|
782
|
+
strong: s.strong,
|
783
|
+
strikethrough: s.strikethrough,
|
784
|
+
emoji: s.emoji,
|
785
|
+
header: s.header,
|
786
|
+
setext: s.setext,
|
787
|
+
hr: s.hr,
|
788
|
+
taskList: s.taskList,
|
789
|
+
list: s.list,
|
790
|
+
listStack: s.listStack.slice(0),
|
791
|
+
quote: s.quote,
|
792
|
+
indentedCode: s.indentedCode,
|
793
|
+
trailingSpace: s.trailingSpace,
|
794
|
+
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
795
|
+
md_inside: s.md_inside,
|
796
|
+
fencedEndRE: s.fencedEndRE
|
797
|
+
};
|
798
|
+
},
|
799
|
+
|
800
|
+
token: function(stream, state) {
|
801
|
+
|
802
|
+
// Reset state.formatting
|
803
|
+
state.formatting = false;
|
804
|
+
|
805
|
+
if (stream != state.thisLine.stream) {
|
806
|
+
state.header = 0;
|
807
|
+
state.hr = false;
|
808
|
+
|
809
|
+
if (stream.match(/^\s*$/, true)) {
|
810
|
+
blankLine(state);
|
811
|
+
return null;
|
812
|
+
}
|
813
|
+
|
814
|
+
state.prevLine = state.thisLine
|
815
|
+
state.thisLine = {stream: stream}
|
816
|
+
|
817
|
+
// Reset state.taskList
|
818
|
+
state.taskList = false;
|
819
|
+
|
820
|
+
// Reset state.trailingSpace
|
821
|
+
state.trailingSpace = 0;
|
822
|
+
state.trailingSpaceNewLine = false;
|
823
|
+
|
824
|
+
state.f = state.block;
|
825
|
+
if (state.f != htmlBlock) {
|
826
|
+
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, expandedTab).length;
|
827
|
+
state.indentation = indentation;
|
828
|
+
state.indentationDiff = null;
|
829
|
+
if (indentation > 0) return null;
|
830
|
+
}
|
831
|
+
}
|
832
|
+
return state.f(stream, state);
|
833
|
+
},
|
834
|
+
|
835
|
+
innerMode: function(state) {
|
836
|
+
if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
|
837
|
+
if (state.localState) return {state: state.localState, mode: state.localMode};
|
838
|
+
return {state: state, mode: mode};
|
839
|
+
},
|
840
|
+
|
841
|
+
indent: function(state, textAfter, line) {
|
842
|
+
if (state.block == htmlBlock) return htmlMode.indent(state.htmlState, textAfter, line)
|
843
|
+
if (state.localState) return state.localMode.indent(state.localState, textAfter, line)
|
844
|
+
return CodeMirror.Pass
|
845
|
+
},
|
846
|
+
|
847
|
+
blankLine: blankLine,
|
848
|
+
|
849
|
+
getType: getType,
|
850
|
+
|
851
|
+
closeBrackets: "()[]{}''\"\"``",
|
852
|
+
fold: "markdown"
|
853
|
+
};
|
854
|
+
return mode;
|
855
|
+
}, "xml");
|
856
|
+
|
857
|
+
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
858
|
+
|
859
|
+
});
|