corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>Static Code highlighter using Ace</title>
6 <meta name="author" content="Matthew Kastor">
7 <style type="text/css">
8 .code {
9 width: 50%;
10 white-space: pre-wrap;
11 border: solid lightgrey 1px
12 }
13 </style>
14 </head>
15 <body>
16  
17 <h2>Client Side Syntax Highlighting</h2>
18  
19 <p>Syntax highlighting using Ace language modes and themes.</p>
20  
21 <div class="code" ace-mode="ace/mode/css" ace-theme="ace/theme/chrome" ace-gutter="true">
22 .code {
23 width: 50%;
24 white-space: pre-wrap;
25 border: solid lightgrey 1px
26 }
27  
28 </div>
29  
30 <pre class="code" ace-mode="ace/mode/javascript" ace-theme="ace/theme/twilight">
31 function wobble (flam) {
32 return flam.wobbled = true;
33 }
34  
35 </pre>
36  
37  
38 <div class="code" ace-mode="ace/mode/lua" ace-theme="ace/theme/chrome" ace-gutter="true" style="width: 30em;">
39 --[[--
40 num_args takes in 5.1 byte code and extracts the number of arguments from its function header.
41 --]]--
42  
43 function int(t)
44 return t:byte(1) + t:byte(2) * 0x100 + t:byte(3) * 0x10000 + t:byte(4) * 0x1000000
45 end
46  
47 function num_args(func)
48 local dump = string.dump(func)
49 local offset, cursor = int(dump:sub(13)), offset + 26
50 --Get the params and var flag (whether there's a ... in the param)
51 return dump:sub(cursor):byte(), dump:sub(cursor+1):byte()
52 end
53  
54 </div>
55  
56  
57 <!-- load ace -->
58 <script src="../src/ace.js"></script>
59 <!-- load ace static_highlight extension -->
60 <script src="../src/ext-static_highlight.js"></script>
61 <script>
62 var highlight = ace.require("ace/ext/static_highlight")
63 var dom = ace.require("ace/lib/dom")
64 function qsa(sel) {
65 return Array.apply(null, document.querySelectorAll(sel));
66 }
67  
68 qsa(".code").forEach(function (codeEl) {
69 highlight(codeEl, {
70 mode: codeEl.getAttribute("ace-mode"),
71 theme: codeEl.getAttribute("ace-theme"),
72 startLineNumber: 1,
73 showGutter: codeEl.getAttribute("ace-gutter"),
74 trim: true
75 }, function (highlighted) {
76  
77 });
78 });
79 </script>
80  
81 </body>
82 </html>