analyze a thing, create a nice HTML document, and launch it.
166724
def launch(thing,title=False):
    """"""
    html=htmlFromThing(thing,title=title)
    if not html:
        print("no HTML was generated.")
        return
    fname="%s/%s.html"%(tempfile.gettempdir(),str(time.time()))
    with open(fname,'w') as f:
        f.write(html)
    webbrowser.open(fname)
1014220
def report(self):
        
        # make this prettier
        html = u'<hr/><a name="%s"></a>\n' % self.name()

        # Intro
        html = html + "<h2> Plugin <em>" + self.name() + "</em></h2>\n"

        # Files
        if len(self.copied_files):
            html = html + "<p>Files copied:<br><ul>\n"
            for afile in self.copied_files:
                html = html + '<li><a href="%s">%s</a>' % \
                    (u'..' + _to_u(afile['dstpath']), _to_u(afile['srcpath']))
                if afile['symlink'] == "yes":
                    html = html + " (symlink to %s)" % _to_u(afile['pointsto'])
                html = html + '</li>\n'
            html = html + "</ul></p>\n"

        # Command Output
        if len(self.executed_commands):
            html = html + "<p>Commands Executed:<br><ul>\n"
            # convert file name to relative path from our root
            # don't use relpath - these are HTML paths not OS paths.
            for cmd in self.executed_commands:
                if cmd["file"] and len(cmd["file"]):
                    cmd_rel_path = u"../" + _to_u(self.commons['cmddir']) \
                        + "/" + _to_u(cmd['file'])
                    html = html + '<li><a href="%s">%s</a></li>\n' % \
                        (cmd_rel_path, _to_u(cmd['exe']))
                else:
                    html = html + '<li>%s</li>\n' % (_to_u(cmd['exe']))
            html = html + "</ul></p>\n"

        # Alerts
        if len(self.alerts):
            html = html + "<p>Alerts:<br><ul>\n"
            for alert in self.alerts:
                html = html + '<li>%s</li>\n' % _to_u(alert)
            html = html + "</ul></p>\n"

        # Custom Text
        if self.custom_text != "":
            html = html + "<p>Additional Information:<br>\n"
            html = html + _to_u(self.custom_text) + "</p>\n"

        if six.PY2:
            return html.encode('utf8')
        else:
            return html
1050343
def build(self, text, url):
        
        super(TextLink, self).build()
        self.target = url
        self.content = text
660046
function injectDocumentWrite(targetWindow, doc) {
  var stackContainer = new Error();
  function processMarkup(markup) {
    if (markup.indexOf('<script ') == -1) {
      // Probably not a script tag. Ignore.
      return false;
    }

    // Try really hard to get base URLs.
    var baseUrl = arguments.callee.caller.caller ?
        arguments.callee.caller.caller['__src'] : null;
    if (!baseUrl) {
      var originalPrepare = Error.prepareStackTrace;
      Error.prepareStackTrace = function(e, callSites) {
        return callSites;
      };
      Error.captureStackTrace(stackContainer);
      var stack = stackContainer.stack;
      Error.prepareStackTrace = originalPrepare;
      baseUrl = stack[2].getFileName();
    }

    // We hackily do this by creating the DOM inside of a non-document-rooted
    // div and query all scripts. This lets us find multiple scripts/etc and
    // not have to worry about parsing HTML ourselves.
    var div = doc.createElement('div');
    div.innerHTML = markup;
    var scripts = div.querySelectorAll('script');
    if (!scripts || !scripts.length) {
      return false;
    }

    log('document.write* of scripts', scripts);

    // Process each script.
    // Since document.write* is synchronous, we must fetch and process inline.
    for (var n = 0; n < scripts.length; n++) {
      var script = scripts[n];
      var processedScript = processScript(script, true, baseUrl);
      // Eval in window context - with our sourceURL tag this lets the code
      // show in the dev tools correctly.
      eval.call(targetWindow, processedScript.text);
    }

    // TODO(benvanik): ensure we aren't eating other stuff that needs to go
    // into the DOM.
    return true;
  };

  var originalDocWrite = doc.write;
  doc.write = function write(markup) {
    if (processMarkup(markup)) {
      return;
    } else {
      return originalDocWrite.apply(this, arguments);
    }
  };
  doc.write['raw'] = originalDocWrite;

  var originalDocWriteLn = doc.writeln;
  doc.writeln = function writeln(line) {
    if (processMarkup(line)) {
      return;
    } else {
      return originalDocWriteLn.apply(this, arguments);
    }
  };
  doc.writeln['raw'] = originalDocWriteLn;
}
774253
def main():
    ""

    actions = """
        {LWIN}
        {PAUSE .25}
        r
        {PAUSE .25}
        Notepad.exe{ENTER}
        {PAUSE 1}
        Hello{SPACE}World!
        {PAUSE 1}
        %{F4}
        {PAUSE .25}
        n
        """
    SendKeys(actions, pause = .1)

    keys = parse_keys(actions)
    for k in keys:
        print(k)
        k.Run()
        time.sleep(.1)

    test_strings = [
        "\n"
        "(aa)some text\n",
        "(a)some{ }text\n",
        "(b)some{{}text\n",
        "(c)some{+}text\n",
        "(d)so%me{ab 4}text",
        "(e)so%me{LEFT 4}text",
        "(f)so%me{ENTER 4}text",
        "(g)so%me{^aa 4}text",
        "(h)some +(asdf)text",
        "(i)some %^+(asdf)text",
        "(j)some %^+a text+",
        "(k)some %^+a tex+{&}",
        "(l)some %^+a tex+(dsf)",
        "",
        ]

    for s in test_strings:
        print(repr(s))
        keys = parse_keys(s, with_newlines = True)
        print(keys)

        for k in keys:
            k.Run()
            time.sleep(.1)
        print()
914511
def build_document(html_content, base_href=None):
    """"""
    assert html_content is not None

    if isinstance(html_content, unicode):
        html_content = html_content.encode("utf8", "xmlcharrefreplace")

    try:
        document = document_fromstring(html_content, parser=UTF8_PARSER)
    except (ParserError, XMLSyntaxError):
        raise ValueError("Failed to parse document contents.")

    if base_href:
        document.make_links_absolute(base_href, resolve_base_href=True)
    else:
        document.resolve_base_href()

    return document
1214825
def launch_browser(self, soup):
        
        with tempfile.NamedTemporaryFile(delete=False, suffix='.html') as file:
            file.write(soup.encode())
        webbrowser.open('file://' + file.name)
1215227
function main() {
  var topWindow = window.top;
  var isTop = window.top === window;

  // Check the top window for options.
  var options = null;
  try {
    var optionsEl = topWindow.document.querySelector('x-wtf-options');
    if (optionsEl) {
      // Options exist in the DOM, use those.
      options = JSON.parse(optionsEl.text);
    }
  } catch (e) {
    // Failed, likely because of cross-domain iframe issues.
  }

  // Grab options - if not found, not injected.
  if (!options) {
    options = fetchOptions(topWindow);
  }
  if (!options) {
    return;
  }

  // Add options to the document for other frames/etc to find.
  if (!optionsEl) {
    try {
      optionsEl = document.createElement('x-wtf-options');
      optionsEl.text = JSON.stringify(options);
      topWindow.document.documentElement.appendChild(optionsEl);
    } catch (e) {
      // Failed, likely because of cross-domain iframe issues.
    }
  }

  if (options['__instrumented__']) {
    // Instrumentation mode.
    if (isTop) {
      // Create a blob that is both the falafel and process scripts.
      // This is used to create the worker.
      var xhr = new XMLHttpRequest();
      xhr.open('GET', chrome.extension.getURL('third_party/falafel.js'), false);
      xhr.send();
      var falafelSource = xhr.responseText;
      xhr = new XMLHttpRequest();
      xhr.open('GET', chrome.extension.getURL('wtf-process.js'), false);
      xhr.send();
      var processSource = xhr.responseText;
      var blob = new Blob([
        falafelSource,
        processSource
      ], {
        type: 'application/javascript'
      });
      var blobUrl = URL.createObjectURL(blob);
      options['wtf.instrumentation.blob'] = blobUrl;

      injectScriptFile(chrome.extension.getURL('third_party/falafel.js'));
      injectScriptFile(chrome.extension.getURL('wtf-process.js'));
      injectScriptFile(chrome.extension.getURL('wtf-call-tracing.js'));
    }
    injectScriptFunction(function(options) {
      // If we are nested in an iframe, protect against cross-origin errors.
      try {
        window.top.wtfi.prepare(options, window);
      } catch (e) {
      }
    }, [
      options
    ]);
  } else {
    // Normal tracing mode.
    // Inject the tracing framework script and the prepare function.
    if (isTop) {
      var traceScriptUrl =
        chrome.extension.getURL('wtf_trace_web_js_compiled.js');
      injectScriptFunction(function(traceScriptUrl) {
        window.WTF_TRACE_SCRIPT_URL = traceScriptUrl;
      }, [traceScriptUrl]);
      injectScriptFile(traceScriptUrl);
    }
    injectScriptFunction(function(options) {
      // If we are nested in an iframe, protect against cross-origin errors.
      try {
        window.top.wtf.trace.prepare(options, window);
      } catch (e) {
      }
    }, [
      options
    ]);

    if (isTop) {
      // Inject addons, if required.
      var addons = injectAddons(options['wtf.addons'] || []);
      // Inject preparation code to start tracing with the desired options.
      injectScriptFunction(startTracing, [
        addons
      ]);
    }
  }

  if (isTop) {
    setupCommunications();
  }
}
735182
def generate_html(self, jdoc, schema, schemas):
        ''''''

        params = {'functions': sorted([j for j in jdoc \
                   if (j.schema_name == schema.object_name and j.object_type \
                       in ['function', 'procedure', 'trigger'])], \
                                      key=lambda x: x.object_name),
                   'tables': sorted([j for j in jdoc \
                   if (j.schema_name == schema.object_name and j.object_type \
                       in ['table', 'view', 'materialized view', 'foreign table'])], \
                                    key=lambda x: x.object_name),
                   'schema_name': schema.object_name,
                   'schemas': sorted(schemas, key=lambda x: x.object_name),
                   'project': self.project_name,
                   'title': '{}: schema {}'.format(self.project_name,
                                                   schema.object_name)}
        template = self.lookup.get_template('schema.mako')
        html = template.render_unicode(**params)

        return html
507663
def main():
  
  args = docopt(__doc__)
  if args['--version']:
    print(__version__)
    sys.exit()

  result = parse(
      args['<source>'],
      segmenter=args['--segmenter'],
      language=args['--language'],
      classname=args['--classname'])
  print(result['html_code'])
  sys.exit()
1082074
def main():
    """"""
    util.create_dir(os.path.join(CONF_DIR, "templates"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/light/"))
    util.create_dir(os.path.join(CONF_DIR, "colorschemes/dark/"))

    util.setup_logging()
    parser = get_args()

    parse_args_exit(parser)
    parse_args(parser)
723641
protected void html() {
        int p = bp;
        nextChar();
        if (isIdentifierStart(ch)) {
            String name = readIdentifier();
            checkHtmlTag(name);
            htmlAttrs();
            if (ch == '/') {
                nextChar();
            }
            if (ch == '>') {
                nextChar();
                return;
            }
        } else if (ch == '/') {
            nextChar();
            if (isIdentifierStart(ch)) {
                readIdentifier();
                skipWhitespace();
                if (ch == '>') {
                    nextChar();
                    return;
                }
            }
        } else if (ch == '!') {
            nextChar();
            if (ch == '-') {
                nextChar();
                if (ch == '-') {
                    nextChar();
                    while (bp < buflen) {
                        int dash = 0;
                        while (ch == '-') {
                            dash++;
                            nextChar();
                        }
                        // Strictly speaking, a comment should not contain "--"
                        // so dash > 2 is an error, dash == 2 implies ch == '>'
                        // See http://www.w3.org/TR/html-markup/syntax.html#syntax-comments
                        // for more details.
                        if (dash >= 2 && ch == '>') {
                            nextChar();
                            return;
                        }

                        nextChar();
                    }
                }
            }
        }

        bp = p + 1;
        ch = buf[bp];
    }
1116617
def main():
    

    # register specific rst directives
    # small trick here: get_language will reveal languages.en
    labels = languages.get_language('en').labels
    # add the label
    languages.en.labels["todo"] = "Todo"
    # add node
    add_node(todo,
             html=(visit_todo, depart_todo),
             latex=(visit_todo, depart_todo),
             text=(visit_todo, depart_todo))
    # nodes._add_node_class_names(['todo'])

    # register the new directive todo
    directives.register_directive('todo', Todo)

    # add the label
    languages.en.labels["done"] = "Done"
    # add node
    add_node(done,
             html=(visit_done, depart_done),
             latex=(visit_done, depart_done),
             text=(visit_done, depart_done))
    # nodes._add_node_class_names(['todo'])

    # register the new directive todo
    directives.register_directive('done', Done)

    # Check if the directory is under git, if not, create the repo
    try:
        Repo()
    except InvalidGitRepositoryError:
        Repo.init()

    # add view path from module localisation
    views_path = attowiki_distro_path() + '/views/'
    bottle.TEMPLATE_PATH.insert(0, views_path)

    app = bottle.Bottle()

    # All the Urls of the project
    # index or __index__
    app.route('/', method='GET')(views.view_page)
    # new page
    app.route('/', method='POST')(views.view_page)
    # meta pages
    app.route('/__index__')(views.view_meta_index)
    app.route('/__cheatsheet__')(views.view_meta_cheat_sheet)
    app.route('/__history__/<gitref>/<name>.__source__')(
        views.view_history_source)
    app.route('/__history__/<gitref>/<name>.__diff__')(views.view_history_diff)
    app.route('/__history__/<gitref>/<name>')(views.view_history)
    app.route('/__<admonition_name>__')(views.view_meta_admonition)

    # export pdf
    app.route('/pdf/<name>')(views.view_pdf)

    # new page
    app.route('/edit/')(views.view_edit)
    # edit an existing page
    app.route('/edit/<name>')(views.view_edit)

    # cancel the edition of an existing page
    app.route('/cancel-edit/')(views.view_cancel_edit)
    app.route('/cancel-edit/<name>')(views.view_cancel_edit)

    # meta page for one single document
    app.route('/<name>.__source__')(views.view_history_source)
    app.route('/<name>.__diff__')(views.view_history_diff)
    app.route('/<name>.__<admonition_name>__')(views.view_meta_admonition)
    # view an existing page
    app.route('/<name>', method='GET')(views.view_page)

    # write new content to an existing page
    app.route('/<name>', method='POST')(views.view_page)
    # write new content to an existing page (without commit - for quick save)
    app.route('/<name>', method='PUT')(views.view_quick_save_page)

    # for devt purpose: set bottle in debug mode
    bottle.debug(True)  # this line may be commented in production mode

    # run locally by default
    import argparse
    cmd_parser = argparse.ArgumentParser(
        description="usage: %prog package.module:app")
    cmd_parser.add_argument('-u', '--user', help='user name for auth',
                            default=None)
    cmd_parser.add_argument('-p', '--password', help='password for auth',
                            default=None)
    cmd_parser.add_argument('host', help='host to bind',
                            default='localhost', nargs='?')
    cmd_parser.add_argument('port', help='bind port',
                            default='8080', nargs='?')
    args = cmd_parser.parse_args()
    attowiki.user = args.user
    attowiki.password = args.password
    if ':' in args.host:
        args.host, args.port = args.host.rsplit(':', 1)
    bottle.run(app, host=args.host, port=args.port)
725050
function createSite() {
  function app(page) { app.handle(page); }
  mixin(app, EventEmitter.prototype, false);
  mixin(app, proto, false);
  app.init();
  return app;
}
99678
function processFile() {
  const options = { collapseWhitespace: true };
  return (file, callback) => {
    if (file.meta.filePath.ext !== '.html') {
      async.nextTick(callback, null, file);
      return;
    }

    const data = htmlMinifier.minify(file.data, options);
    async.nextTick(callback, null, Object.assign({}, file, { data }));
  };
}
1115542
public void open() {
        super.open();
        try {
            writeComment(Document.getVersion());
            writeComment("CreationDate: " + new Date().toString());
            addTabs(1);
            writeEnd(HtmlTags.HEAD);
            addTabs(1);
            writeStart(HtmlTags.BODY);
            if (document.leftMargin() > 0) {
                write(HtmlTags.LEFTMARGIN, String.valueOf(document.leftMargin()));
            }
            if (document.rightMargin() > 0) {
                write(HtmlTags.RIGHTMARGIN, String.valueOf(document.rightMargin()));
            }
            if (document.topMargin() > 0) {
                write(HtmlTags.TOPMARGIN, String.valueOf(document.topMargin()));
            }
            if (document.bottomMargin() > 0) {
                write(HtmlTags.BOTTOMMARGIN, String.valueOf(document.bottomMargin()));
            }
            if (pageSize.getBackgroundColor() != null) {
                write(HtmlTags.BACKGROUNDCOLOR, HtmlEncoder.encode(pageSize.getBackgroundColor()));
            }
            if (document.getJavaScript_onLoad() != null) {
                write(HtmlTags.JAVASCRIPT_ONLOAD, HtmlEncoder.encode(document.getJavaScript_onLoad()));
            }
            if (document.getJavaScript_onUnLoad() != null) {
                write(HtmlTags.JAVASCRIPT_ONUNLOAD, HtmlEncoder.encode(document.getJavaScript_onUnLoad()));
            }
            if (document.getHtmlStyleClass() != null) {
                write(Markup.HTML_ATTR_CSS_CLASS, document.getHtmlStyleClass());
            }
            os.write(GT);
            initHeader(); // line added by David Freels
        }
        catch(IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
    }
596416
def main(search, query):
    """"""
    url = search.search(query)
    print(url)
    search.open_page(url)