openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

runmode.html (2265B)


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