From 3a754133dbc138390503341fd2e9beba3e43aa4b Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 27 Jan 2012 12:05:17 -0800 Subject: Merged old FileIO --- .../codemirror/mode/htmlembedded/htmlembedded.js | 68 ++++++++++++++++++++++ imports/codemirror/mode/htmlembedded/index.html | 49 ++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100755 imports/codemirror/mode/htmlembedded/htmlembedded.js create mode 100755 imports/codemirror/mode/htmlembedded/index.html (limited to 'imports/codemirror/mode/htmlembedded') diff --git a/imports/codemirror/mode/htmlembedded/htmlembedded.js b/imports/codemirror/mode/htmlembedded/htmlembedded.js new file mode 100755 index 00000000..08e170ea --- /dev/null +++ b/imports/codemirror/mode/htmlembedded/htmlembedded.js @@ -0,0 +1,68 @@ +CodeMirror.defineMode("htmlembedded", function(config, parserConfig) { + + //config settings + var scriptStartRegex = parserConfig.scriptStartRegex || /^<%/i, + scriptEndRegex = parserConfig.scriptEndRegex || /^%>/i; + + //inner modes + var scriptingMode, htmlMixedMode; + + //tokenizer when in html mode + function htmlDispatch(stream, state) { + if (stream.match(scriptStartRegex, false)) { + state.token=scriptingDispatch; + return scriptingMode.token(stream, state.scriptState); + } + else + return htmlMixedMode.token(stream, state.htmlState); + } + + //tokenizer when in scripting mode + function scriptingDispatch(stream, state) { + if (stream.match(scriptEndRegex, false)) { + state.token=htmlDispatch; + return htmlMixedMode.token(stream, state.htmlState); + } + else + return scriptingMode.token(stream, state.scriptState); + } + + + return { + startState: function() { + scriptingMode = scriptingMode || CodeMirror.getMode(config, parserConfig.scriptingModeSpec); + htmlMixedMode = htmlMixedMode || CodeMirror.getMode(config, "htmlmixed"); + return { + token : parserConfig.startOpen ? scriptingDispatch : htmlDispatch, + htmlState : htmlMixedMode.startState(), + scriptState : scriptingMode.startState() + } + }, + + token: function(stream, state) { + return state.token(stream, state); + }, + + indent: function(state, textAfter) { + if (state.token == htmlDispatch) + return htmlMixedMode.indent(state.htmlState, textAfter); + else + return scriptingMode.indent(state.scriptState, textAfter); + }, + + copyState: function(state) { + return { + token : state.token, + htmlState : CodeMirror.copyState(htmlMixedMode, state.htmlState), + scriptState : CodeMirror.copyState(scriptingMode, state.scriptState) + } + }, + + + electricChars: "/{}:" + } +}); + +CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingModeSpec:"javascript"}); +CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"}); +CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingModeSpec:"text/x-java"}); diff --git a/imports/codemirror/mode/htmlembedded/index.html b/imports/codemirror/mode/htmlembedded/index.html new file mode 100755 index 00000000..c1374e58 --- /dev/null +++ b/imports/codemirror/mode/htmlembedded/index.html @@ -0,0 +1,49 @@ + + +
+Mode for html embedded scripts like JSP and ASP.NET. Depends on HtmlMixed which in turn depends on
+ JavaScript, CSS and XML.
Other dependancies include those of the scriping language chosen.
MIME types defined: application/x-aspx
(ASP.NET),
+ application/x-ejs
(Embedded Javascript), application/x-jsp
(JavaServer Pages)