multiplex_test.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. (function() {
  4. CodeMirror.defineMode("markdown_with_stex", function(){
  5. var inner = CodeMirror.getMode({}, "stex");
  6. var outer = CodeMirror.getMode({}, "markdown");
  7. var innerOptions = {
  8. open: '$',
  9. close: '$',
  10. mode: inner,
  11. delimStyle: 'delim',
  12. innerStyle: 'inner'
  13. };
  14. return CodeMirror.multiplexingMode(outer, innerOptions);
  15. });
  16. var mode = CodeMirror.getMode({}, "markdown_with_stex");
  17. function MT(name) {
  18. test.mode(
  19. name,
  20. mode,
  21. Array.prototype.slice.call(arguments, 1),
  22. 'multiplexing');
  23. }
  24. MT(
  25. "stexInsideMarkdown",
  26. "[strong **Equation:**] [delim&delim-open $][inner&tag \\pi][delim&delim-close $]");
  27. CodeMirror.defineMode("identical_delim_multiplex", function() {
  28. return CodeMirror.multiplexingMode(CodeMirror.getMode({indentUnit: 2}, "javascript"), {
  29. open: "#",
  30. close: "#",
  31. mode: CodeMirror.getMode({}, "markdown"),
  32. parseDelimiters: true,
  33. innerStyle: "q"
  34. });
  35. });
  36. var mode2 = CodeMirror.getMode({}, "identical_delim_multiplex");
  37. test.mode("identical_delimiters_with_parseDelimiters", mode2, [
  38. "[keyword let] [def x] [operator =] [q #foo][q&em *bar*][q #];"
  39. ], "multiplexing")
  40. })();