File: static-highlighter.html

package info (click to toggle)
node-ace-code 1.40.1%2B~cs1.7.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,816 kB
  • sloc: javascript: 258,622; sh: 231; asm: 185; makefile: 130; xml: 85; jsp: 85; objc: 77; lisp: 52; cpp: 34; java: 34; tcl: 30; cobol: 30; pascal: 29; ruby: 27; vhdl: 25; fortran: 21; erlang: 17; python: 13; php: 12; perl: 11; haskell: 10; ml: 10; sql: 6; ada: 5; cs: 3
file content (84 lines) | stat: -rw-r--r-- 2,223 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Static Code highlighter using Ace</title>
    <meta name="author" content="Matthew Kastor">
    <style type="text/css">
        .code {
            width: 50%;
            white-space: pre-wrap;
            border: solid lightgrey 1px
        }
    </style>
</head>
<body>

<h2>Client Side Syntax Highlighting</h2>

<p>Syntax highlighting using Ace language modes and themes.</p>

<div class="code" ace-mode="ace/mode/css" ace-theme="ace/theme/chrome" ace-gutter="true">
.code {
    width: 50%;
    white-space: pre-wrap;
    border: solid lightgrey 1px
}

</div>

<pre class="code" ace-mode="ace/mode/javascript" ace-theme="ace/theme/twilight">
function wobble (flam) {
    return flam.wobbled = true;
}

</pre>


<div class="code" ace-mode="ace/mode/lua" ace-theme="ace/theme/chrome" ace-gutter="true" style="width: 30em;">
--[[--
num_args takes in 5.1 byte code and extracts the number of arguments from its function header.
--]]--

function int(t)
    return t:byte(1) + t:byte(2) * 0x100 + t:byte(3) * 0x10000 + t:byte(4) * 0x1000000
end

function num_args(func)
    local dump = string.dump(func)
    local offset, cursor = int(dump:sub(13)), offset + 26
    --Get the params and var flag (whether there's a ... in the param)
    return dump:sub(cursor):byte(), dump:sub(cursor+1):byte()
end

</div>


<script src="kitchen-sink/require.js"></script>
<script>
require.config({paths: { "ace" : "../src"}});

require(["ace/ace", "ace/ext/static_highlight"], function(ace) {
    var highlight = require("ace/ext/static_highlight")
    var dom = require("ace/lib/dom")
    function qsa(sel) {
        return Array.apply(null, document.querySelectorAll(sel));
    }

    qsa(".code").forEach(function (codeEl) {
        highlight(codeEl, {
            mode: codeEl.getAttribute("ace-mode"),
            theme: codeEl.getAttribute("ace-theme"),
            firstLineNumber: 1,
            showGutter: codeEl.getAttribute("ace-gutter"),
            trim: true
        }, function (highlighted) {
            
        });
    });
})
</script>

<script src="./show_own_source.js"></script>
</body>
</html>