Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: Source/devtools/front_end/cm/htmlembedded.js

Issue 18341003: DevTools: [CodeMirror] Add syntax highlighting for some other languages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/cm/coffeescript.js ('k') | Source/devtools/front_end/cm/php.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
2
3 //config settings
4 var scriptStartRegex = parserConfig.scriptStartRegex || /^<%/i,
5 scriptEndRegex = parserConfig.scriptEndRegex || /^%>/i;
6
7 //inner modes
8 var scriptingMode, htmlMixedMode;
9
10 //tokenizer when in html mode
11 function htmlDispatch(stream, state) {
12 if (stream.match(scriptStartRegex, false)) {
13 state.token=scriptingDispatch;
14 return scriptingMode.token(stream, state.scriptState);
15 }
16 else
17 return htmlMixedMode.token(stream, state.htmlState);
18 }
19
20 //tokenizer when in scripting mode
21 function scriptingDispatch(stream, state) {
22 if (stream.match(scriptEndRegex, false)) {
23 state.token=htmlDispatch;
24 return htmlMixedMode.token(stream, state.htmlState);
25 }
26 else
27 return scriptingMode.token(stream, state.scriptState);
28 }
29
30
31 return {
32 startState: function() {
33 scriptingMode = scriptingMode || CodeMirror.getMode(config, parserConfig.s criptingModeSpec);
34 htmlMixedMode = htmlMixedMode || CodeMirror.getMode(config, "htmlmixed");
35 return {
36 token : parserConfig.startOpen ? scriptingDispatch : htmlDispatch,
37 htmlState : CodeMirror.startState(htmlMixedMode),
38 scriptState : CodeMirror.startState(scriptingMode)
39 };
40 },
41
42 token: function(stream, state) {
43 return state.token(stream, state);
44 },
45
46 indent: function(state, textAfter) {
47 if (state.token == htmlDispatch)
48 return htmlMixedMode.indent(state.htmlState, textAfter);
49 else if (scriptingMode.indent)
50 return scriptingMode.indent(state.scriptState, textAfter);
51 },
52
53 copyState: function(state) {
54 return {
55 token : state.token,
56 htmlState : CodeMirror.copyState(htmlMixedMode, state.htmlState),
57 scriptState : CodeMirror.copyState(scriptingMode, state.scriptState)
58 };
59 },
60
61 electricChars: "/{}:",
62
63 innerMode: function(state) {
64 if (state.token == scriptingDispatch) return {state: state.scriptState, mo de: scriptingMode};
65 else return {state: state.htmlState, mode: htmlMixedMode};
66 }
67 };
68 }, "htmlmixed");
69
70 CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingMode Spec:"javascript"});
71 CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingMod eSpec:"text/x-csharp"});
72 CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingMode Spec:"text/x-java"});
73 CodeMirror.defineMIME("application/x-erb", { name: "htmlembedded", scriptingMode Spec:"ruby"});
paulirish 2013/07/03 21:20:48 Looks like we don't include the Ruby mode.
OLDNEW
« no previous file with comments | « Source/devtools/front_end/cm/coffeescript.js ('k') | Source/devtools/front_end/cm/php.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698