Source

highlight / demo.html

<html>
    <head>
        <title>Test</title>
        <link type="text/css" href= "http://localhost:8080/css" rel="stylesheet" />
    </head>
    <body>
        <h3>Testing</h3>
        <pre class="highlight lang=python">
        #!/usr/bin/env python
        '''Run Google Query'''

        import webbrowser

        WEB_URL = "http://www.google.com/search?esrch=BetaShortcuts&amp;q=%s"
        IMAGE_URL = "http://images.google.com/images?q=%s"

        def google(query, url=WEB_URL):
            if isinstance(query, (tuple, list)):
                query = "+".join((item.strip() for item in query if item))

            url = url % query
            webbrowser.open(url)

        def main(argv=None):
            if argv is None:
                import sys
                argv = sys.argv

            from optparse import OptionParser

            parser = OptionParser("usage: %prog QUERY [QUERY2 ...]")
            parser.add_option("-i", "--images", help="search images",
                dest="images", action="store_true", default=0)

            opts, args = parser.parse_args(argv[1:])
            if len(args) &lt; 1:
                parser.error("wrong number of arguments") # Will exit

            url = IMAGE_URL if opts.images else WEB_URL
            google(args, url)

        if __name__ == "__main__":
            main()
        </pre>

        <p>
            Some random text here ...
        </p>
    </body>
    <script src="jquery.js"></script>
    <script>

        function on_code(obj, html) {
            obj.html(
            
        }

        function get_options(cls) {
            var options = {};
            var parts = cls.split(" ");
            for (var i in parts) {
                var part = parts[i];
                var subparts = part.split('=');
                if (subparts.length == 1) {
                    if (subparts[0] == 'linenos') {
                        options['linenos'] = true;
                    }
                }
                else if (subparts.length == 2) {
                    options[subparts[0]] = subparts[1];
                }
            }

            return options;
        }

        function highlight() {
            var obj = $('pre.highlight');
            var options = get_options(obj.attr('class'));
            options['code'] = obj.text();
            obj.load("http://localhost:8080/highlight", options);
        }

        function on_ready() {
            highlight();
        }

        $(document).ready(on_ready);
    </script>
</html>