Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
776 lars 1
<!doctype html>
2
<title>CodeMirror: HTML mixed mode</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/selection/selection-pointer.js"></script>
8
<script src="../xml/xml.js"></script>
9
<script src="../javascript/javascript.js"></script>
10
<script src="../css/css.js"></script>
11
<script src="../vbscript/vbscript.js"></script>
12
<script src="htmlmixed.js"></script>
13
<style>
14
    .CodeMirror {
15
        border-top: 1px solid black;
16
        border-bottom: 1px solid black;
17
    }
18
</style>
19
<div id=nav>
20
    <a href="http://codemirror.net">
21
        <h1>CodeMirror</h1>
22
        <img id=logo src="../../doc/logo.png">
23
    </a>
24
    <ul>
25
        <li>
26
            <a href="../../index.html">Home</a>
27
            <li>
28
                <a href="../../doc/manual.html">Manual</a>
29
                <li>
30
                    <a href="https://github.com/codemirror/codemirror">Code</a>
31
    </ul>
32
    <ul>
33
        <li>
34
            <a href="../index.html">Language modes</a>
35
            <li>
36
                <a class=active href="#">HTML mixed</a>
37
    </ul>
38
</div>
39
<article>
40
    <h2>HTML mixed mode</h2>
41
    <form>
42
        <textarea id="code" name="code">
43
            <html style="color: green">
44
            <!-- this is a comment -->
45
 
46
            <head>
47
                <title>Mixed HTML Example</title>
48
                <style type="text/css">
49
                    h1 {
50
                        font-family: comic sans;
51
                        color: #f0f;
52
                    }
53
 
54
                    div {
55
                        background: yellow !important;
56
                    }
57
 
58
                    body {
59
                        max-width: 50em;
60
                        margin: 1em 2em 1em 5em;
61
                    }
62
                </style>
63
            </head>
64
 
65
            <body>
66
                <h1>Mixed HTML Example</h1>
67
                <script>
68
                    function jsFunc(arg1, arg2)
69
                    {
70
                        if (arg1 && arg2) document.body.innerHTML = "achoo";
71
                    }
72
                </script>
73
            </body>
74
 
75
            </html>
76
        </textarea>
77
    </form>
78
    <script>
79
        // Define an extended mixed-mode that understands vbscript and
80
        // leaves mustache/handlebars embedded templates in html mode
81
        var mixedMode = {
82
            name: "htmlmixed",
83
            scriptTypes: [
84
            {
85
                matches: /\/x-handlebars-template|\/x-mustache/i,
86
                mode: null
87
            },
88
            {
89
                matches: /(text|application)\/(x-)?vb(a|script)/i,
90
                mode: "vbscript"
91
            }]
92
        };
93
        var editor = CodeMirror.fromTextArea(document.getElementById("code"),
94
        {
95
            mode: mixedMode,
96
            selectionPointer: true
97
        });
98
    </script>
99
    <p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p>
100
    <p>It takes an optional mode configuration option, <code>scriptTypes</code>, which can be used to add custom behavior for specific <code>&lt;script type="..."></code> tags. If given, it should hold an array of <code>{matches, mode}</code> objects, where
101
        <code>matches</code> is a string or regexp that matches the script type, and <code>mode</code> is either <code>null</code>, for script types that should stay in HTML mode, or a
102
        <a href="../../doc/manual.html#option_mode">mode spec</a> corresponding to the mode that should be used for the script.</p>
103
    <p>
104
        <strong>MIME types defined:</strong> <code>text/html</code> (redefined, only takes effect if you load this parser after the XML parser).</p>
105
</article>