comparison .cms/lib/codemirror/demo/runmode-standalone.html @ 0:78edf6b517a0 draft

24.10
author Coffee CMS <info@coffee-cms.ru>
date Fri, 11 Oct 2024 22:40:23 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:78edf6b517a0
1 <!doctype html>
2
3 <title>CodeMirror: Mode Runner Demo</title>
4 <meta charset="utf-8"/>
5 <link rel=stylesheet href="../doc/docs.css">
6
7 <link rel="stylesheet" href="../lib/codemirror.css">
8 <script src="../addon/runmode/runmode-standalone.js"></script>
9 <script src="../mode/xml/xml.js"></script>
10 <div id=nav>
11 <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
12
13 <ul>
14 <li><a href="../index.html">Home</a>
15 <li><a href="../doc/manual.html">Manual</a>
16 <li><a href="https://github.com/codemirror/codemirror5">Code</a>
17 </ul>
18 <ul>
19 <li><a class=active href="#">Mode Runner</a>
20 </ul>
21 </div>
22
23 <article>
24 <h2>Mode Runner Demo</h2>
25
26
27 <textarea id="code" style="width: 90%; height: 7em; border: 1px solid black; padding: .2em .4em;">
28 <foobar>
29 <blah>Enter your xml here and press the button below to display
30 it as highlighted by the CodeMirror XML mode</blah>
31 <tag2 foo="2" bar="&amp;quot;bar&amp;quot;"/>
32 </foobar></textarea><br>
33 <button onclick="doHighlight();">Highlight!</button>
34 <pre id="output" class="cm-s-default"></pre>
35
36 <script>
37 function doHighlight() {
38 CodeMirror.runMode(document.getElementById("code").value, "application/xml",
39 document.getElementById("output"));
40 }
41 </script>
42
43 <p>Running a CodeMirror mode outside of the editor.
44 The <code>CodeMirror.runMode</code> function, defined
45 in <code><a href="../addon/runmode/runmode.js">addon/runmode/runmode.js</a></code> takes the following arguments:</p>
46
47 <dl>
48 <dt><code>text (string)</code></dt>
49 <dd>The document to run through the highlighter.</dd>
50 <dt><code>mode (<a href="../doc/manual.html#option_mode">mode spec</a>)</code></dt>
51 <dd>The mode to use (must be loaded as normal).</dd>
52 <dt><code>output (function or DOM node)</code></dt>
53 <dd>If this is a function, it will be called for each token with
54 two arguments, the token's text and the token's style class (may
55 be <code>null</code> for unstyled tokens). If it is a DOM node,
56 the tokens will be converted to <code>span</code> elements as in
57 an editor, and inserted into the node
58 (through <code>innerHTML</code>).</dd>
59 </dl>
60
61 </article>