all repos — NoPaste @ de062991ccdf763b2091f26873047685f9c0c977

Resurrected - The PussTheCat.org fork of NoPaste

scripts/CodeMirror/mode/htmlembedded/htmlembedded.js (view raw)

 1// CodeMirror, copyright (c) by Marijn Haverbeke and others
 2// Distributed under an MIT license: https://codemirror.net/LICENSE
 3
 4(function(mod) {
 5  if (typeof exports == "object" && typeof module == "object") // CommonJS
 6    mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
 7        require("../../addon/mode/multiplex"));
 8  else if (typeof define == "function" && define.amd) // AMD
 9    define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
10            "../../addon/mode/multiplex"], mod);
11  else // Plain browser env
12    mod(CodeMirror);
13})(function(CodeMirror) {
14  "use strict";
15
16  CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
17    var closeComment = parserConfig.closeComment || "--%>"
18    return CodeMirror.multiplexingMode(CodeMirror.getMode(config, "htmlmixed"), {
19      open: parserConfig.openComment || "<%--",
20      close: closeComment,
21      delimStyle: "comment",
22      mode: {token: function(stream) {
23        stream.skipTo(closeComment) || stream.skipToEnd()
24        return "comment"
25      }}
26    }, {
27      open: parserConfig.open || parserConfig.scriptStartRegex || "<%",
28      close: parserConfig.close || parserConfig.scriptEndRegex || "%>",
29      mode: CodeMirror.getMode(config, parserConfig.scriptingModeSpec)
30    });
31  }, "htmlmixed");
32
33  CodeMirror.defineMIME("application/x-ejs", {name: "htmlembedded", scriptingModeSpec:"javascript"});
34  CodeMirror.defineMIME("application/x-aspx", {name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
35  CodeMirror.defineMIME("application/x-jsp", {name: "htmlembedded", scriptingModeSpec:"text/x-java"});
36  CodeMirror.defineMIME("application/x-erb", {name: "htmlembedded", scriptingModeSpec:"ruby"});
37});