In-line Analytics

PR for internal review purposes as prelude for PR to upstream
    PR'd against copy of upstream master.

Known issues to be fixed later:
- Styling is embedded in html file as prelude to re-styling
- No tests
- pep8 and pylint not looked at yet.

@jbau @jrbl @stvstnfrd @caesar2164 if you please.
I don't think this is the right place for this code, actually.  It seems wrong to add all this unrelated functionality to `add_staff_markup`, when in fact this all this has to do with a different button altogether (not "Staff Debug Info").  You should factor this out to another function.  Also, notice that `wrap_fragment` takes `frag` as an input: that is successive calls to `wrap_fragment` can be used to add more and more layers of wrapping.  This allows you to create another function that acts in sequence with `add_staff_markup`