本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.7KB

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