summaryrefslogtreecommitdiffstats
path: root/deps/highlight.js/export.html
blob: db5b58efd6b2388f6de5f5c2100c2b7848abfedf (plain) (blame)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!-- saved from url=(0013)about:internet -->
<!-- ^^^ This is for IE not to show security warning for local files,
see http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2brows.mspx-->

<!--
Highlighted code export
Copyright (c) Vladimir Gubarkov <xonixx@gmail.com>
-->

<html>
    <head>
        <title>Highlited code export</title>
        <link rel="stylesheet" href="styles/default.css">
        <meta charset="utf-8">
        <style type="text/css">
            #t1, #t2 { width: 100%;}
            tr { vertical-align: top; }
            address { margin-top: 4em; }
        </style>
        <script src="highlight.js"></script>
        <script src="languages/cs.js"></script>
        <script src="languages/python.js"></script>
        <script src="languages/mel.js"></script>
        <script src="languages/perl.js"></script>
        <script src="languages/axapta.js"></script>
        <script src="languages/cpp.js"></script>
        <script src="languages/sql.js"></script>
        <script src="languages/smalltalk.js"></script>
        <script src="languages/profile.js"></script>
        <script src="languages/bash.js"></script>
        <script src="languages/html-xml.js"></script>
        <script src="languages/renderman.js"></script>
        <script src="languages/1c.js"></script>
        <script src="languages/delphi.js"></script>
        <script src="languages/dos.js"></script>
        <script src="languages/django.js"></script>
        <script src="languages/vbscript.js"></script>
        <script src="languages/ini.js"></script>
        <script src="languages/apache.js"></script>
        <script src="languages/ruby.js"></script>
        <script src="languages/css.js"></script>
        <script src="languages/lisp.js"></script>
        <script src="languages/java.js"></script>
        <script src="languages/javascript.js"></script>
        <script src="languages/php.js"></script>
        <script src="languages/diff.js"></script>
        <script src="languages/avrasm.js"></script>
        <script src="languages/parser3.js"></script>
        <script>hljs.initHighlightingOnLoad();</script>
    </head>
    <body>
        <script type="text/javascript">
            String.prototype.escape = function() {
                return this.replace(/&/gm, '&amp;').replace(/</gm, '&lt;').replace(/>/gm, '&gt;');
            }

            function doIt() {
                var viewDiv = document.getElementById("highlight-view");
                var t1 = document.getElementById("t1");
                var t2 = document.getElementById("t2");
                var selector = document.getElementById("langSelector");
                var selectedLang = selector.options[selector.selectedIndex].value.toLowerCase();
                if(selectedLang) {
                    viewDiv.innerHTML = '<pre><code class="'+selectedLang+'">'+t1.value.escape()+"</code></pre>";
                } else { // try auto
                    viewDiv.innerHTML = '<pre><code>' + t1.value.escape() + "</code></pre>";
                }
                hljs.highlightBlock(viewDiv.firstChild.firstChild);
                t2.value = viewDiv.innerHTML;
            }

            function copyToBuffer(textToCopy) {
                if (window.clipboardData) { // IE
                    window.clipboardData.setData("Text", textToCopy);
                } else if (window.netscape) { // FF
                    // from http://developer.mozilla.org/en/docs/Using_the_Clipboard
                    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
                    var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
                    gClipboardHelper.copyString(textToCopy);
                }
            }
        </script>
        <script type="text/javascript">
            var langSelectorHtml = '<label>Language <select id="langSelector">';
            langSelectorHtml += '<option value="">Auto</option>';
            for (var i in hljs.LANGUAGES) {
                if (hljs.LANGUAGES.hasOwnProperty(i))
                    langSelectorHtml += '<option value=\"'+i+'\">'+i.charAt(0).toUpperCase()+i.substr(1)+'</option>';
            }
            langSelectorHtml += '</select></label>';
            document.write(langSelectorHtml);
        </script>
        <table width="100%">
            <tr>
                <td><textarea rows="20" cols="50" id="t1"></textarea></td>
                <td><textarea rows="20" cols="50" id="t2"></textarea></td>
            </tr>
            <tr>
                <td>Write a code snippet</td>
                <td>Get HTML to paste anywhere (for actual styles and colors see sample.css)</td>
            </tr>
        </table>
        <table width="98%">
            <tr>
                <td><input type="button" value="Export &rarr;" onclick="doIt()"/></td>
                <td align="right"><input type="button" value="Copy to buffer" onclick="copyToBuffer(document.getElementById('t2').value);"/></td>
            </tr>
        </table>
        <div id="highlight-view"></div>
        <address>
          Export script: <a href="mailto:xonixx@gmail.com">Vladimir Gubarkov</a><br>
          Highlighting: <a href="http://softwaremaniacs.org/soft/highlight/">highlight.js</a>
        </address>
    </body>
</html>