move a few things away in to-be-integrated/
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / demo / runmode.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Mode Runner Demo</title>
6     <link rel="stylesheet" href="../lib/codemirror.css">
7     <script src="../lib/codemirror.js"></script>
8     <script src="../addon/runmode/runmode.js"></script>
9     <script src="../mode/xml/xml.js"></script>
10     <link rel="stylesheet" href="../doc/docs.css">
11   </head>
12   <body>
13     <h1>CodeMirror: Mode Runner Demo</h1>
14
15     <textarea id="code" style="width: 90%; height: 7em; border: 1px solid black; padding: .2em .4em;">
16 <foobar>
17   <blah>Enter your xml here and press the button below to display
18     it as highlighted by the CodeMirror XML mode</blah>
19   <tag2 foo="2" bar="&amp;quot;bar&amp;quot;"/>
20 </foobar></textarea><br>
21     <button onclick="doHighlight();">Highlight!</button>
22     <pre id="output" class="cm-s-default"></pre>
23
24     <script>
25 function doHighlight() {
26   CodeMirror.runMode(document.getElementById("code").value, "application/xml",
27                      document.getElementById("output"));
28 }
29 </script>
30
31     <p>Running a CodeMirror mode outside of the editor.
32     The <code>CodeMirror.runMode</code> function, defined
33     in <code><a href="../addon/runmode/runmode.js">lib/runmode.js</a></code> takes the following arguments:</p>
34
35     <dl>
36       <dt><code>text (string)</code></dt>
37       <dd>The document to run through the highlighter.</dd>
38       <dt><code>mode (<a href="../doc/manual.html#option_mode">mode spec</a>)</code></dt>
39       <dd>The mode to use (must be loaded as normal).</dd>
40       <dt><code>output (function or DOM node)</code></dt>
41       <dd>If this is a function, it will be called for each token with
42       two arguments, the token's text and the token's style class (may
43       be <code>null</code> for unstyled tokens). If it is a DOM node,
44       the tokens will be converted to <code>span</code> elements as in
45       an editor, and inserted into the node
46       (through <code>innerHTML</code>).</dd>
47     </dl>
48
49   </body>
50 </html>