multiplex.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!doctype html>
  2. <title>CodeMirror: Multiplexing Parser Demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <script src="../addon/mode/multiplex.js"></script>
  8. <script src="../mode/xml/xml.js"></script>
  9. <style>
  10. .CodeMirror {border: 1px solid black;}
  11. .cm-delimit {color: #fa4;}
  12. </style>
  13. <div id=nav>
  14. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  15. <ul>
  16. <li><a href="../index.html">Home</a>
  17. <li><a href="../doc/manual.html">Manual</a>
  18. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  19. </ul>
  20. <ul>
  21. <li><a class=active href="#">Multiplexing Parser</a>
  22. </ul>
  23. </div>
  24. <article>
  25. <h2>Multiplexing Parser Demo</h2>
  26. <form><textarea id="code" name="code">
  27. <html>
  28. <body style="<<magic>>">
  29. <h1><< this is not <html >></h1>
  30. <<
  31. multiline
  32. not html
  33. at all : &amp;amp; <link/>
  34. >>
  35. <p>this is html again</p>
  36. </body>
  37. </html>
  38. </textarea></form>
  39. <script>
  40. CodeMirror.defineMode("demo", function(config) {
  41. return CodeMirror.multiplexingMode(
  42. CodeMirror.getMode(config, "text/html"),
  43. {open: "<<", close: ">>",
  44. mode: CodeMirror.getMode(config, "text/plain"),
  45. delimStyle: "delimit"}
  46. // .. more multiplexed styles can follow here
  47. );
  48. });
  49. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  50. mode: "demo",
  51. lineNumbers: true,
  52. lineWrapping: true
  53. });
  54. </script>
  55. <p>Demonstration of a multiplexing mode, which, at certain
  56. boundary strings, switches to one or more inner modes. The out
  57. (HTML) mode does not get fed the content of the <code>&lt;&lt;
  58. >></code> blocks. See
  59. the <a href="../doc/manual.html#addon_multiplex">manual</a> and
  60. the <a href="../addon/mode/multiplex.js">source</a> for more
  61. information.</p>
  62. <p>
  63. <strong>Parsing/Highlighting Tests:</strong>
  64. <a href="../test/index.html#multiplexing_*">normal</a>,
  65. <a href="../test/index.html#verbose,multiplexing_*">verbose</a>.
  66. </p>
  67. </article>