summaryrefslogtreecommitdiff
path: root/codemirror_ui/lib/CodeMirror-2.3/demo/multiplex.html
blob: 9348545b5641fccdad17057d8b991ef6ef5f4f3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!doctype html>
<html>
  <head>
    <title>CodeMirror: Multiplexing Parser Demo</title>
    <link rel="stylesheet" href="../lib/codemirror.css">
    <script src="../lib/codemirror.js"></script>
    <script src="../lib/util/multiplex.js"></script>
    <script src="../mode/xml/xml.js"></script>
    <link rel="stylesheet" href="../doc/docs.css">

    <style type="text/css">
      .CodeMirror {border: 1px solid black;}
      .cm-delimit {color: #fa4;}
    </style>
  </head>
  <body>
    <h1>CodeMirror: Multiplexing Parser Demo</h1>

    <form><textarea id="code" name="code">
<html>
  <body>
    <h1><< this is not <html >></h1>
    <<
        multiline
        not html
        at all : &amp;amp; <link/>
    >>
    <p>this is html again</p>
  </body>
</html>
</textarea></form>

    <script>
CodeMirror.defineMode("demo", function(config) {
  return CodeMirror.multiplexingMode(
    CodeMirror.getMode(config, "text/html"),
    {open: "<<", close: ">>",
     mode: CodeMirror.getMode(config, "text/plain"),
     delimStyle: "delimit"}
    // .. more multiplexed styles can follow here
  );
});
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  mode: "demo",
  lineNumbers: true,
  lineWrapping: true
});
</script>

    <p>Demonstration of a multiplexing mode, which, at certain
    boundary strings, switches to one or more inner modes. The out
    (HTML) mode does not get fed the content of the <code>&lt;&lt;
    >></code> blocks. See
    the <a href="../doc/manual.html#util_multiplex">manual</a> and
    the <a href="../lib/util/multiplex.js">source</a> for more
    information.</p>

  </body>
</html>